Skip to content

Commit 107486c

Browse files
hovinenbcopybara-github
authored andcommitted
Document expect_that! and expect_pred! in the README.md file.
This replaces the mention of the and_log_failure() method with expect_that!, which offers more concise syntax and no drawbacks. PiperOrigin-RevId: 505970808
1 parent 4c086f8 commit 107486c

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,21 +182,19 @@ failed, but execution continues until the test completes or otherwise aborts.
182182

183183
This is analogous to the `EXPECT_*` family of macros in GoogleTest.
184184

185-
To make a non-fatal assertion, invoke the method [`and_log_failure()`] on the
186-
output of the assertion macro. The test must also be marked with
187-
[`google_test`] instead of the Rust-standard `#[test]`. It must return
188-
[`Result<()>`].
185+
To make a non-fatal assertion, use the macro [`expect_that!`]. The test must
186+
also be marked with [`google_test`] instead of the Rust-standard `#[test]`. It
187+
must return [`Result<()>`].
189188

190189
```rust
191190
use googletest::{
192-
google_test, matchers::eq, verify_that, GoogleTestSupport, Result
191+
expect_that, google_test, matchers::eq, Result
193192
};
194193

195194
#[google_test]
196195
fn more_than_one_failure() -> Result<()> {
197196
let value = 2;
198-
verify_that!(value, eq(3)).and_log_failure(); // Just marks the test as
199-
// having failed.
197+
expect_that!(value, eq(3)); // Just marks the test as having failed.
200198
verify_that!(value, eq(2))?; // Passes, but the test already failed.
201199
Ok(())
202200
}
@@ -262,7 +260,8 @@ stuff_is_correct(x, y) was false with
262260
```
263261

264262
The `verify_pred!` invocation evaluates to a [`Result<()>`] just like
265-
[`verify_that!`].
263+
[`verify_that!`]. There is also a macro [`expect_pred!`] to make a non-fatal
264+
predicaticate assertion.
266265

267266
## Unconditionally generating a test failure
268267

@@ -284,6 +283,8 @@ to this project.
284283

285284
[`and_log_failure()`]: https://docs.rs/googletest/*/googletest/trait.GoogleTestSupport.html#tymethod.and_log_failure
286285
[`assert_that!`]: https://docs.rs/googletest/*/googletest/macro.assert_that.html
286+
[`expect_pred!`]: https://docs.rs/googletest/*/googletest/macro.expect_pred.html
287+
[`expect_that!`]: https://docs.rs/googletest/*/googletest/macro.expect_that.html
287288
[`fail!`]: https://docs.rs/googletest/*/googletest/macro.fail.html
288289
[`google_test`]: https://docs.rs/googletest/*/googletest/attr.google_test.html
289290
[`matches_pattern!`]: https://docs.rs/googletest/*/googletest/macro.matches_pattern.html

0 commit comments

Comments
 (0)