6 "github.com/stretchr/testify/assert"
7 data "github.com/tendermint/go-wire/data"
8 "github.com/tendermint/go-wire/data/base58"
11 func TestEncoders(t *testing.T) {
12 assert := assert.New(t)
14 // TODO: also test other alphabets???
15 btc := base58.BTCEncoder
18 encoder data.ByteEncoder
19 input, expected []byte
21 {btc, []byte(`"3mJr7AoUXx2Wqd"`), []byte("1234598760")},
22 {btc, []byte(`"3yxU3u1igY8WkgtjK92fbJQCd4BZiiT1v25f"`), []byte("abcdefghijklmnopqrstuvwxyz")},
24 {btc, []byte(`0123`), nil}, // not in quotes
25 {btc, []byte(`"3mJr0"`), nil}, // invalid chars
28 for _, tc := range cases {
30 err := tc.encoder.Unmarshal(&output, tc.input)
31 if tc.expected == nil {
32 assert.NotNil(err, tc.input)
33 } else if assert.Nil(err, "%s: %+v", tc.input, err) {
34 assert.Equal(tc.expected, output, tc.input)