package ber import ( "bytes" "testing" ) type oidTest struct { oid OID out []byte } var oidTestData = []oidTest{ {OID{1, 3, 12, 0, 218}, []byte{0x2B, 0x0C, 0x00, 0x81, 0x5A}}, {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}}, } func TestOID(t *testing.T) { for _, test := range oidTestData { oid := marshalOID(test.oid) if !bytes.Equal(oid, test.out) { t.Error(test.oid, "expected", test.out, "got", oid) } } }