package ber import ( "bytes" "testing" ) type stringTest struct { in string out []byte } var stringTestData = []stringTest{ {"111", []byte{0x31, 0x31, 0x31}}, {"0A16", []byte{0x30, 0x41, 0x31, 0x36}}, } func TestString(t *testing.T) { for _, test := range stringTestData { a := MarshalString(test.in) if !bytes.Equal(a, test.out) { t.Error(test.in, "expexted", test.out, "got", a) } b := UnmarshalString(test.out) if b != test.in { t.Error(test.out, "expexted", test.in, "got", b) } } }