Skip to main content

assert_false

Macro assert_false 

Source
macro_rules! assert_false {
    ($condition:expr) => { ... };
    ($condition:expr, $($format_args:expr),* $(,)?) => { ... };
}
Expand description

Marks the test as failed and panics if the given value is true.

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_false!(true); // 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_false!(true, "Test failed. Extra information: {extra_information}.");
}

The output is as follows:

Value of: true
Expected: is equal to false
Actual: true,
  which isn't equal to false
Test failed. Extra information: Some additional information.