diff options
Diffstat (limited to 'src/pkg/encoding/asn1/marshal_test.go')
-rw-r--r-- | src/pkg/encoding/asn1/marshal_test.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/pkg/encoding/asn1/marshal_test.go b/src/pkg/encoding/asn1/marshal_test.go index f43bcae68..b4dbe71ef 100644 --- a/src/pkg/encoding/asn1/marshal_test.go +++ b/src/pkg/encoding/asn1/marshal_test.go @@ -82,7 +82,7 @@ var marshalTests = []marshalTest{ {explicitTagTest{64}, "3005a503020140"}, {time.Unix(0, 0).UTC(), "170d3730303130313030303030305a"}, {time.Unix(1258325776, 0).UTC(), "170d3039313131353232353631365a"}, - {time.Unix(1258325776, 0).In(PST), "17113039313131353232353631362d30383030"}, + {time.Unix(1258325776, 0).In(PST), "17113039313131353134353631362d30383030"}, {BitString{[]byte{0x80}, 1}, "03020780"}, {BitString{[]byte{0x81, 0xf0}, 12}, "03030481f0"}, {ObjectIdentifier([]int{1, 2, 3, 4}), "06032a0304"}, @@ -122,6 +122,7 @@ var marshalTests = []marshalTest{ {testSET([]int{10}), "310302010a"}, {omitEmptyTest{[]string{}}, "3000"}, {omitEmptyTest{[]string{"1"}}, "30053003130131"}, + {"Σ", "0c02cea3"}, } func TestMarshal(t *testing.T) { @@ -131,9 +132,16 @@ func TestMarshal(t *testing.T) { t.Errorf("#%d failed: %s", i, err) } out, _ := hex.DecodeString(test.out) - if bytes.Compare(out, data) != 0 { + if !bytes.Equal(out, data) { t.Errorf("#%d got: %x want %x\n\t%q\n\t%q", i, data, out, data, out) } } } + +func TestInvalidUTF8(t *testing.T) { + _, err := Marshal(string([]byte{0xff, 0xff})) + if err == nil { + t.Errorf("invalid UTF8 string was accepted") + } +} |