From deb063f01cfa8ffa66cd76174691bd27ececdbcd Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 26 Jun 2015 19:40:20 +0200 Subject: Add bool type --- ber/bool_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ber/bool_test.go (limited to 'ber/bool_test.go') diff --git a/ber/bool_test.go b/ber/bool_test.go new file mode 100644 index 0000000..47cac82 --- /dev/null +++ b/ber/bool_test.go @@ -0,0 +1,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) +} -- cgit v1.2.3