Skip to content

Commit

Permalink
handle single and array JSON schemas in test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Dec 7, 2024
1 parent 8d7517b commit f3c36e2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sample_parser/src/json_schema_testsuite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,11 @@ fn main() {

for arg in &args[1..] {
let schema_file = read_file_to_string(arg);
let val: Vec<JsonTest> =
serde_json::from_str(&schema_file).expect("Invalid JSON in schema");
let val: Vec<JsonTest> = if schema_file.starts_with("{") {
vec![serde_json::from_str(&schema_file).expect("Invalid JSON in single schema")]
} else {
serde_json::from_str(&schema_file).expect("Invalid JSON in array schema")
};
for (idx, t) in val.iter().enumerate() {
stats.num_tests += 1;
print!("Running test: {} ({}) #{} ", arg, t.description, idx);
Expand Down

0 comments on commit f3c36e2

Please sign in to comment.