aboutsummaryrefslogtreecommitdiff
path: root/ber/bool_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'ber/bool_test.go')
-rw-r--r--ber/bool_test.go22
1 files changed, 22 insertions, 0 deletions
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)
+}