macro_rules! assert_that {
( $actual: expr, panics ) => { ... };
( $actual: expr, does not panic ) => { ... };
( $actual: expr) => { ... };
( $actual: expr , otherwise $reason: expr ) => { ... };
( $actual: expr, $matcher: expr ) => { ... };
}Expand description
States that the asserted value satisfies the required properties of the supplied Matcher.
The postulated assertion is verfied immediately and panics if it is not satisfied. The macro comes in three different forms:
-
Assert that some expression is true, supplied with an optional error message.
ⓘassert_that!(EXPRESSION); assert_that!(EXPRESSION, otherwise "some error message"); -
Assert that some expression satifies the properties of some
Matcher. Expressions used withMatchers must return a reference to a value. TheMatcheris either predefined, a user defined type with aMatcherimplementation, or a closure returning aMatchResult.ⓘ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") } }) -
Assert that some expression is expected to panic/not panic.
ⓘassert_that!(panic!("panic"), panics); assert_that!(1+1, does not panic);