Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow verification for "input rejected" case #2554

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion proptest/src/test_runner/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,13 @@ impl TestRunner {
test: impl Fn(S::Value) -> TestCaseResult,
) -> TestRunResult<S> {
let tree = strategy.new_tree(self).unwrap();
test(tree.current()).unwrap();

// run harness and assert that (1) it succeeds or (2) the
// input was invalid.
assert!(matches!(
test(tree.current()),
Ok(_) | Err(TestCaseError::Reject(_))
YoshikiTakashima marked this conversation as resolved.
Show resolved Hide resolved
));
Ok(())
}

Expand Down Expand Up @@ -294,6 +300,13 @@ mod test {
"Default .cases should be 256. Check: src/test_runner/config.rs"
);
}

#[test]
fn reject_input(nil in &Just(()) ) {
if nil == () {
return Err(TestCaseError::reject("input rejected."))
}
}
}

proptest! {
Expand Down