aboutsummaryrefslogtreecommitdiff
path: root/ber
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-06-29 17:29:54 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-06-29 17:29:54 +0200
commit858afe322b6b24871630d04deeabe74b4d7802f2 (patch)
tree329f5bbd1db13dec7923e4ba2f0126cd7609b69f /ber
parent9c744184399e6684882081b0469b6a708b770ac2 (diff)
Adjust bool test
Diffstat (limited to 'ber')
-rw-r--r--ber/bool_test.go30
1 files changed, 17 insertions, 13 deletions
diff --git a/ber/bool_test.go b/ber/bool_test.go
index 47cac82..7471a33 100644
--- a/ber/bool_test.go
+++ b/ber/bool_test.go
@@ -2,21 +2,25 @@ 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)
- }
+type boolTest struct {
+ in bool
+ out byte
+}
+var boolTestData = []boolTest{
+ {true, 0xFF},
+ {false, 0x00},
}
func TestBool(t *testing.T) {
- testBool(t, true, 0xFF)
- testBool(t, true, 0x01)
- testBool(t, false, 0x00)
+ for _, test := range boolTestData {
+ a := marshalBool(test.in)
+ if a != test.out {
+ t.Error(test.in, "expected", test.out, "got", a)
+ }
+ n := unmarshalBool(test.out)
+ if n != test.in {
+ t.Error(test.out, "expected", test.in, "got", n)
+ }
+ }
}