Skip to content

Commit

Permalink
Add README example to the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kellerkindt committed Oct 14, 2020
1 parent 749999d commit 65f3275
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/basic_integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,39 @@ asn_to_rust!(
END"
);

#[test]
fn test_whether_it_compiles_at_all() {}

#[test]
fn test_default_range() {
assert_eq!(RangedMax::value_min(), NotRanged::value_min());
assert_eq!(RangedMax::value_max(), NotRanged::value_max());
let _ = NotRanged(123_u64); // does not compile if the inner type differs
}

#[test]
fn test_readme_sample() {
use asn1rs::syn::numbers::Constraint;
assert_eq!(
___asn1rs_RangedMaxField0Constraint::MIN,
___asn1rs_NotRangedField0Constraint::MIN,
);
assert_eq!(
___asn1rs_RangedMaxField0Constraint::MAX,
___asn1rs_NotRangedField0Constraint::MAX,
);

let value = NotRanged(123_u64); // does not compile if the inner type is not u64

let mut writer = NewUperWriter::default();
writer.write(&value).expect("Failed to serialize");

let mut reader = writer.into_reader();
let value2 = reader.read::<NotRanged>().expect("Failed to deserialize");

assert_eq!(value, value2);
}

#[test]
fn test_uper_small() {
let mut writer = NewUperWriter::default();
Expand Down

0 comments on commit 65f3275

Please sign in to comment.