macro_rules! result_of {
($function: expr, $matcher: expr) => { ... };
}Expand description
Matches a value where the result of callable applied to the value matches
the inner matcher.
The callable will be called twice, so make sure it is pure.
use googletest::prelude::*;
fn should_pass() -> googletest::Result<()> {
verify_that!(100, result_of!(|value| value + 1, eq(101)))?; // Passes
Ok(())
}
fn should_fail() -> googletest::Result<()> {
verify_that!(100, result_of!(|value| value * 2, eq(100)))?; // Fails
Ok(())
}
should_pass().unwrap();
should_fail().unwrap_err();