-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathparse_with_components.rs
57 lines (45 loc) · 1.12 KB
/
parse_with_components.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
#![recursion_limit = "512"]
mod test_utils;
use test_utils::*;
asn_to_rust!(
r"ParseWithComponents DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
SomeEnum ::= ENUMERATED {
VarA,
VarB,
VarC
}
BaseSeq ::= SEQUENCE {
abc UTF8String,
def SomeEnum
}
SeqButOnlyVarB ::= BaseSeq(WITH COMPONENTS {
...,
def(VarB)
})
END"
);
#[test]
pub fn does_it_compile() {
let _ = SomeEnum::VarB;
let _ = BaseSeq {
abc: "some-utf8-string".to_string(),
def: SomeEnum::VarC,
};
let _ = SeqButOnlyVarB(BaseSeq {
abc: "some-utf8-string-again".to_string(),
def: SomeEnum::VarB,
});
}
#[test]
pub fn with_components_must_be_transparent() {
let mut writer1 = UperWriter::default();
let mut writer2 = UperWriter::default();
let base_seq = BaseSeq {
abc: "some-utf8-string-again".to_string(),
def: SomeEnum::VarB,
};
base_seq.write(&mut writer1).unwrap();
SeqButOnlyVarB(base_seq).write(&mut writer2).unwrap();
assert_eq!(writer1.into_bytes_vec(), writer2.into_bytes_vec());
}