From ec6c8b5883eccdf304b932e25f847a2546ec46f5 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 6 Aug 2015 17:10:50 +0200 Subject: fix UnmarshalOID --- ber/obj_test.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'ber/obj_test.go') diff --git a/ber/obj_test.go b/ber/obj_test.go index 7f1c4ab..53ea7f5 100644 --- a/ber/obj_test.go +++ b/ber/obj_test.go @@ -6,27 +6,32 @@ import ( ) type oidTest struct { - oid OID - out []byte + oid OID + out []byte + valid bool } var oidTestData = []oidTest{ {OID{1, 3, 12, 0, 218}, - []byte{0x2B, 0x0C, 0x00, 0x81, 0x5A}}, + []byte{0x2B, 0x0C, 0x00, 0x81, 0x5A}, true}, {OID{1, 3, 12, 0, 285, 200}, - []byte{0x2B, 0x0C, 0x00, 0x82, 0x1D, 0x81, 0x48}}, - {OID{}, []byte{}}, - {OID{0, 39}, []byte{0x27}}, - {OID{1, 39}, []byte{0x4f}}, - {OID{1, 40}, []byte{}}, - {OID{2, 40}, []byte{0x78}}, + []byte{0x2B, 0x0C, 0x00, 0x82, 0x1D, 0x81, 0x48}, true}, + {OID{}, []byte{}, false}, + {OID{0, 39}, []byte{0x27}, true}, + {OID{1, 39}, []byte{0x4f}, true}, + {OID{1, 40}, []byte{}, false}, + {OID{2, 40}, []byte{0x78}, true}, } func TestOID(t *testing.T) { for _, test := range oidTestData { - oid := marshalOID(test.oid) + oid := MarshalOID(test.oid) if !bytes.Equal(oid, test.out) { t.Error(test.oid, "expected", test.out, "got", oid) } + out := UnmarshalOID(test.out) + if test.valid && !out.Equal(test.oid) { + t.Error(test.out, "expected", test.oid, "got", out) + } } } -- cgit v1.2.3