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

import (
	"bytes"
	"testing"
)

type base128Test struct {
	in  int
	out []byte
}

var base128TestData = []base128Test{
	{643, []byte{0x85, 0x03}},
	{113549, []byte{0x86, 0xF7, 0x0D}},
	{49152, []byte{0x83, 0x80, 0x00}},
}

func TestBase128(t *testing.T) {
	for _, test := range base128TestData {
		n := base128(test.in)
		if !bytes.Equal(n, test.out) {
			t.Error(test.in, "expected", test.out, "got", n)
		}
	}
}