package ber import ( "bytes" "testing" ) type lenTest struct { in int out []byte } var lenTestData = []lenTest{ {0, []byte{0x00}}, {23, []byte{0x17}}, {193, []byte{0x81, 0xc1}}, {240, []byte{0x81, 0xf0}}, {257, []byte{0x82, 0x01, 0x01}}, } func TestLen(t *testing.T) { for _, test := range lenTestData { a := MarshalLen(test.in) if !bytes.Equal(a, test.out) { t.Error(test.in, "expected", test.out, "got", a) } n, _ := UnmarshalLen(test.out) if n != test.in { t.Error(test.out, "expected", test.in, "got", n) } } }