macro_rules! assert_pred {
($content:expr $(,)?) => { ... };
($content:expr $(,)?, $($format_args:expr),* $(,)?) => { ... };
}
Expand description
Asserts that the given predicate applied to the given arguments returns true, panicking if it does not.
One may optionally add arguments which will be formatted and appended to a failure message. For example:
ⓘ
let extra_information = "Some additional information";
assert_pred!(1 == 2, "Test failed. Extra information: {extra_information}.");
The output is as follows:
1 == 2 was false with
Test failed. Extra information: Some additional information.
Note for users of GoogleTest for C++:
This differs from the ASSERT_PRED*
family of macros in that it panics
rather than triggering an early return from the invoking function. To get
behaviour equivalent to ASSERT_PRED*
, use verify_pred!
with the ?
operator.