Skip to content

Commit

Permalink
chore: add test cases to demonstrate multipleOf errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielBauman88 committed Nov 21, 2022
1 parent 002edce commit 5f0f64c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions jsonschema/src/keywords/multiple_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,17 @@ mod tests {
fn schema_path(schema: &Value, instance: &Value, expected: &str) {
tests_util::assert_schema_path(schema, instance, expected)
}

// https://github.com/Stranger6667/jsonschema-rs/issues/397
#[test]
fn multiple_of_error_cases() {
// is not a multiple - but remainder of division is less than epsilon
let schema = &json!({"multipleOf": 1.3});
let instance = &json!(1.3e-16);
tests_util::is_valid(schema, instance);
// is a multiple - but remainder of division is greater than epsilon
let schema = &json!({"multipleOf": 1e-16});
let instance = &json!(1e-15);
tests_util::is_not_valid(schema, instance);
}
}

0 comments on commit 5f0f64c

Please sign in to comment.