github.com/datachainlab/burrow@v0.25.0/binary/bytes_test.go (about) 1 package binary 2 3 import ( 4 "encoding/json" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestHexBytes_MarshalText(t *testing.T) { 12 bs := HexBytes{1, 2, 3, 4, 5} 13 out, err := json.Marshal(bs) 14 require.NoError(t, err) 15 assert.Equal(t, "\"0102030405\"", string(out)) 16 bs2 := new(HexBytes) 17 err = json.Unmarshal(out, bs2) 18 assert.Equal(t, bs, *bs2) 19 }