Skip to content

Commit 2854670

Browse files
Merge pull request #271 from google:improve-crate-docs
PiperOrigin-RevId: 550570527
2 parents cb570d8 + c637eb9 commit 2854670

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,23 @@ It must return [`Result<()>`].
187187
use googletest::prelude::*;
188188

189189
#[googletest::test]
190-
fn more_than_one_failure() -> Result<()> {
190+
fn failing_non_fatal_assertion() -> Result<()> {
191191
let value = 2;
192192
expect_that!(value, eq(3)); // Just marks the test as having failed.
193-
verify_that!(value, eq(2))?; // Passes, but the test already failed.
193+
verify_that!(value, eq(2))?; // Passes, so does not abort the test.
194+
Ok(()) // Because of the failing expect_that! call above, the
195+
// test fails despite returning Ok(())
196+
}
197+
```
198+
199+
```rust
200+
use googletest::prelude::*;
201+
202+
#[googletest::test]
203+
fn failing_fatal_assertion_after_non_fatal_assertion() -> Result<()> {
204+
let value = 2;
205+
verify_that!(value, eq(3))?; // Fails and aborts the test.
206+
expect_that!(value, eq(3)); // Never executes, since the test already aborted.
194207
Ok(())
195208
}
196209
```

googletest/crate_docs.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,24 @@ use googletest::prelude::*;
298298
# /* Make sure this also compiles as a doctest.
299299
#[googletest::test]
300300
# */
301-
fn more_than_one_failure() -> Result<()> {
301+
fn failing_non_fatal_assertion() -> Result<()> {
302302
let value = 2;
303303
expect_that!(value, eq(3)); // Just marks the test as having failed.
304-
verify_that!(value, eq(2))?; // Passes, but the test already failed.
304+
verify_that!(value, eq(2))?; // Passes, so does not abort the test.
305+
Ok(()) // Because of the failing expect_that! call above, the
306+
// test fails despite returning Ok(())
307+
}
308+
```
309+
310+
```no_run
311+
use googletest::prelude::*;
312+
313+
#[googletest::test]
314+
fn failing_fatal_assertion_after_non_fatal_assertion() -> Result<()> {
315+
let value = 2;
316+
expect_that!(value, eq(2)); // Passes; test still considered passing.
317+
verify_that!(value, eq(3))?; // Fails and aborts the test.
318+
expect_that!(value, eq(3)); // Never executes, since the test already aborted.
305319
Ok(())
306320
}
307321
```

0 commit comments

Comments
 (0)