macro_rules! expect_eq {
($actual:expr, [$($expected:expr),+ $(,)?] $(,)?) => { ... };
($actual:expr, [$($expected:expr),+ $(,)?], $($format_args:expr),* $(,)?) => { ... };
($actual:expr, {$($expected:expr),+ $(,)?} $(,)?) => { ... };
($actual:expr, {$($expected:expr),+ $(,)?}, $($format_args:expr),* $(,)?) => { ... };
($actual:expr, $expected:expr $(,)?) => { ... };
($actual:expr, $expected:expr, $($format_args:expr),* $(,)?) => { ... };
}
Expand description
Marks test as failed and continues execution if the second argument is not equal to first argument.
This is a not-fatal failure. The test continues execution even after the macro execution.
This can only be invoked inside tests with the
gtest
attribute. The failure must be generated
in the same thread as that running the test itself.
Example:
ⓘ
use googletest::prelude::*;
#[gtest]
fn should_fail() {
expect_eq!(2, 1);
println!("This will print!");
}
This macro has special support for matching against container. Namely:
expect_eq!(actual, [e1, e2, ...])
for checking actual contains “e1, e2, …” in order.expect_eq!(actual, {e1, e2, ...})
for checking actual contains “e1, e2, …” in any order.
One may include formatted arguments in the failure message:
ⓘ
use googletest::prelude::*;
#[gtest]
fn should_fail() {
let argument = "argument"
expect_eq!(2, 1, "custom failure message: {argument}");
println!("This will print!");
}