-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly resolve and set default value for an ENUMRATED type #56
- Loading branch information
1 parent
4a03f2f
commit 0c1cd81
Showing
9 changed files
with
178 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
mod test_utils; | ||
|
||
use test_utils::*; | ||
|
||
asn_to_rust!( | ||
r"BasicEnumerated DEFINITIONS AUTOMATIC TAGS ::= | ||
BEGIN | ||
Basic ::= ENUMERATED { | ||
abc, | ||
def, | ||
ghi | ||
} | ||
Container ::= SEQUENCE { | ||
the-selection Basic DEFAULT abc | ||
} | ||
END" | ||
); | ||
#[test] | ||
pub fn does_it_compile() { | ||
let _ = Basic::Abc; | ||
let _ = Basic::Def; | ||
let _ = Basic::Ghi; | ||
let seq = Container { | ||
the_selection: Basic::Def, | ||
}; | ||
|
||
PrintlnWriter::default().write(&seq).unwrap(); | ||
// Writing sequence MyCleverSeq, tag=Universal(16) | ||
// Writing DEFAULT (default: 1337) | ||
// Some | ||
// WRITING Integer(MIN..MAX), tag=ContextSpecific(0) | ||
// 5 | ||
} | ||
|
||
#[test] | ||
pub fn the_selection_abc() { | ||
serialize_and_deserialize_uper( | ||
1, | ||
&[0x00], | ||
&Container { | ||
the_selection: Basic::Abc, | ||
}, | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn the_selection_def() { | ||
serialize_and_deserialize_uper( | ||
3, | ||
&[0xA0], | ||
&Container { | ||
the_selection: Basic::Def, | ||
}, | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn the_selection_ghi() { | ||
serialize_and_deserialize_uper( | ||
3, | ||
&[0xC0], | ||
&Container { | ||
the_selection: Basic::Ghi, | ||
}, | ||
); | ||
} |