Skip to main content

eq

Function eq 

Source
pub fn eq<T>(expected: T) -> impl Matcher<T>
where T: PartialEq + Debug,
Expand description

Matches a value equal to expected.

On a mismatch where the values’ pretty representations are multi-line (a struct, a collection), the failure carries a line-oriented diff.

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

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