diff options
author | Dimitri Sokolyuk <demon@dim13.org> | 2015-06-29 17:29:54 +0200 |
---|---|---|
committer | Dimitri Sokolyuk <demon@dim13.org> | 2015-06-29 17:29:54 +0200 |
commit | 858afe322b6b24871630d04deeabe74b4d7802f2 (patch) | |
tree | 329f5bbd1db13dec7923e4ba2f0126cd7609b69f /ber | |
parent | 9c744184399e6684882081b0469b6a708b770ac2 (diff) |
Adjust bool test
Diffstat (limited to 'ber')
-rw-r--r-- | ber/bool_test.go | 30 |
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) + } + } } |