expect_false

Macro expect_false 

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

Marks test as failed and continue execution if the expression evaluates to true.

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_false!(2 + 2 == 4);
    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_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.