macro_rules! assert_true {
($condition:expr) => { ... };
($condition:expr, $($format_args:expr),* $(,)?) => { ... };
}Expand description
Marks the test as failed and panics if the given value is false.
This is a fatal assertion: the test panics in the event of assertion failure.
This can only be invoked inside tests with the
gtest attribute. The assertion must
occur in the same thread as that running the test itself.
Example:
ⓘ
use googletest::prelude::*;
#[gtest]
fn should_fail() {
assert_true!(false); // panic!
}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";
assert_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.