aboutsummaryrefslogtreecommitdiff
path: root/ber/ber_test.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-09-26 13:16:07 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-09-26 13:16:07 +0200
commit0a6d80154a138f8240ba18fc670854021aeee648 (patch)
tree6cf34ae75aa26cac84cbd823c32090da002ebf84 /ber/ber_test.go
parent54caa4e7e085e177ff05b719ae247d21fe8c257e (diff)
fix marshalClass
Diffstat (limited to 'ber/ber_test.go')
-rw-r--r--ber/ber_test.go23
1 files changed, 23 insertions, 0 deletions
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)
+ }
+ }
+}