Skip to main content

not

Function not 

Source
pub fn not<T, M>(matcher: M) -> impl Matcher<T>
where T: Debug + ?Sized, M: Matcher<T>,
Expand description

Matches when matcher does not match.

Negating a matcher is the composable alternative to violates: not is itself a matcher, so it nests inside other combinators (all_of((not(eq(0)), lt(100)))).

use test_better_core::TestResult;
use test_better_matchers::{eq, check, not};

fn main() -> TestResult {
    check!(5).satisfies(not(eq(4)))?;
    check!(4).violates(not(eq(4)))?;
    Ok(())
}