aboutsummaryrefslogtreecommitdiff
path: root/ber/bool_test.go
blob: 47cac8265a6124c6cc55362d52e64bb7fb211f87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package ber

import "testing"

func testBool(t *testing.T, v bool, b byte) {
	a := marshalBool(v)
	if (a & 1) != (b & 1) {
		t.Error("BER", v, "expected", b, "got", a)
	}

	n := unmarshalBool(b)
	if n != v {
		t.Error("UnBER", b, "expected", v, "got", n)
	}

}

func TestBool(t *testing.T) {
	testBool(t, true, 0xFF)
	testBool(t, true, 0x01)
	testBool(t, false, 0x00)
}