Module prelude

Source
Expand description

Re-exports of the symbols in this crate which are most likely to be used.

This includes:

  • All assertion macros,
  • Traits and type definitions normally used by tests, and
  • All built-in matchers.

Typically, one imports everything in the prelude in one’s test module:

mod tests {
    use googletest::prelude::*;
}

Re-exports§

pub use super::fixtures::ConsumableFixture;
pub use super::fixtures::Fixture;
pub use super::fixtures::FixtureOf;
pub use super::fixtures::StaticFixture;
pub use super::matcher::Matcher;
pub use super::matcher::MatcherBase;
pub use super::verify_current_test_outcome;
pub use super::GoogleTestSupport;
pub use super::OrFail;
pub use super::Result;
pub use super::matchers::*;

Macros§

add_failure
Generates a failure marking the test as failed but continue execution.
add_failure_at
Generates a failure at specified location marking the test as failed but continue execution.
assert_pred
Asserts that the given predicate applied to the given arguments returns true, panicking if it does not.
assert_that
Matches the given value against the given matcher, panicking if it does not match.
expect_eq
Marks test as failed and continues execution if the second argument is not equal to first argument.
expect_false
Marks test as failed and continue execution if the expression evaluates to true.
expect_float_eq
Marks test as failed and continues execution if the float given by the first argument is not approximately equal to the float given by the second argument.
expect_ge
Marks test as failed and continues execution if the first argument is not greater than or equal to the second argument.
expect_gt
Marks test as failed and continues execution if the first argument is not greater than the second argument.
expect_le
Marks test as failed and continues execution if the first argument is greater than the second argument.
expect_lt
Marks test as failed and continues execution if the first argument is greater or equal to second argument.
expect_ne
Marks test as failed and continues execution if the second argument is equal to first argument.
expect_near
Marks the test as failed and continues execution if the float given by first argument is not equal to second argument with error tolerance of max_abs_error.
expect_pred
Asserts that the given predicate applied to the given arguments returns true, failing the test but continuing execution if not.
expect_that
Matches the given value against the given matcher, marking the test as failed but continuing execution if it does not match.
expect_true
Marks test as failed and continue execution if the expression evaluates to false.
fail
Evaluates to a Result which contains an Err variant with the given test failure message.
succeed
Generates a success. This does not make the overall test succeed. A test is only considered successful if none of its assertions fail during its execution.
verify_eq
Checks whether the second argument is equal to the first argument.
verify_false
Verify if the condition evaluates to false and returns Result.
verify_float_eq
Checks whether the float given by first argument is approximately equal to second argument.
verify_ge
Checks whether the first argument is greater than or equal to the second argument.
verify_gt
Checks whether the first argument is greater than the second argument.
verify_le
Checks whether the first argument is less than or equal to the second argument.
verify_lt
Checks whether the first argument is less than second argument.
verify_ne
Checks whether the second argument is not equal to the first argument.
verify_near
Checks whether the float given by first argument is equal to second argument with error tolerance of max_abs_error.
verify_pred
Asserts that the given predicate applied to the given arguments returns true.
verify_that
Checks whether the Matcher given by the second argument matches the first argument.
verify_true
Verify if the condition evaluates to true and returns Result.

Attribute Macros§

gtest
Marks a test to be run by the Google Rust test runner.

Derive Macros§

MatcherBase