macro_rules! expect_true {
($condition:expr) => { ... };
($condition:expr, $($format_args:expr),* $(,)?) => { ... };
}
Expand description
Marks test as failed and continue execution if the expression evaluates to false.
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_true!(2 + 2 == 5);
println!("This will print");
}
One may optionally add arguments which will be formatted and appended to a failure message. For example:
ⓘ
use googletest::prelude::*;
#[gtest]
fn should_fail() {
let extra_information = "Some additional information";
expect_true!(false, "Test failed. Extra information: {extra_information}.");
}
The output is as follows:
Value of: false
Expected: is equal to true
Actual: false,
which isn't equal to true
Test failed. Extra information: Some additional information.