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 authored Feb 12, 2025
1 parent 4d9d105 commit 1324bde
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/specification_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@ 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 1324bde

Please sign in to comment.