From 0a6d80154a138f8240ba18fc670854021aeee648 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 26 Sep 2015 13:16:07 +0200 Subject: fix marshalClass --- ber/ber_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'ber/ber_test.go') diff --git a/ber/ber_test.go b/ber/ber_test.go index 8365987..46cab4e 100644 --- a/ber/ber_test.go +++ b/ber/ber_test.go @@ -194,3 +194,26 @@ func TestLen(t *testing.T) { } } } + +var classTestData = map[Header][]byte{ + {classUniversal, kindPrimitive, tagInteger}: {0x02}, + {classUniversal, kindPrimitive, 32}: {0x1f, 0x20}, + {classUniversal, kindPrimitive, 256}: {0x1f, 0x82, 0x00}, + {classApplication, kindConstructed, 2}: {0x62}, + {classContextSpecific, kindConstructed, 1}: {0xa1}, +} + +func TestClass(t *testing.T) { + for val, out := range classTestData { + s := state{} + s.marshalClass(val) + o := s.Bytes() + if !bytes.Equal(o, out) { + t.Error(val, "expected", out, "got", o) + } + v := s.unmarshalClass() + if v != val { + t.Error(out, "expected", val, "got", v) + } + } +} -- cgit v1.2.3