aboutsummaryrefslogtreecommitdiff
path: root/ber/string_test.go
blob: 04d1fa13bb0574f1613cd1508f85178af340f23e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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)
		}
	}
}