Macro credibility::aver_eq[][src]

macro_rules! aver_eq {
    ($block:ident, $($arg:tt)+) => { ... };
}

Asserts that two values are equal to each other (using assert_eq), but does not panic.

Much like aver!, aver_eq! uses assert_eq! and catches any panic caused; if any panic occurs, it tells the test block which will fail once it gets dropped.

Examples

test_block!(tb, "An example test block", {
    aver_eq!(tb, 2+3, 5, "Math should work!");
    Ok(())
});

And here's the example of failing test cases above again, just with nicer error messages. Again, note that all the cases will be checked and contribute to the panic at the end:

test_block!(tb, "An example test block", {
    let cases = vec![
        (2, 3, 5),  // will be checked
        (1, 1, 2),  // will also be checked!
        (1, 1, 3),  // and this, too (the single successful test case)
    ];
    for (in1, in2, output) in cases {
        let result = in1+in2+1;
        aver_eq!(tb, output, result);
    }
    Ok(())
});