OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package asn1 | 5 package asn1 |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "encoding/hex" | 9 "encoding/hex" |
10 "testing" | 10 "testing" |
(...skipping 12 matching lines...) Expand all Loading... |
23 type nestedStruct struct { | 23 type nestedStruct struct { |
24 A intStruct | 24 A intStruct |
25 } | 25 } |
26 | 26 |
27 type rawContentsStruct struct { | 27 type rawContentsStruct struct { |
28 Raw RawContent | 28 Raw RawContent |
29 A int | 29 A int |
30 } | 30 } |
31 | 31 |
32 type implicitTagTest struct { | 32 type implicitTagTest struct { |
33 » A int "implicit,tag:5" | 33 » A int `asn1:"implicit,tag:5"` |
34 } | 34 } |
35 | 35 |
36 type explicitTagTest struct { | 36 type explicitTagTest struct { |
37 » A int "explicit,tag:5" | 37 » A int `asn1:"explicit,tag:5"` |
38 } | 38 } |
39 | 39 |
40 type ia5StringTest struct { | 40 type ia5StringTest struct { |
41 » A string "ia5" | 41 » A string `asn1:"ia5"` |
42 } | 42 } |
43 | 43 |
44 type printableStringTest struct { | 44 type printableStringTest struct { |
45 » A string "printable" | 45 » A string `asn1:"printable"` |
46 } | 46 } |
47 | 47 |
48 type optionalRawValueTest struct { | 48 type optionalRawValueTest struct { |
49 » A RawValue "optional" | 49 » A RawValue `asn1:"optional"` |
50 } | 50 } |
51 | 51 |
52 type testSET []int | 52 type testSET []int |
53 | 53 |
54 func setPST(t *time.Time) *time.Time { | 54 func setPST(t *time.Time) *time.Time { |
55 t.ZoneOffset = -28800 | 55 t.ZoneOffset = -28800 |
56 return t | 56 return t |
57 } | 57 } |
58 | 58 |
59 type marshalTest struct { | 59 type marshalTest struct { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 data, err := Marshal(test.in) | 120 data, err := Marshal(test.in) |
121 if err != nil { | 121 if err != nil { |
122 t.Errorf("#%d failed: %s", i, err) | 122 t.Errorf("#%d failed: %s", i, err) |
123 } | 123 } |
124 out, _ := hex.DecodeString(test.out) | 124 out, _ := hex.DecodeString(test.out) |
125 if bytes.Compare(out, data) != 0 { | 125 if bytes.Compare(out, data) != 0 { |
126 t.Errorf("#%d got: %x want %x", i, data, out) | 126 t.Errorf("#%d got: %x want %x", i, data, out) |
127 } | 127 } |
128 } | 128 } |
129 } | 129 } |
OLD | NEW |