package hexutility import ( "testing" ) type marshalTest struct { input interface{} want string } var ( encodeBytesTests = []marshalTest{ {[]byte{}, "0x"}, {[]byte{0}, "0x00"}, {[]byte{0, 0, 1, 2}, "0x00000102"}, } ) func TestEncode(t *testing.T) { for _, test := range encodeBytesTests { enc := Encode(test.input.([]byte)) if enc != test.want { t.Errorf("input %x: wrong encoding %s", test.input, enc) } } }