aboutsummaryrefslogtreecommitdiff
path: root/ber/len_test.go
blob: aeda5f91d8cb330a36c863f9f8badc76259c1b9b (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
package ber

import "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 {
		n, _ := UnmarshalLen(test.out)
		if n != test.in {
			t.Error(test.out, "expected", test.in, "got", n)
		}
	}
}