aboutsummaryrefslogtreecommitdiff
path: root/ber/string_test.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-08-06 16:17:07 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-08-06 16:17:07 +0200
commitf83e5f62aebf4924a393f5c131b32e0843a735c9 (patch)
tree1f780296743703c016e47365278566be37667d16 /ber/string_test.go
parent1011b0952a55c0102cd81ba95d46b8eaeea4bcf5 (diff)
Export string
Diffstat (limited to 'ber/string_test.go')
-rw-r--r--ber/string_test.go29
1 files changed, 18 insertions, 11 deletions
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)
+ }
+ }
}