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) } } }