aboutsummaryrefslogtreecommitdiff
path: root/ber/bool_test.go
blob: 1eae7e6a97fdddb10daf3454fd26c2b7ab42f904 (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
31
32
package ber

import (
	"bytes"
	"testing"
)

type boolTest struct {
	in  bool
	out byte
}

var boolTestData = []boolTest{
	{true, 0xFF},
	{false, 0x00},
}

func TestBool(t *testing.T) {
	for _, test := range boolTestData {
		buf := &bytes.Buffer{}
		MarshalBool(buf, test.in)
		a, _ := buf.ReadByte()
		if a != test.out {
			t.Error(test.in, "expected", test.out, "got", a)
		}
		buf.WriteByte(test.out)
		n := UnmarshalBool(buf)
		if n != test.in {
			t.Error(test.out, "expected", test.in, "got", n)
		}
	}
}