1 Star 0 Fork 52

husheng/dongle

forked from dromara/dongle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
base58_test.go 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
package dongle
import (
"strconv"
"testing"
"github.com/stretchr/testify/assert"
)
var (
base58Input = "hello world"
base58Expected = "StV1DL6CwTryKyV"
)
func TestEncode_ByBase58_FromStringToString(t *testing.T) {
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{base58Input, base58Expected},
}
for index, test := range tests {
e := Encode.FromString(test.input).ByBase58()
assert.Nil(t, e.Error)
assert.Equal(t, test.expected, e.ToString(), "Current test id is "+strconv.Itoa(index))
}
}
func TestDecode_ByBase58_FromStringToString(t *testing.T) {
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{base58Expected, base58Input},
}
for index, test := range tests {
d := Decode.FromString(test.input).ByBase58()
assert.Nil(t, d.Error)
assert.Equal(t, test.expected, d.ToString(), "Current test id is "+strconv.Itoa(index))
}
}
func TestEncode_ByBase58_FromBytesToBytes(t *testing.T) {
tests := []struct {
input []byte // 输入值
expected []byte // 期望值
}{
{[]byte(""), []byte("")},
{[]byte(base58Input), []byte(base58Expected)},
}
for index, test := range tests {
e := Encode.FromBytes(test.input).ByBase58()
assert.Nil(t, e.Error)
assert.Equal(t, test.expected, e.ToBytes(), "Current test id is "+strconv.Itoa(index))
}
}
func TestDecode_ByBase58_FromBytesToBytes(t *testing.T) {
tests := []struct {
input []byte // 输入值
expected []byte // 期望值
}{
{[]byte(""), []byte("")},
{[]byte(base58Expected), []byte(base58Input)},
}
for index, test := range tests {
d := Decode.FromBytes(test.input).ByBase58()
assert.Nil(t, d.Error)
assert.Equal(t, test.expected, d.ToBytes(), "Current test id is "+strconv.Itoa(index))
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/husheng888/dongle.git
git@gitee.com:husheng888/dongle.git
husheng888
dongle
dongle
master

搜索帮助