From 858afe322b6b24871630d04deeabe74b4d7802f2 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 29 Jun 2015 17:29:54 +0200 Subject: Adjust bool test --- ber/bool_test.go | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'ber') 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) + } + } } -- cgit v1.2.3