@@ -286,7 +286,7 @@ For example:
286286```c++
287287TEST(SkipTest, DoesSkip) {
288288 GTEST_SKIP() << "Skipping single test";
289- EXPECT_EQ(0, 1 ); // Won't fail; it won't be executed
289+ FAIL( ); // Won't fail; it won't be executed
290290}
291291
292292class SkipFixture : public ::testing::Test {
@@ -298,7 +298,7 @@ class SkipFixture : public ::testing::Test {
298298
299299// Tests for SkipFixture won't be executed.
300300TEST_F(SkipFixture, SkipsOneTest) {
301- EXPECT_EQ(5, 7 ); // Won't fail
301+ FAIL( ); // Won't fail; it won't be executed
302302}
303303```
304304
@@ -405,6 +405,51 @@ EXPECT_TRUE(IsCorrectPointIntVector(point_ints))
405405For more details regarding `AbslStringify()` and its integration with other
406406libraries, see go/abslstringify.
407407
408+ ## Regular Expression Syntax
409+
410+ When built with Bazel and using Abseil, GoogleTest uses the
411+ [RE2](https://github.com/google/re2/wiki/Syntax) syntax. Otherwise, for POSIX
412+ systems (Linux, Cygwin, Mac), GoogleTest uses the
413+ [POSIX extended regular expression](https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04)
414+ syntax. To learn about POSIX syntax, you may want to read this
415+ [Wikipedia entry](https://en.wikipedia.org/wiki/Regular_expression#POSIX_extended).
416+
417+ On Windows, GoogleTest uses its own simple regular expression implementation. It
418+ lacks many features. For example, we don't support union (`"x|y"`), grouping
419+ (`"(xy)"`), brackets (`"[xy]"`), and repetition count (`"x{5,7}"`), among
420+ others. Below is what we do support (`A` denotes a literal character, period
421+ (`.`), or a single `\\ ` escape sequence; `x` and `y` denote regular
422+ expressions.):
423+
424+ Expression | Meaning
425+ ---------- | --------------------------------------------------------------
426+ `c` | matches any literal character `c`
427+ `\\d` | matches any decimal digit
428+ `\\D` | matches any character that's not a decimal digit
429+ `\\f` | matches `\f`
430+ `\\n` | matches `\n`
431+ `\\r` | matches `\r`
432+ `\\s` | matches any ASCII whitespace, including `\n`
433+ `\\S` | matches any character that's not a whitespace
434+ `\\t` | matches `\t`
435+ `\\v` | matches `\v`
436+ `\\w` | matches any letter, `_`, or decimal digit
437+ `\\W` | matches any character that `\\w` doesn't match
438+ `\\c` | matches any literal character `c`, which must be a punctuation
439+ `.` | matches any single character except `\n`
440+ `A?` | matches 0 or 1 occurrences of `A`
441+ `A*` | matches 0 or many occurrences of `A`
442+ `A+` | matches 1 or many occurrences of `A`
443+ `^` | matches the beginning of a string (not that of each line)
444+ `$` | matches the end of a string (not that of each line)
445+ `xy` | matches `x` followed by `y`
446+
447+ To help you determine which capability is available on your system, GoogleTest
448+ defines macros to govern which regular expression it is using. The macros are:
449+ `GTEST_USES_SIMPLE_RE=1` or `GTEST_USES_POSIX_RE=1`. If you want your death
450+ tests to work in all cases, you can either `#if` on these macros or use the more
451+ limited syntax only.
452+
408453## Death Tests
409454
410455In many applications, there are assertions that can cause application failure if
@@ -416,7 +461,7 @@ corruption, security holes, or worse. Hence it is vitally important to test that
416461such assertion statements work as expected.
417462
418463Since these precondition checks cause the processes to die, we call such tests
419- _death tests_ . More generally, any test that checks that a program terminates
464+ *death tests* . More generally, any test that checks that a program terminates
420465(except by throwing an exception) in an expected fashion is also a death test.
421466
422467Note that if a piece of code throws an exception, we don't consider it "death"
@@ -462,6 +507,12 @@ verifies that:
462507 exit with exit code 0, and
463508* calling ` KillProcess() ` kills the process with signal ` SIGKILL ` .
464509
510+ {: .callout .warning}
511+ Warning: If your death test contains mocks and is expecting a specific exit
512+ code, then you must allow the mock objects to be leaked via ` Mock::AllowLeak ` .
513+ This is because the mock leak detector will exit with its own error code if it
514+ detects a leak.
515+
465516The test function body may contain other assertions and statements as well, if
466517necessary.
467518
@@ -503,51 +554,6 @@ TEST_F(FooDeathTest, DoesThat) {
503554}
504555```
505556
506- ### Regular Expression Syntax
507-
508- When built with Bazel and using Abseil, GoogleTest uses the
509- [RE2](https://github.com/google/re2/wiki/Syntax) syntax. Otherwise, for POSIX
510- systems (Linux, Cygwin, Mac), GoogleTest uses the
511- [POSIX extended regular expression](https://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04)
512- syntax. To learn about POSIX syntax, you may want to read this
513- [Wikipedia entry](https://en.wikipedia.org/wiki/Regular_expression#POSIX_extended).
514-
515- On Windows, GoogleTest uses its own simple regular expression implementation. It
516- lacks many features. For example, we don't support union (`"x|y"`), grouping
517- (`"(xy)"`), brackets (`"[xy]"`), and repetition count (`"x{5,7}"`), among
518- others. Below is what we do support (`A` denotes a literal character, period
519- (`.`), or a single `\\ ` escape sequence; `x` and `y` denote regular
520- expressions.):
521-
522- Expression | Meaning
523- ---------- | --------------------------------------------------------------
524- `c` | matches any literal character `c`
525- `\\d` | matches any decimal digit
526- `\\D` | matches any character that's not a decimal digit
527- `\\f` | matches `\f`
528- `\\n` | matches `\n`
529- `\\r` | matches `\r`
530- `\\s` | matches any ASCII whitespace, including `\n`
531- `\\S` | matches any character that's not a whitespace
532- `\\t` | matches `\t`
533- `\\v` | matches `\v`
534- `\\w` | matches any letter, `_`, or decimal digit
535- `\\W` | matches any character that `\\w` doesn't match
536- `\\c` | matches any literal character `c`, which must be a punctuation
537- `.` | matches any single character except `\n`
538- `A?` | matches 0 or 1 occurrences of `A`
539- `A*` | matches 0 or many occurrences of `A`
540- `A+` | matches 1 or many occurrences of `A`
541- `^` | matches the beginning of a string (not that of each line)
542- `$` | matches the end of a string (not that of each line)
543- `xy` | matches `x` followed by `y`
544-
545- To help you determine which capability is available on your system, GoogleTest
546- defines macros to govern which regular expression it is using. The macros are:
547- `GTEST_USES_SIMPLE_RE=1` or `GTEST_USES_POSIX_RE=1`. If you want your death
548- tests to work in all cases, you can either `#if` on these macros or use the more
549- limited syntax only.
550-
551557### How It Works
552558
553559See [Death Assertions](reference/assertions.md#death) in the Assertions
@@ -727,7 +733,7 @@ Some tips on using `SCOPED_TRACE`:
727733### Propagating Fatal Failures
728734
729735A common pitfall when using ` ASSERT_* ` and ` FAIL* ` is not understanding that
730- when they fail they only abort the _ current function _ , not the entire test. For
736+ when they fail they only abort the * current function * , not the entire test. For
731737example, the following test will segfault:
732738
733739``` c++
@@ -2382,7 +2388,7 @@ IMPORTANT: The exact format of the JSON document is subject to change.
23822388
23832389#### Detecting Test Premature Exit
23842390
2385- Google Test implements the _ premature -exit-file _ protocol for test runners to
2391+ Google Test implements the * premature -exit-file * protocol for test runners to
23862392catch any kind of unexpected exits of test programs. Upon start, Google Test
23872393creates the file which will be automatically deleted after all work has been
23882394finished. Then, the test runner can check if this file exists. In case the file
0 commit comments