Skip to content

Commit

Permalink
Check that serialization matches raw input when canonical field is om…
Browse files Browse the repository at this point in the history
  • Loading branch information
apasel422 committed Feb 11, 2025
1 parent 2ffcf79 commit ac9790f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/specification_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,20 @@ fn run_test_case(test_case: &TestData) -> Result<(), Box<dyn Error>> {
assert_eq!(expected_field_value, actual_field_value);

// Test serialization
let actual_result = actual_field_value.serialize();

if let Some(canonical_val) = &test_case.canonical {
let actual_result = actual_field_value.serialize();
if canonical_val.is_empty() {
assert!(actual_result.is_err());
} else {
assert_eq!(canonical_val[0], actual_result?);
}
} else {
// If the canonical field is omitted, the canonical form is the input.
assert_eq!(input, actual_result?);
}

Ok(())
}

Expand Down

0 comments on commit ac9790f

Please sign in to comment.