-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathbasic_null.rs
60 lines (50 loc) · 1.07 KB
/
basic_null.rs
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
mod test_utils;
use test_utils::*;
asn_to_rust!(
r"BasicNull DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
MyNull ::= NULL
NullSeq ::= SEQUENCE {
abc UTF8String,
def NULL,
ghi MyNull
}
NullChoice ::= Choice {
abc UTF8String,
def NULL,
ghi MyNull
}
END"
);
#[test]
fn test_sequence() {
// from playground
serialize_and_deserialize_uper(
8 * 4,
&[0x03, 0x61, 0x62, 0x63],
&NullSeq {
abc: "abc".to_string(),
def: Null,
ghi: MyNull(Null),
},
);
}
#[test]
fn test_choice_abc() {
// from playground
serialize_and_deserialize_uper(
8 * 4 + 2,
&[0x00, 0xD8, 0x58, 0x98, 0xC0],
&NullChoice::Abc("abc".to_string()),
);
}
#[test]
fn test_choice_def() {
// from playground
serialize_and_deserialize_uper(2, &[0x40], &NullChoice::Def(Null));
}
#[test]
fn test_choice_ghi() {
// from playground
serialize_and_deserialize_uper(2, &[0x80], &NullChoice::Ghi(MyNull(Null)));
}