Skip to content

Commit 01fb3a4

Browse files
committed
added some code which crashes
1 parent 37a9c33 commit 01fb3a4

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/macros.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ macro_rules! asn1 {
88
);
99

1010
(@field_type [$($parsed:tt)*] [INTEGER, $($rest:tt)*]) => (
11-
asn1!(@field_name [$($parsed)* @type INTEGER] [$($rest)*]);
11+
asn1!(@field_name [$($parsed)* @type INTEGER @rust_type i64] [$($rest)*]);
1212
);
1313
(@field_type [$($parsed:tt)*] [BOOLEAN, $($rest:tt)*]) => (
14-
asn1!(@field_name [$($parsed)* @type BOOLEAN] [$($rest)*]);
14+
asn1!(@field_name [$($parsed)* @type BOOLEAN @rust_type bool] [$($rest)*]);
1515
);
1616

17-
(@complete $name:ident $(, @name $field_name:ident @type $field_type:ty)*) => {
18-
struct $name;
17+
(@complete $name:ident $(, @name $field_name:ident @type $field_type:ident @rust_type $field_rust_type)*) => {
18+
struct $name {
19+
$(
20+
$field_name: $field_rust_type,
21+
)*
22+
}
1923

2024
impl $name {
2125
fn asn1_description() -> Vec<(&'static str, &'static str)> {
@@ -70,4 +74,18 @@ mod tests {
7074
("y", "BOOLEAN"),
7175
])
7276
}
77+
78+
#[test]
79+
fn test_struct() {
80+
asn1!(
81+
Double ::= SEQUENCE {
82+
x INTEGER,
83+
y BOOLEAN,
84+
}
85+
);
86+
87+
let d = Double{x: 3, y: true};
88+
assert_eq!(d.x, 3);
89+
assert_eq!(d.y, true);
90+
}
7391
}

0 commit comments

Comments
 (0)