From f83e5f62aebf4924a393f5c131b32e0843a735c9 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 6 Aug 2015 16:17:07 +0200 Subject: Export string --- ber/string_test.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'ber/string_test.go') diff --git a/ber/string_test.go b/ber/string_test.go index c783918..04d1fa1 100644 --- a/ber/string_test.go +++ b/ber/string_test.go @@ -5,19 +5,26 @@ import ( "testing" ) -func testString(t *testing.T, s string, e []byte) { - a := marshalString(s) - if !bytes.Equal(a, e) { - t.Error("String", s, "expexted", e, "got", a) - } +type stringTest struct { + in string + out []byte +} - b := unmarshalString(e) - if b != s { - t.Error("DeString", e, "expexted", s, "got", b) - } +var stringTestData = []stringTest{ + {"111", []byte{0x31, 0x31, 0x31}}, + {"0A16", []byte{0x30, 0x41, 0x31, 0x36}}, } func TestString(t *testing.T) { - testString(t, "111", []byte{0x31, 0x31, 0x31}) - testString(t, "0A16", []byte{0x30, 0x41, 0x31, 0x36}) + 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) + } + } } -- cgit v1.2.3