Macro googletest::matchers::all
source ยท macro_rules! all { ($(,)?) => { ... }; ($matcher:expr $(,)?) => { ... }; ($head:expr, $head2:expr $(,)?) => { ... }; ($head:expr, $head2:expr, $($tail:expr),+ $(,)?) => { ... }; }
Expand description
Matches a value which all of the given matchers match.
Each argument is a Matcher
which matches
against the actual value.
For example:
verify_that!("A string", all!(starts_with("A"), ends_with("string")))?; // Passes
verify_that!("A string", all!(starts_with("A"), ends_with("not a string")))?; // Fails
Using this macro is equivalent to using the
and
method:
verify_that!(10, gt(9).and(lt(11)))?; // Also passes
Assertion failure messages are not guaranteed to be identical, however.
If an inner matcher is eq(...)
, it can be omitted:
verify_that!(123, all![123, lt(1000), gt(100)])