Macro galvanic_assert::assert_that [] [src]

macro_rules! assert_that {
    ( $actual: expr, panics ) => { ... };
    ( $actual: expr, does not panic ) => { ... };
    ( $actual: expr) => { ... };
    ( $actual: expr , otherwise $reason: expr ) => { ... };
    ( $actual: expr, $matcher: expr ) => { ... };
}

States that the asserted values satisfies the required properties of the supplied Matcher.

The macro comes in three different forms:

  1. Assert that some expression is true, supplied with an optional error message.

    assert_that!(EXPRESSION);
    assert_that!(EXPRESSION, otherwise "some error message");
  2. Assert that some expression satifies the properties of some Matcher. The Matcher is either predefined, a user defined type with a Matcher implementation, or a closure returning a MatchResult

    assert_that!(1, eq(1));
    assert_that!(1, |x| {
        let builder = MatchResultBuilder::for_("my_matcher");
        if x == 1 { builder.matched } else { builder.failed_because("some reason") }
    })
  3. Assert that some expression is expected to panic/not panic.

    assert_that!(panic!("panic"), panics);
    assert_that!(1+1, does not panic);