Skip to content

Commit

Permalink
Help valgrind by parsing document multiple times in test
Browse files Browse the repository at this point in the history
  • Loading branch information
JDSeiler authored and dginev committed Jul 18, 2023
1 parent 7d48290 commit cd9eea6
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions tests/schema_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,19 @@ fn schema_from_string_reports_unique_errors() {
}

let mut xsdvalidator = xsd.unwrap();
if let Err(errors) = xsdvalidator.validate_document(&xml) {
assert_eq!(errors.len(), 5);
let expected_errors = vec![
"Element 'stock', attribute 'junkAttribute': The attribute 'junkAttribute' is not allowed.\n",
"Element 'stock': The attribute 'ticker' is required but missing.\n",
"Element 'stock': The attribute 'exchange' is required but missing.\n",
"Element 'price': 'NOT A NUMBER' is not a valid value of the atomic type 'xs:float'.\n",
"Element 'date': 'NOT A DATE' is not a valid value of the atomic type 'xs:date'.\n"
];
for err_msg in expected_errors {
assert!(errors.iter().any(|err| err.message.as_ref().unwrap() == err_msg), "Expected error message {} was not found", err_msg);
for _ in 0..5 {
if let Err(errors) = xsdvalidator.validate_document(&xml) {
assert_eq!(errors.len(), 5);
let expected_errors = vec![
"Element 'stock', attribute 'junkAttribute': The attribute 'junkAttribute' is not allowed.\n",
"Element 'stock': The attribute 'ticker' is required but missing.\n",
"Element 'stock': The attribute 'exchange' is required but missing.\n",
"Element 'price': 'NOT A NUMBER' is not a valid value of the atomic type 'xs:float'.\n",
"Element 'date': 'NOT A DATE' is not a valid value of the atomic type 'xs:date'.\n"
];
for err_msg in expected_errors {
assert!(errors.iter().any(|err| err.message.as_ref().unwrap() == err_msg), "Expected error message {} was not found", err_msg);
}
}
}
}

0 comments on commit cd9eea6

Please sign in to comment.