Macro verify_that

Source
macro_rules! verify_that {
    ($subject:expr) => { ... };
}
Expand description

Starts an assertion for the given subject or expression in the CollectFailures mode.

It wraps the subject into a Spec and sets the name of the expression and the code location of the assertion in the Spec. On the Spec any assertion method that is implemented for the subject’s type can be called.

Assertions started with verify_that! will collect AssertFailures for all failing assertions. The collected failures can be queried by calling one of the methods failures or display_failures on the Spec.

§Example

use asserting::prelude::*;
let some_text = "vel tempor augue delenit".to_string();
let failures = verify_that!(some_text)
    .starts_with("nibh")
    .ends_with("magna")
    .failures();

assert_that!(failures).has_length(2);

This call of the macro expands to:

let failures = verify_that(some_text)
    .named("some_text")
    .located_at(Location { file: file!(), line: line!(), column: column!() })
    .starts_with("nibh")
    .ends_with("magna")
    .failures();