aboutsummaryrefslogtreecommitdiff
path: root/ber/class_test.go
blob: 2eac2203ff10f1dc1e1af873a4e077cd38389ec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package ber

import (
	"bytes"
	"fmt"
)

var berTestData = []byte{
	0x02, 0x04, 0x0A, 0x30,
	0x40, 0x61, 0x7E,
	0x80, 0xA1, 0xBE,
}

func ExampleIdent() {
	for _, test := range berTestData {
		c, k, t := Ident(bytes.NewBuffer([]byte{test}))
		if c == classUniversal {
			fmt.Printf("%#x: %v %v %v\n",
				test, c, k, t)
		} else {
			fmt.Printf("%#x: %v %v %#x\n",
				test, c, k, byte(t))
		}
	}
	// Output:
	// 0x2: Universal Primitive Integer
	// 0x4: Universal Primitive Octet String
	// 0xa: Universal Primitive Enumerated
	// 0x30: Universal Constructed Sequence (Of)
	// 0x40: Application Primitive 0x0
	// 0x61: Application Constructed 0x1
	// 0x7e: Application Constructed 0x1e
	// 0x80: Context-specific Primitive 0x0
	// 0xa1: Context-specific Constructed 0x1
	// 0xbe: Context-specific Constructed 0x1e
}