aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml6
-rw-r--r--googlemock/README.md7
-rw-r--r--googlemock/docs/cheat_sheet.md439
-rw-r--r--googlemock/docs/cook_book.md5
-rw-r--r--googlemock/docs/for_dummies.md6
-rw-r--r--googlemock/docs/gmock_faq.md8
-rw-r--r--googlemock/include/gmock/gmock-generated-actions.h9
-rw-r--r--googlemock/include/gmock/gmock-generated-actions.h.pump9
-rw-r--r--googlemock/include/gmock/gmock-generated-matchers.h7
-rw-r--r--googlemock/include/gmock/gmock-generated-matchers.h.pump7
-rw-r--r--googlemock/include/gmock/gmock.h4
-rw-r--r--googletest/docs/advanced.md101
-rw-r--r--googletest/docs/faq.md2
-rw-r--r--googletest/docs/primer.md55
-rw-r--r--googletest/include/gtest/gtest-typed-test.h6
-rw-r--r--googletest/include/gtest/gtest.h6
-rw-r--r--googletest/include/gtest/internal/gtest-param-util.h5
-rw-r--r--googletest/samples/sample9_unittest.cc8
-rw-r--r--googletest/src/gtest.cc62
-rw-r--r--googletest/test/googletest-listener-test.cc113
-rw-r--r--googletest/test/googletest-output-test-golden-lin.txt9
-rw-r--r--googletest/test/googletest-output-test_.cc8
-rw-r--r--googletest/test/gtest_unittest.cc11
23 files changed, 462 insertions, 431 deletions
diff --git a/.travis.yml b/.travis.yml
index 6b4c5c76..56f7d7c1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,6 @@
# This file can be validated on:
# http://lint.travis-ci.org/
-sudo: false
language: cpp
# Define the matrix explicitly, manually expanding the combinations of (os, compiler, env).
@@ -11,20 +10,17 @@ language: cpp
matrix:
include:
- os: linux
- sudo: required
before_install: chmod -R +x ./ci/*platformio.sh
install: ./ci/install-platformio.sh
script: ./ci/build-platformio.sh
- os: linux
dist: xenial
compiler: gcc
- sudo : true
install: ./ci/install-linux.sh && ./ci/log-config.sh
script: ./ci/build-linux-bazel.sh
- os: linux
dist: xenial
compiler: clang
- sudo : true
install: ./ci/install-linux.sh && ./ci/log-config.sh
script: ./ci/build-linux-bazel.sh
- os: linux
@@ -52,7 +48,7 @@ install:
script: ./ci/travis.sh
-# For sudo=false builds this section installs the necessary dependencies.
+# This section installs the necessary dependencies.
addons:
apt:
# List of whitelisted in travis packages for ubuntu-precise can be found here:
diff --git a/googlemock/README.md b/googlemock/README.md
index 55c4b832..183fdb81 100644
--- a/googlemock/README.md
+++ b/googlemock/README.md
@@ -28,6 +28,13 @@ gMock:
- does not use exceptions, and
- is easy to learn and use.
+Details and examples can be found here:
+
+* [gMock for Dummies](docs/for_dummies.md)
+* [Legacy gMock FAQ](docs/gmock_faq.md)
+* [gMock Cookbook](docs/cook_book.md)
+* [gMock Cheat Sheet](docs/cheat_sheet.md)
+
Please note that code under scripts/generator/ is from the [cppclean
project](http://code.google.com/p/cppclean/) and under the Apache
License, which is different from Google Mock's license.
diff --git a/googlemock/docs/cheat_sheet.md b/googlemock/docs/cheat_sheet.md
index 540da39e..37c808f5 100644
--- a/googlemock/docs/cheat_sheet.md
+++ b/googlemock/docs/cheat_sheet.md
@@ -177,7 +177,8 @@ Example usage:
To customize the default action for a particular method of a specific mock
object, use `ON_CALL()`. `ON_CALL()` has a similar syntax to `EXPECT_CALL()`,
but it is used for setting default behaviors (when you do not require that the
-mock method is called). See go/prefer-on-call for a more detailed discussion.
+mock method is called). See [here](cook_book.md#UseOnCall) for a more detailed
+discussion.
```cpp
ON_CALL(mock-object, method(matchers))
@@ -222,14 +223,12 @@ and the default action will be taken each time.
A **matcher** matches a *single* argument. You can use it inside `ON_CALL()` or
`EXPECT_CALL()`, or use it to validate a value directly:
+<!-- mdformat off(github rendering does not support multiline tables) -->
| Matcher | Description |
| :----------------------------------- | :------------------------------------ |
-| `EXPECT_THAT(actual_value, matcher)` | Asserts that `actual_value` matches |
-: : `matcher`. :
-| `ASSERT_THAT(actual_value, matcher)` | The same as |
-: : `EXPECT_THAT(actual_value, matcher)`, :
-: : except that it generates a **fatal** :
-: : failure. :
+| `EXPECT_THAT(actual_value, matcher)` | Asserts that `actual_value` matches `matcher`. |
+| `ASSERT_THAT(actual_value, matcher)` | The same as `EXPECT_THAT(actual_value, matcher)`, except that it generates a **fatal** failure. |
+<!-- mdformat on -->
Built-in matchers (where `argument` is the function argument) are divided into
several categories:
@@ -243,6 +242,7 @@ Matcher | Description
#### Generic Comparison
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :--------------------- | :-------------------------------------------------- |
| `Eq(value)` or `value` | `argument == value` |
@@ -253,14 +253,11 @@ Matcher | Description
| `Ne(value)` | `argument != value` |
| `IsNull()` | `argument` is a `NULL` pointer (raw or smart). |
| `NotNull()` | `argument` is a non-null pointer (raw or smart). |
-| `Optional(m)` | `argument` is `optional<>` that contains a value |
-: : matching `m`. :
-| `VariantWith<T>(m)` | `argument` is `variant<>` that holds the |
-: : alternative of type T with a value matching `m`. :
+| `Optional(m)` | `argument` is `optional<>` that contains a value matching `m`. |
+| `VariantWith<T>(m)` | `argument` is `variant<>` that holds the alternative of type T with a value matching `m`. |
| `Ref(variable)` | `argument` is a reference to `variable`. |
-| `TypedEq<type>(value)` | `argument` has type `type` and is equal to `value`. |
-: : You may need to use this instead of `Eq(value)` :
-: : when the mock function is overloaded. :
+| `TypedEq<type>(value)` | `argument` has type `type` and is equal to `value`. You may need to use this instead of `Eq(value)` when the mock function is overloaded. |
+<!-- mdformat on -->
Except `Ref()`, these matchers make a *copy* of `value` in case it's modified or
destructed later. If the compiler complains that `value` doesn't have a public
@@ -270,20 +267,14 @@ is not changed afterwards, or the meaning of your matcher will be changed.
#### Floating-Point Matchers {#FpMatchers}
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :------------------------------- | :--------------------------------- |
-| `DoubleEq(a_double)` | `argument` is a `double` value |
-: : approximately equal to `a_double`, :
-: : treating two NaNs as unequal. :
-| `FloatEq(a_float)` | `argument` is a `float` value |
-: : approximately equal to `a_float`, :
-: : treating two NaNs as unequal. :
-| `NanSensitiveDoubleEq(a_double)` | `argument` is a `double` value |
-: : approximately equal to `a_double`, :
-: : treating two NaNs as equal. :
-| `NanSensitiveFloatEq(a_float)` | `argument` is a `float` value |
-: : approximately equal to `a_float`, :
-: : treating two NaNs as equal. :
+| `DoubleEq(a_double)` | `argument` is a `double` value approximately equal to `a_double`, treating two NaNs as unequal. |
+| `FloatEq(a_float)` | `argument` is a `float` value approximately equal to `a_float`, treating two NaNs as unequal. |
+| `NanSensitiveDoubleEq(a_double)` | `argument` is a `double` value approximately equal to `a_double`, treating two NaNs as equal. |
+| `NanSensitiveFloatEq(a_float)` | `argument` is a `float` value approximately equal to `a_float`, treating two NaNs as equal. |
+<!-- mdformat on -->
The above matchers use ULP-based comparison (the same as used in googletest).
They automatically pick a reasonable error bound based on the absolute value of
@@ -292,48 +283,37 @@ which requires comparing two NaNs for equality to return false. The
`NanSensitive*` version instead treats two NaNs as equal, which is often what a
user wants.
-| Matcher | Description |
-| :---------------------------------- | :------------------------------------- |
-| `DoubleNear(a_double, | `argument` is a `double` value close |
-: max_abs_error)` : to `a_double` (absolute error <= :
-: : `max_abs_error`), treating two NaNs as :
-: : unequal. :
-| `FloatNear(a_float, max_abs_error)` | `argument` is a `float` value close to |
-: : `a_float` (absolute error <= :
-: : `max_abs_error`), treating two NaNs as :
-: : unequal. :
-| `NanSensitiveDoubleNear(a_double, | `argument` is a `double` value close |
-: max_abs_error)` : to `a_double` (absolute error <= :
-: : `max_abs_error`), treating two NaNs as :
-: : equal. :
-| `NanSensitiveFloatNear(a_float, | `argument` is a `float` value close to |
-: max_abs_error)` : `a_float` (absolute error <= :
-: : `max_abs_error`), treating two NaNs as :
-: : equal. :
+<!-- mdformat off(no multiline tables) -->
+| Matcher | Description |
+| :------------------------------------------------ | :----------------------- |
+| `DoubleNear(a_double, max_abs_error)` | `argument` is a `double` value close to `a_double` (absolute error <= `max_abs_error`), treating two NaNs as unequal. |
+| `FloatNear(a_float, max_abs_error)` | `argument` is a `float` value close to `a_float` (absolute error <= `max_abs_error`), treating two NaNs as unequal. |
+| `NanSensitiveDoubleNear(a_double, max_abs_error)` | `argument` is a `double` value close to `a_double` (absolute error <= `max_abs_error`), treating two NaNs as equal. |
+| `NanSensitiveFloatNear(a_float, max_abs_error)` | `argument` is a `float` value close to `a_float` (absolute error <= `max_abs_error`), treating two NaNs as equal. |
+<!-- mdformat on -->
#### String Matchers
The `argument` can be either a C string or a C++ string object:
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :---------------------- | :------------------------------------------------- |
| `ContainsRegex(string)` | `argument` matches the given regular expression. |
| `EndsWith(suffix)` | `argument` ends with string `suffix`. |
| `HasSubstr(string)` | `argument` contains `string` as a sub-string. |
-| `MatchesRegex(string)` | `argument` matches the given regular expression |
-: : with the match starting at the first character and :
-: : ending at the last character. :
+| `MatchesRegex(string)` | `argument` matches the given regular expression with the match starting at the first character and ending at the last character. |
| `StartsWith(prefix)` | `argument` starts with string `prefix`. |
| `StrCaseEq(string)` | `argument` is equal to `string`, ignoring case. |
-| `StrCaseNe(string)` | `argument` is not equal to `string`, ignoring |
-: : case. :
+| `StrCaseNe(string)` | `argument` is not equal to `string`, ignoring case. |
| `StrEq(string)` | `argument` is equal to `string`. |
| `StrNe(string)` | `argument` is not equal to `string`. |
+<!-- mdformat on -->
`ContainsRegex()` and `MatchesRegex()` take ownership of the `RE` object. They
use the regular expression syntax defined
-[here](http://go/gunit-advanced-regex). `StrCaseEq()`, `StrCaseNe()`, `StrEq()`,
-and `StrNe()` work for wide strings as well.
+[here](advanced.md#regular-expression-syntax). `StrCaseEq()`, `StrCaseNe()`,
+`StrEq()`, and `StrNe()` work for wide strings as well.
#### Container Matchers
@@ -342,99 +322,28 @@ or simply `expected_container` to match a container exactly. If you want to
write the elements in-line, match them more flexibly, or get more informative
messages, you can use:
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :---------------------------------------- | :------------------------------- |
-| `BeginEndDistanceIs(m)` | `argument` is a container whose |
-: : `begin()` and `end()` iterators :
-: : are separated by a number of :
-: : increments matching `m`. E.g. :
-: : `BeginEndDistanceIs(2)` or :
-: : `BeginEndDistanceIs(Lt(2))`. For :
-: : containers that define a :
-: : `size()` method, `SizeIs(m)` may :
-: : be more efficient. :
-| `ContainerEq(container)` | The same as `Eq(container)` |
-: : except that the failure message :
-: : also includes which elements are :
-: : in one container but not the :
-: : other. :
-| `Contains(e)` | `argument` contains an element |
-: : that matches `e`, which can be :
-: : either a value or a matcher. :
-| `Each(e)` | `argument` is a container where |
-: : *every* element matches `e`, :
-: : which can be either a value or a :
-: : matcher. :
-| `ElementsAre(e0, e1, ..., en)` | `argument` has `n + 1` elements, |
-: : where the *i*-th element matches :
-: : `ei`, which can be a value or a :
-: : matcher. :
-| `ElementsAreArray({e0, e1, ..., en})`, | The same as `ElementsAre()` |
-: `ElementsAreArray(a_container)`, : except that the expected element :
-: `ElementsAreArray(begin, end)`, : values/matchers come from an :
-: `ElementsAreArray(array)`, or : initializer list, STL-style :
-: `ElementsAreArray(array, count)` : container, iterator range, or :
-: : C-style array. :
-| `IsEmpty()` | `argument` is an empty container |
-: : (`container.empty()`). :
-| `IsFalse()` | `argument` evaluates to `false` |
-: : in a Boolean context. :
-| `IsSubsetOf({e0, e1, ..., en})`, | `argument` matches |
-: `IsSubsetOf(a_container)`, : `UnorderedElementsAre(x0, x1, :
-: `IsSubsetOf(begin, end)`, : ..., xk)` for some subset `{x0, :
-: `IsSubsetOf(array)`, or : x1, ..., xk}` of the expected :
-: `IsSubsetOf(array, count)` : matchers. :
-| `IsSupersetOf({e0, e1, ..., en})`, | Some subset of `argument` |
-: `IsSupersetOf(a_container)`, : matches :
-: `IsSupersetOf(begin, end)`, : `UnorderedElementsAre(`expected :
-: `IsSupersetOf(array)`, or : matchers`)`. :
-: `IsSupersetOf(array, count)` : :
-| `IsTrue()` | `argument` evaluates to `true` |
-: : in a Boolean context. :
-| `Pointwise(m, container)`, `Pointwise(m, | `argument` contains the same |
-: {e0, e1, ..., en})` : number of elements as in :
-: : `container`, and for all i, (the :
-: : i-th element in `argument`, the :
-: : i-th element in `container`) :
-: : match `m`, which is a matcher on :
-: : 2-tuples. E.g. `Pointwise(Le(), :
-: : upper_bounds)` verifies that :
-: : each element in `argument` :
-: : doesn't exceed the corresponding :
-: : element in `upper_bounds`. See :
-: : more detail below. :
-| `SizeIs(m)` | `argument` is a container whose |
-: : size matches `m`. E.g. :
-: : `SizeIs(2)` or `SizeIs(Lt(2))`. :
-| `UnorderedElementsAre(e0, e1, ..., en)` | `argument` has `n + 1` elements, |
-: : and under *some* permutation of :
-: : the elements, each element :
-: : matches an `ei` (for a different :
-: : `i`), which can be a value or a :
-: : matcher. :
-| `UnorderedElementsAreArray({e0, e1, ..., | The same as |
-: en})`, : `UnorderedElementsAre()` except :
-: `UnorderedElementsAreArray(a_container)`, : that the expected element :
-: `UnorderedElementsAreArray(begin, end)`, : values/matchers come from an :
-: `UnorderedElementsAreArray(array)`, or : initializer list, STL-style :
-: `UnorderedElementsAreArray(array, count)` : container, iterator range, or :
-: : C-style array. :
-| `UnorderedPointwise(m, container)`, | Like `Pointwise(m, container)`, |
-: `UnorderedPointwise(m, {e0, e1, ..., : but ignores the order of :
-: en})` : elements. :
-| `WhenSorted(m)` | When `argument` is sorted using |
-: : the `<` operator, it matches :
-: : container matcher `m`. E.g. :
-: : `WhenSorted(ElementsAre(1, 2, :
-: : 3))` verifies that `argument` :
-: : contains elements 1, 2, and 3, :
-: : ignoring order. :
-| `WhenSortedBy(comparator, m)` | The same as `WhenSorted(m)`, |
-: : except that the given comparator :
-: : instead of `<` is used to sort :
-: : `argument`. E.g. :
-: : `WhenSortedBy(std\:\:greater(), :
-: : ElementsAre(3, 2, 1))`. :
+| `BeginEndDistanceIs(m)` | `argument` is a container whose `begin()` and `end()` iterators are separated by a number of increments matching `m`. E.g. `BeginEndDistanceIs(2)` or `BeginEndDistanceIs(Lt(2))`. For containers that define a `size()` method, `SizeIs(m)` may be more efficient. |
+| `ContainerEq(container)` | The same as `Eq(container)` except that the failure message also includes which elements are in one container but not the other. |
+| `Contains(e)` | `argument` contains an element that matches `e`, which can be either a value or a matcher. |
+| `Each(e)` | `argument` is a container where *every* element matches `e`, which can be either a value or a matcher. |
+| `ElementsAre(e0, e1, ..., en)` | `argument` has `n + 1` elements, where the *i*-th element matches `ei`, which can be a value or a matcher. |
+| `ElementsAreArray({e0, e1, ..., en})`, `ElementsAreArray(a_container)`, `ElementsAreArray(begin, end)`, `ElementsAreArray(array)`, or `ElementsAreArray(array, count)` | The same as `ElementsAre()` except that the expected element values/matchers come from an initializer list, STL-style container, iterator range, or C-style array. |
+| `IsEmpty()` | `argument` is an empty container (`container.empty()`). |
+| `IsFalse()` | `argument` evaluates to `false` in a Boolean context. |
+| `IsSubsetOf({e0, e1, ..., en})`, `IsSubsetOf(a_container)`, `IsSubsetOf(begin, end)`, `IsSubsetOf(array)`, or `IsSubsetOf(array, count)` | `argument` matches `UnorderedElementsAre(x0, x1, ..., xk)` for some subset `{x0, x1, ..., xk}` of the expected matchers. |
+| `IsSupersetOf({e0, e1, ..., en})`, `IsSupersetOf(a_container)`, `IsSupersetOf(begin, end)`, `IsSupersetOf(array)`, or `IsSupersetOf(array, count)` | Some subset of `argument` matches `UnorderedElementsAre(`expected matchers`)`. |
+| `IsTrue()` | `argument` evaluates to `true` in a Boolean context. |
+| `Pointwise(m, container)`, `Pointwise(m, {e0, e1, ..., en})` | `argument` contains the same number of elements as in `container`, and for all i, (the i-th element in `argument`, the i-th element in `container`) match `m`, which is a matcher on 2-tuples. E.g. `Pointwise(Le(), upper_bounds)` verifies that each element in `argument` doesn't exceed the corresponding element in `upper_bounds`. See more detail below. |
+| `SizeIs(m)` | `argument` is a container whose size matches `m`. E.g. `SizeIs(2)` or `SizeIs(Lt(2))`. |
+| `UnorderedElementsAre(e0, e1, ..., en)` | `argument` has `n + 1` elements, and under *some* permutation of the elements, each element matches an `ei` (for a different `i`), which can be a value or a matcher. |
+| `UnorderedElementsAreArray({e0, e1, ..., en})`, `UnorderedElementsAreArray(a_container)`, `UnorderedElementsAreArray(begin, end)`, `UnorderedElementsAreArray(array)`, or `UnorderedElementsAreArray(array, count)` | The same as `UnorderedElementsAre()` except that the expected element values/matchers come from an initializer list, STL-style container, iterator range, or C-style array. |
+| `UnorderedPointwise(m, container)`, `UnorderedPointwise(m, {e0, e1, ..., en})` | Like `Pointwise(m, container)`, but ignores the order of elements. |
+| `WhenSorted(m)` | When `argument` is sorted using the `<` operator, it matches container matcher `m`. E.g. `WhenSorted(ElementsAre(1, 2, 3))` verifies that `argument` contains elements 1, 2, and 3, ignoring order. |
+| `WhenSortedBy(comparator, m)` | The same as `WhenSorted(m)`, except that the given comparator instead of `<` is used to sort `argument`. E.g. `WhenSortedBy(std::greater(), ElementsAre(3, 2, 1))`. |
+<!-- mdformat on -->
**Notes:**
@@ -461,41 +370,31 @@ messages, you can use:
#### Member Matchers
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :------------------------------ | :----------------------------------------- |
-| `Field(&class::field, m)` | `argument.field` (or `argument->field` |
-: : when `argument` is a plain pointer) :
-: : matches matcher `m`, where `argument` is :
-: : an object of type _class_. :
-| `Key(e)` | `argument.first` matches `e`, which can be |
-: : either a value or a matcher. E.g. :
-: : `Contains(Key(Le(5)))` can verify that a :
-: : `map` contains a key `<= 5`. :
-| `Pair(m1, m2)` | `argument` is an `std::pair` whose `first` |
-: : field matches `m1` and `second` field :
-: : matches `m2`. :
-| `Property(&class::property, m)` | `argument.property()` (or |
-: : `argument->property()` when `argument` is :
-: : a plain pointer) matches matcher `m`, :
-: : where `argument` is an object of type :
-: : _class_. :
+| `Field(&class::field, m)` | `argument.field` (or `argument->field` when `argument` is a plain pointer) matches matcher `m`, where `argument` is an object of type _class_. |
+| `Key(e)` | `argument.first` matches `e`, which can be either a value or a matcher. E.g. `Contains(Key(Le(5)))` can verify that a `map` contains a key `<= 5`. |
+| `Pair(m1, m2)` | `argument` is an `std::pair` whose `first` field matches `m1` and `second` field matches `m2`. |
+| `Property(&class::property, m)` | `argument.property()` (or `argument->property()` when `argument` is a plain pointer) matches matcher `m`, where `argument` is an object of type _class_. |
+<!-- mdformat on -->
#### Matching the Result of a Function, Functor, or Callback
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :--------------- | :------------------------------------------------ |
-| `ResultOf(f, m)` | `f(argument)` matches matcher `m`, where `f` is a |
-: : function or functor. :
+| `ResultOf(f, m)` | `f(argument)` matches matcher `m`, where `f` is a function or functor. |
+<!-- mdformat on -->
#### Pointer Matchers
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :------------------------ | :---------------------------------------------- |
-| `Pointee(m)` | `argument` (either a smart pointer or a raw |
-: : pointer) points to a value that matches matcher :
-: : `m`. :
-| `WhenDynamicCastTo<T>(m)` | when `argument` is passed through |
-: : `dynamic_cast<T>()`, it matches matcher `m`. :
+| `Pointee(m)` | `argument` (either a smart pointer or a raw pointer) points to a value that matches matcher `m`. |
+| `WhenDynamicCastTo<T>(m)` | when `argument` is passed through `dynamic_cast<T>()`, it matches matcher `m`. |
+<!-- mdformat on -->
<!-- GOOGLETEST_CM0026 DO NOT DELETE -->
@@ -519,82 +418,61 @@ Matcher | Description
You can use the following selectors to pick a subset of the arguments (or
reorder them) to participate in the matching:
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :------------------------- | :---------------------------------------------- |
-| `AllArgs(m)` | Equivalent to `m`. Useful as syntactic sugar in |
-: : `.With(AllArgs(m))`. :
-| `Args<N1, N2, ..., Nk>(m)` | The tuple of the `k` selected (using 0-based |
-: : indices) arguments matches `m`, e.g. `Args<1, :
-: : 2>(Eq())`. :
+| `AllArgs(m)` | Equivalent to `m`. Useful as syntactic sugar in `.With(AllArgs(m))`. |
+| `Args<N1, N2, ..., Nk>(m)` | The tuple of the `k` selected (using 0-based indices) arguments matches `m`, e.g. `Args<1, 2>(Eq())`. |
+<!-- mdformat on -->
#### Composite Matchers
You can make a matcher from one or more other matchers:
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :------------------------------- | :-------------------------------------- |
-| `AllOf(m1, m2, ..., mn)` | `argument` matches all of the matchers |
-: : `m1` to `mn`. :
-| `AllOfArray({m0, m1, ..., mn})`, | The same as `AllOf()` except that the |
-: `AllOfArray(a_container)`, : matchers come from an initializer list, :
-: `AllOfArray(begin, end)`, : STL-style container, iterator range, or :
-: `AllOfArray(array)`, or : C-style array. :
-: `AllOfArray(array, count)` : :
-| `AnyOf(m1, m2, ..., mn)` | `argument` matches at least one of the |
-: : matchers `m1` to `mn`. :
-| `AnyOfArray({m0, m1, ..., mn})`, | The same as `AnyOf()` except that the |
-: `AnyOfArray(a_container)`, : matchers come from an initializer list, :
-: `AnyOfArray(begin, end)`, : STL-style container, iterator range, or :
-: `AnyOfArray(array)`, or : C-style array. :
-: `AnyOfArray(array, count)` : :
-| `Not(m)` | `argument` doesn't match matcher `m`. |
+| `AllOf(m1, m2, ..., mn)` | `argument` matches all of the matchers `m1` to `mn`. |
+| `AllOfArray({m0, m1, ..., mn})`, `AllOfArray(a_container)`, `AllOfArray(begin, end)`, `AllOfArray(array)`, or `AllOfArray(array, count)` | The same as `AllOf()` except that the matchers come from an initializer list, STL-style container, iterator range, or C-style array. |
+| `AnyOf(m1, m2, ..., mn)` | `argument` matches at least one of the matchers `m1` to `mn`. |
+| `AnyOfArray({m0, m1, ..., mn})`, `AnyOfArray(a_container)`, `AnyOfArray(begin, end)`, `AnyOfArray(array)`, or `AnyOfArray(array, count)` | The same as `AnyOf()` except that the matchers come from an initializer list, STL-style container, iterator range, or C-style array. |
+| `Not(m)` | `argument` doesn't match matcher `m`. |
+<!-- mdformat on -->
<!-- GOOGLETEST_CM0028 DO NOT DELETE -->
#### Adapters for Matchers
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :---------------------- | :------------------------------------ |
-| `MatcherCast<T>(m)` | casts matcher `m` to type |
-: : `Matcher<T>`. :
-| `SafeMatcherCast<T>(m)` | [safely |
-: : casts](cook_book.md#casting-matchers) :
-: : matcher `m` to type `Matcher<T>`. :
-| `Truly(predicate)` | `predicate(argument)` returns |
-: : something considered by C++ to be :
-: : true, where `predicate` is a function :
-: : or functor. :
+| `MatcherCast<T>(m)` | casts matcher `m` to type `Matcher<T>`. |
+| `SafeMatcherCast<T>(m)` | [safely casts](cook_book.md#casting-matchers) matcher `m` to type `Matcher<T>`. |
+| `Truly(predicate)` | `predicate(argument)` returns something considered by C++ to be true, where `predicate` is a function or functor. |
+<!-- mdformat on -->
`AddressSatisfies(callback)` and `Truly(callback)` take ownership of `callback`,
which must be a permanent callback.
#### Using Matchers as Predicates {#MatchersAsPredicatesCheat}
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :---------------------------- | :------------------------------------------ |
-| `Matches(m)(value)` | evaluates to `true` if `value` matches `m`. |
-: : You can use `Matches(m)` alone as a unary :
-: : functor. :
-| `ExplainMatchResult(m, value, | evaluates to `true` if `value` matches `m`, |
-: result_listener)` : explaining the result to `result_listener`. :
-| `Value(value, m)` | evaluates to `true` if `value` matches `m`. |
+| `Matches(m)(value)` | evaluates to `true` if `value` matches `m`. You can use `Matches(m)` alone as a unary functor. |
+| `ExplainMatchResult(m, value, result_listener)` | evaluates to `true` if `value` matches `m`, explaining the result to `result_listener`. |
+| `Value(value, m)` | evaluates to `true` if `value` matches `m`. |
+<!-- mdformat on -->
#### Defining Matchers
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :----------------------------------- | :------------------------------------ |
-| `MATCHER(IsEven, "") { return (arg % | Defines a matcher `IsEven()` to match |
-: 2) == 0; }` : an even number. :
-| `MATCHER_P(IsDivisibleBy, n, "") { | Defines a macher `IsDivisibleBy(n)` |
-: *result_listener << "where the : to match a number divisible by `n`. :
-: remainder is " << (arg % n); return : :
-: (arg % n) == 0; }` : :
-| `MATCHER_P2(IsBetween, a, b, | Defines a matcher `IsBetween(a, b)` |
-: std\:\:string(negation ? "isn't" \: : to match a value in the range [`a`, :
-: "is") + " between " + : `b`]. :
-: PrintToString(a) + " and " + : :
-: PrintToString(b)) { return a <= arg : :
-: && arg <= b; }` : :
+| `MATCHER(IsEven, "") { return (arg % 2) == 0; }` | Defines a matcher `IsEven()` to match an even number. |
+| `MATCHER_P(IsDivisibleBy, n, "") { *result_listener << "where the remainder is " << (arg % n); return (arg % n) == 0; }` | Defines a macher `IsDivisibleBy(n)` to match a number divisible by `n`. |
+| `MATCHER_P2(IsBetween, a, b, std::string(negation ? "isn't" : "is") + " between " + PrintToString(a) + " and " + PrintToString(b)) { return a <= arg && arg <= b; }` | Defines a matcher `IsBetween(a, b)` to match a value in the range [`a`, `b`]. |
+<!-- mdformat on -->
**Notes:**
@@ -611,78 +489,51 @@ which must be a permanent callback.
#### Returning a Value
+<!-- mdformat off(no multiline tables) -->
| | |
| :-------------------------- | :-------------------------------------------- |
| `Return()` | Return from a `void` mock function. |
-| `Return(value)` | Return `value`. If the type of `value` is |
-: : different to the mock function's return type, :
-: : `value` is converted to the latter type <i>at :
-: : the time the expectation is set</i>, not when :
-: : the action is executed. :
+| `Return(value)` | Return `value`. If the type of `value` is different to the mock function's return type, `value` is converted to the latter type <i>at the time the expectation is set</i>, not when the action is executed. |
| `ReturnArg<N>()` | Return the `N`-th (0-based) argument. |
-| `ReturnNew<T>(a1, ..., ak)` | Return `new T(a1, ..., ak)`; a different |
-: : object is created each time. :
+| `ReturnNew<T>(a1, ..., ak)` | Return `new T(a1, ..., ak)`; a different object is created each time. |
| `ReturnNull()` | Return a null pointer. |
| `ReturnPointee(ptr)` | Return the value pointed to by `ptr`. |
| `ReturnRef(variable)` | Return a reference to `variable`. |
-| `ReturnRefOfCopy(value)` | Return a reference to a copy of `value`; the |
-: : copy lives as long as the action. :
+| `ReturnRefOfCopy(value)` | Return a reference to a copy of `value`; the copy lives as long as the action. |
+<!-- mdformat on -->
#### Side Effects
+<!-- mdformat off(no multiline tables) -->
| | |
| :--------------------------------- | :-------------------------------------- |
-| `Assign(&variable, value)` | Assign `value` to variable. |
-| `DeleteArg<N>()` | Delete the `N`-th (0-based) argument, |
-: : which must be a pointer. :
-| `SaveArg<N>(pointer)` | Save the `N`-th (0-based) argument to |
-: : `*pointer`. :
-| `SaveArgPointee<N>(pointer)` | Save the value pointed to by the `N`-th |
-: : (0-based) argument to `*pointer`. :
-| `SetArgReferee<N>(value)` | Assign value to the variable referenced |
-: : by the `N`-th (0-based) argument. :
-| `SetArgPointee<N>(value)` | Assign `value` to the variable pointed |
-: : by the `N`-th (0-based) argument. :
-| `SetArgumentPointee<N>(value)` | Same as `SetArgPointee<N>(value)`. |
-: : Deprecated. Will be removed in v1.7.0. :
-| `SetArrayArgument<N>(first, last)` | Copies the elements in source range |
-: : [`first`, `last`) to the array pointed :
-: : to by the `N`-th (0-based) argument, :
-: : which can be either a pointer or an :
-: : iterator. The action does not take :
-: : ownership of the elements in the source :
-: : range. :
-| `SetErrnoAndReturn(error, value)` | Set `errno` to `error` and return |
-: : `value`. :
-| `Throw(exception)` | Throws the given exception, which can |
-: : be any copyable value. Available since :
-: : v1.1.0. :
-
-#### Using a Function, Functor, Lambda, or Callback as an Action
+| `Assign(&variable, value)` | Assign `value` to variable. |
+| `DeleteArg<N>()` | Delete the `N`-th (0-based) argument, which must be a pointer. |
+| `SaveArg<N>(pointer)` | Save the `N`-th (0-based) argument to `*pointer`. |
+| `SaveArgPointee<N>(pointer)` | Save the value pointed to by the `N`-th (0-based) argument to `*pointer`. |
+| `SetArgReferee<N>(value)` | Assign value to the variable referenced by the `N`-th (0-based) argument. |
+| `SetArgPointee<N>(value)` | Assign `value` to the variable pointed by the `N`-th (0-based) argument. |
+| `SetArgumentPointee<N>(value)` | Same as `SetArgPointee<N>(value)`. Deprecated. Will be removed in v1.7.0. |
+| `SetArrayArgument<N>(first, last)` | Copies the elements in source range [`first`, `last`) to the array pointed to by the `N`-th (0-based) argument, which can be either a pointer or an iterator. The action does not take ownership of the elements in the source range. |
+| `SetErrnoAndReturn(error, value)` | Set `errno` to `error` and return `value`. |
+| `Throw(exception)` | Throws the given exception, which can be any copyable value. Available since v1.1.0. |
+<!-- mdformat on -->
+
+#### Using a Function, Functor, or Lambda as an Action
In the following, by "callable" we mean a free function, `std::function`,
-functor, lambda, or `google3`-style permanent callback.
+functor, or lambda.
+<!-- mdformat off(no multiline tables) -->
| | |
| :---------------------------------- | :------------------------------------- |
-| `f` | Invoke f with the arguments passed to |
-: : the mock function, where f is a :
-: : callable (except of google3 callback). :
-| `Invoke(f)` | Invoke `f` with the arguments passed |
-: : to the mock function, where `f` can be :
-: : a global/static function or a functor. :
-| `Invoke(object_pointer, | Invoke the {method on the object with |
-: &class\:\:method)` : the arguments passed to the mock :
-: : function. :
-| `InvokeWithoutArgs(f)` | Invoke `f`, which can be a |
-: : global/static function or a functor. :
-: : `f` must take no arguments. :
-| `InvokeWithoutArgs(object_pointer, | Invoke the method on the object, which |
-: &class\:\:method)` : takes no arguments. :
-| `InvokeArgument<N>(arg1, arg2, ..., | Invoke the mock function's `N`-th |
-: argk)` : (0-based) argument, which must be a :
-: : function or a functor, with the `k` :
-: : arguments. :
+| `f` | Invoke f with the arguments passed to the mock function, where f is a callable. |
+| `Invoke(f)` | Invoke `f` with the arguments passed to the mock function, where `f` can be a global/static function or a functor. |
+| `Invoke(object_pointer, &class::method)` | Invoke the method on the object with the arguments passed to the mock function. |
+| `InvokeWithoutArgs(f)` | Invoke `f`, which can be a global/static function or a functor. `f` must take no arguments. |
+| `InvokeWithoutArgs(object_pointer, &class::method)` | Invoke the method on the object, which takes no arguments. |
+| `InvokeArgument<N>(arg1, arg2, ..., argk)` | Invoke the mock function's `N`-th (0-based) argument, which must be a function or a functor, with the `k` arguments. |
+<!-- mdformat on -->
The return value of the invoked function is used as the return value of the
action.
@@ -724,10 +575,11 @@ value, and `foo` by reference.
#### Default Action
+<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :------------ | :----------------------------------------------------- |
-| `DoDefault()` | Do the default action (specified by `ON_CALL()` or the |
-: : built-in one). :
+| `DoDefault()` | Do the default action (specified by `ON_CALL()` or the built-in one). |
+<!-- mdformat on -->
**Note:** due to technical reasons, `DoDefault()` cannot be used inside a
composite action - trying to do so will result in a run-time error.
@@ -736,19 +588,15 @@ composite action - trying to do so will result in a run-time error.
#### Composite Actions
+<!-- mdformat off(no multiline tables) -->
| | |
| :----------------------------- | :------------------------------------------ |
-| `DoAll(a1, a2, ..., an)` | Do all actions `a1` to `an` and return the |
-: : result of `an` in each invocation. The :
-: : first `n - 1` sub-actions must return void. :
-| `IgnoreResult(a)` | Perform action `a` and ignore its result. |
-: : `a` must not return void. :
-| `WithArg<N>(a)` | Pass the `N`-th (0-based) argument of the |
-: : mock function to action `a` and perform it. :
-| `WithArgs<N1, N2, ..., Nk>(a)` | Pass the selected (0-based) arguments of |
-: : the mock function to action `a` and perform :
-: : it. :
-| `WithoutArgs(a)` | Perform action `a` without any arguments. |
+| `DoAll(a1, a2, ..., an)` | Do all actions `a1` to `an` and return the result of `an` in each invocation. The first `n - 1` sub-actions must return void. |
+| `IgnoreResult(a)` | Perform action `a` and ignore its result. `a` must not return void. |
+| `WithArg<N>(a)` | Pass the `N`-th (0-based) argument of the mock function to action `a` and perform it. |
+| `WithArgs<N1, N2, ..., Nk>(a)` | Pass the selected (0-based) arguments of the mock function to action `a` and perform it. |
+| `WithoutArgs(a)` | Perform action `a` without any arguments. |
+<!-- mdformat on -->
#### Defining Actions
@@ -765,17 +613,13 @@ composite action - trying to do so will result in a run-time error.
</tr>
</table>
+<!-- mdformat off(no multiline tables) -->
| | |
| :--------------------------------- | :-------------------------------------- |
-| `ACTION(Sum) { return arg0 + arg1; | Defines an action `Sum()` to return the |
-: }` : sum of the mock function's argument #0 :
-: : and #1. :
-| `ACTION_P(Plus, n) { return arg0 + | Defines an action `Plus(n)` to return |
-: n; }` : the sum of the mock function's :
-: : argument #0 and `n`. :
-| `ACTION_Pk(Foo, p1, ..., pk) { | Defines a parameterized action `Foo(p1, |
-: statements; }` : ..., pk)` to execute the given :
-: : `statements`. :
+| `ACTION(Sum) { return arg0 + arg1; }` | Defines an action `Sum()` to return the sum of the mock function's argument #0 and #1. |
+| `ACTION_P(Plus, n) { return arg0 + n; }` | Defines an action `Plus(n)` to return the sum of the mock function's argument #0 and `n`. |
+| `ACTION_Pk(Foo, p1, ..., pk) { statements; }` | Defines a parameterized action `Foo(p1, ..., pk)` to execute the given `statements`. |
+<!-- mdformat on -->
The `ACTION*` macros cannot be used inside a function or class.
@@ -784,15 +628,15 @@ The `ACTION*` macros cannot be used inside a function or class.
These are used in `Times()` to specify how many times a mock function will be
called:
+<!-- mdformat off(no multiline tables) -->
| | |
| :---------------- | :----------------------------------------------------- |
| `AnyNumber()` | The function can be called any number of times. |
| `AtLeast(n)` | The call is expected at least `n` times. |
| `AtMost(n)` | The call is expected at most `n` times. |
-| `Between(m, n)` | The call is expected between `m` and `n` (inclusive) |
-: : times. :
-| `Exactly(n) or n` | The call is expected exactly `n` times. In particular, |
-: : the call should never happen when `n` is 0. :
+| `Between(m, n)` | The call is expected between `m` and `n` (inclusive) times. |
+| `Exactly(n) or n` | The call is expected exactly `n` times. In particular, the call should never happen when `n` is 0. |
+<!-- mdformat on -->
### Expectation Order
@@ -917,10 +761,9 @@ See this [recipe](cook_book.md#using-check-points) for one application of it.
### Flags
+<!-- mdformat off(no multiline tables) -->
| Flag | Description |
| :----------------------------- | :---------------------------------------- |
-| `--gmock_catch_leaked_mocks=0` | Don't report leaked mock objects as |
-: : failures. :
-| `--gmock_verbose=LEVEL` | Sets the default verbosity level (`info`, |
-: : `warning`, or `error`) of Google Mock :
-: : messages. :
+| `--gmock_catch_leaked_mocks=0` | Don't report leaked mock objects as failures. |
+| `--gmock_verbose=LEVEL` | Sets the default verbosity level (`info`, `warning`, or `error`) of Google Mock messages. |
+<!-- mdformat on -->
diff --git a/googlemock/docs/cook_book.md b/googlemock/docs/cook_book.md
index 676560bf..0352ef65 100644
--- a/googlemock/docs/cook_book.md
+++ b/googlemock/docs/cook_book.md
@@ -1195,11 +1195,12 @@ that satisfies matcher `m`.
For example:
+<!-- mdformat off(github rendering does not support multiline tables) -->
| Expression | Description |
| :--------------------------- | :--------------------------------------- |
| `Field(&Foo::number, Ge(3))` | Matches `x` where `x.number >= 3`. |
-| `Property(&Foo::name, | Matches `x` where `x.name()` starts with |
-: StartsWith("John "))` : `"John "`. :
+| `Property(&Foo::name, StartsWith("John "))` | Matches `x` where `x.name()` starts with `"John "`. |
+<!-- mdformat on -->
Note that in `Property(&Foo::baz, ...)`, method `baz()` must take no argument
and be declared as `const`.
diff --git a/googlemock/docs/for_dummies.md b/googlemock/docs/for_dummies.md
index 5551cd8b..db579df5 100644
--- a/googlemock/docs/for_dummies.md
+++ b/googlemock/docs/for_dummies.md
@@ -148,8 +148,8 @@ follow:
* Derive a class `MockTurtle` from `Turtle`.
* Take a *virtual* function of `Turtle` (while it's possible to
- [mock non-virtual methods using templates](#MockingNonVirtualMethods), it's
- much more involved).
+ [mock non-virtual methods using templates](cook_book.md#MockingNonVirtualMethods),
+ it's much more involved).
* In the `public:` section of the child class, write `MOCK_METHOD();`
* Now comes the fun part: you take the function signature, cut-and-paste it
into the macro, and add two commas - one between the return type and the
@@ -695,4 +695,4 @@ For example, in some tests we may not care about how many times `GetX()` and
In gMock, if you are not interested in a method, just don't say anything about
it. If a call to this method occurs, you'll see a warning in the test output,
but it won't be a failure. This is called "naggy" behavior; to change, see
-[The Nice, the Strict, and the Naggy](#NiceStrictNaggy).
+[The Nice, the Strict, and the Naggy](cook_book.md#NiceStrictNaggy).
diff --git a/googlemock/docs/gmock_faq.md b/googlemock/docs/gmock_faq.md
index 8bc45b18..214aabf1 100644
--- a/googlemock/docs/gmock_faq.md
+++ b/googlemock/docs/gmock_faq.md
@@ -81,7 +81,7 @@ void Bar(int* p); // Neither p nor *p is const.
void Bar(const int* p); // p is not const, but *p is.
```
-<<!-- GOOGLETEST_CM0030 DO NOT DELETE -->
+<!-- GOOGLETEST_CM0030 DO NOT DELETE -->
### I can't figure out why gMock thinks my expectations are not satisfied. What should I do?
@@ -91,9 +91,9 @@ trace, you'll gain insights on why the expectations you set are not met.
If you see the message "The mock function has no default action set, and its
return type has no default value set.", then try
-[adding a default action](http://go/gmockguide#DefaultValue). Due to a known
-issue, unexpected calls on mocks without default actions don't print out a
-detailed comparison between the actual arguments and the expected arguments.
+[adding a default action](for_dummies.md#DefaultValue). Due to a known issue,
+unexpected calls on mocks without default actions don't print out a detailed
+comparison between the actual arguments and the expected arguments.
### My program crashed and `ScopedMockLog` spit out tons of messages. Is it a gMock bug?
diff --git a/googlemock/include/gmock/gmock-generated-actions.h b/googlemock/include/gmock/gmock-generated-actions.h
index bf95300b..981af78f 100644
--- a/googlemock/include/gmock/gmock-generated-actions.h
+++ b/googlemock/include/gmock/gmock-generated-actions.h
@@ -259,11 +259,10 @@ class ActionHelper {
//
// CAVEAT:
//
-// ACTION*() can only be used in a namespace scope. The reason is
-// that C++ doesn't yet allow function-local types to be used to
-// instantiate templates. The up-coming C++0x standard will fix this.
-// Once that's done, we'll consider supporting using ACTION*() inside
-// a function.
+// ACTION*() can only be used in a namespace scope as templates cannot be
+// declared inside of a local class.
+// Users can, however, define any local functors (e.g. a lambda) that
+// can be used as actions.
//
// MORE INFORMATION:
//
diff --git a/googlemock/include/gmock/gmock-generated-actions.h.pump b/googlemock/include/gmock/gmock-generated-actions.h.pump
index 39e65c33..209603c5 100644
--- a/googlemock/include/gmock/gmock-generated-actions.h.pump
+++ b/googlemock/include/gmock/gmock-generated-actions.h.pump
@@ -182,11 +182,10 @@ $template
//
// CAVEAT:
//
-// ACTION*() can only be used in a namespace scope. The reason is
-// that C++ doesn't yet allow function-local types to be used to
-// instantiate templates. The up-coming C++0x standard will fix this.
-// Once that's done, we'll consider supporting using ACTION*() inside
-// a function.
+// ACTION*() can only be used in a namespace scope as templates cannot be
+// declared inside of a local class.
+// Users can, however, define any local functors (e.g. a lambda) that
+// can be used as actions.
//
// MORE INFORMATION:
//
diff --git a/googlemock/include/gmock/gmock-generated-matchers.h b/googlemock/include/gmock/gmock-generated-matchers.h
index b6f34bdd..690a57f1 100644
--- a/googlemock/include/gmock/gmock-generated-matchers.h
+++ b/googlemock/include/gmock/gmock-generated-matchers.h
@@ -250,11 +250,8 @@
// overloading matchers based on parameter types (as opposed to just
// based on the number of parameters).
//
-// MATCHER*() can only be used in a namespace scope. The reason is
-// that C++ doesn't yet allow function-local types to be used to
-// instantiate templates. The up-coming C++0x standard will fix this.
-// Once that's done, we'll consider supporting using MATCHER*() inside
-// a function.
+// MATCHER*() can only be used in a namespace scope as templates cannot be
+// declared inside of a local class.
//
// More Information
// ================
diff --git a/googlemock/include/gmock/gmock-generated-matchers.h.pump b/googlemock/include/gmock/gmock-generated-matchers.h.pump
index 333dc9df..ae90917c 100644
--- a/googlemock/include/gmock/gmock-generated-matchers.h.pump
+++ b/googlemock/include/gmock/gmock-generated-matchers.h.pump
@@ -252,11 +252,8 @@ $$ }} This line fixes auto-indentation of the following code in Emacs.
// overloading matchers based on parameter types (as opposed to just
// based on the number of parameters).
//
-// MATCHER*() can only be used in a namespace scope. The reason is
-// that C++ doesn't yet allow function-local types to be used to
-// instantiate templates. The up-coming C++0x standard will fix this.
-// Once that's done, we'll consider supporting using MATCHER*() inside
-// a function.
+// MATCHER*() can only be used in a namespace scope as templates cannot be
+// declared inside of a local class.
//
// More Information
// ================
diff --git a/googlemock/include/gmock/gmock.h b/googlemock/include/gmock/gmock.h
index 7096984b..99c3d787 100644
--- a/googlemock/include/gmock/gmock.h
+++ b/googlemock/include/gmock/gmock.h
@@ -39,14 +39,14 @@
// This file implements the following syntax:
//
-// ON_CALL(mock_object.Method(...))
+// ON_CALL(mock_object, Method(...))
// .With(...) ?
// .WillByDefault(...);
//
// where With() is optional and WillByDefault() must appear exactly
// once.
//
-// EXPECT_CALL(mock_object.Method(...))
+// EXPECT_CALL(mock_object, Method(...))
// .With(...) ?
// .Times(...) ?
// .InSequence(...) *
diff --git a/googletest/docs/advanced.md b/googletest/docs/advanced.md
index f8624c0e..e05d3179 100644
--- a/googletest/docs/advanced.md
+++ b/googletest/docs/advanced.md
@@ -101,14 +101,15 @@ If you already have a function or functor that returns `bool` (or a type that
can be implicitly converted to `bool`), you can use it in a *predicate
assertion* to get the function arguments printed for free:
-| Fatal assertion | Nonfatal assertion | Verifies |
-| -------------------- | -------------------- | --------------------------- |
-| `ASSERT_PRED1(pred1, | `EXPECT_PRED1(pred1, | `pred1(val1)` is true |
-: val1);` : val1);` : :
-| `ASSERT_PRED2(pred2, | `EXPECT_PRED2(pred2, | `pred2(val1, val2)` is true |
-: val1, val2);` : val1, val2);` : :
-| `...` | `...` | ... |
+<!-- mdformat off(github rendering does not support multiline tables) -->
+| Fatal assertion | Nonfatal assertion | Verifies |
+| --------------------------------- | --------------------------------- | --------------------------- |
+| `ASSERT_PRED1(pred1, val1)` | `EXPECT_PRED1(pred1, val1)` | `pred1(val1)` is true |
+| `ASSERT_PRED2(pred2, val1, val2)` | `EXPECT_PRED2(pred2, val1, val2)` | `pred1(val1, val2)` is true |
+| `...` | `...` | `...` |
+
+<!-- mdformat on-->
In the above, `predn` is an `n`-ary predicate function or functor, where `val1`,
`val2`, ..., and `valn` are its arguments. The assertion succeeds if the
predicate returns `true` when applied to the given arguments, and fails
@@ -330,23 +331,26 @@ want to learn more, see
#### Floating-Point Macros
-| Fatal assertion | Nonfatal assertion | Verifies |
-| ----------------------- | ----------------------- | ----------------------- |
-| `ASSERT_FLOAT_EQ(val1, | `EXPECT_FLOAT_EQ(val1, | the two `float` values |
-: val2);` : val2);` : are almost equal :
-| `ASSERT_DOUBLE_EQ(val1, | `EXPECT_DOUBLE_EQ(val1, | the two `double` values |
-: val2);` : val2);` : are almost equal :
+<!-- mdformat off(github rendering does not support multiline tables) -->
+
+| Fatal assertion | Nonfatal assertion | Verifies |
+| ------------------------------- | ------------------------------- | ---------------------------------------- |
+| `ASSERT_FLOAT_EQ(val1, val2);` | `EXPECT_FLOAT_EQ(val1, val2);` | the two `float` values are almost equal |
+| `ASSERT_DOUBLE_EQ(val1, val2);` | `EXPECT_DOUBLE_EQ(val1, val2);` | the two `double` values are almost equal |
+
+<!-- mdformat on-->
By "almost equal" we mean the values are within 4 ULP's from each other.
The following assertions allow you to choose the acceptable error bound:
-| Fatal assertion | Nonfatal assertion | Verifies |
-| ------------------ | ------------------------ | ------------------------- |
-| `ASSERT_NEAR(val1, | `EXPECT_NEAR(val1, val2, | the difference between |
-: val2, abs_error);` : abs_error);` : `val1` and `val2` doesn't :
-: : : exceed the given absolute :
-: : : error :
+<!-- mdformat off(github rendering does not support multiline tables) -->
+
+| Fatal assertion | Nonfatal assertion | Verifies |
+| ------------------------------------- | ------------------------------------- | -------------------------------------------------------------------------------- |
+| `ASSERT_NEAR(val1, val2, abs_error);` | `EXPECT_NEAR(val1, val2, abs_error);` | the difference between `val1` and `val2` doesn't exceed the given absolute error |
+
+<!-- mdformat on-->
#### Floating-Point Predicate-Format Functions
@@ -369,10 +373,13 @@ Verifies that `val1` is less than, or almost equal to, `val2`. You can replace
arguments passed to mock objects. A gMock *matcher* is basically a predicate
that knows how to describe itself. It can be used in these assertion macros:
-| Fatal assertion | Nonfatal assertion | Verifies |
-| ------------------- | ------------------------------ | --------------------- |
-| `ASSERT_THAT(value, | `EXPECT_THAT(value, matcher);` | value matches matcher |
-: matcher);` : : :
+<!-- mdformat off(github rendering does not support multiline tables) -->
+
+| Fatal assertion | Nonfatal assertion | Verifies |
+| ------------------------------ | ------------------------------ | --------------------- |
+| `ASSERT_THAT(value, matcher);` | `EXPECT_THAT(value, matcher);` | value matches matcher |
+
+<!-- mdformat on-->
For example, `StartsWith(prefix)` is a matcher that matches a string starting
with `prefix`, and you can write:
@@ -399,7 +406,8 @@ and you're ready to go.
### More String Assertions
-(Please read the [previous](#AssertThat) section first if you haven't.)
+(Please read the [previous](#asserting-using-gmock-matchers) section first if
+you haven't.)
You can use the gMock
[string matchers](../../googlemock/docs/cheat_sheet.md#string-matchers) with
@@ -1341,19 +1349,17 @@ for generating test parameters. They return what we call (surprise!) *parameter
generators*. Here is a summary of them, which are all in the `testing`
namespace:
-| Parameter Generator | Behavior |
-| ---------------------------- | ------------------------------------------- |
-| `Range(begin, end [, step])` | Yields values `{begin, begin+step, |
-: : begin+step+step, ...}`. The values do not :
-: : include `end`. `step` defaults to 1. :
-| `Values(v1, v2, ..., vN)` | Yields values `{v1, v2, ..., vN}`. |
-| `ValuesIn(container)` and | Yields values from a C-style array, an |
-: `ValuesIn(begin,end)` : STL-style container, or an iterator range :
-: : `[begin, end)`. :
-| `Bool()` | Yields sequence `{false, true}`. |
-| `Combine(g1, g2, ..., gN)` | Yields all combinations (Cartesian product) |
-: : as std\:\:tuples of the values generated by :
-: : the `N` generators. :
+<!-- mdformat off(github rendering does not support multiline tables) -->
+
+| Parameter Generator | Behavior |
+| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
+| `Range(begin, end [, step])` | Yields values `{begin, begin+step, begin+step+step, ...}`. The values do not include `end`. `step` defaults to 1. |
+| `Values(v1, v2, ..., vN)` | Yields values `{v1, v2, ..., vN}`. |
+| `ValuesIn(container)` and `ValuesIn(begin,end)` | Yields values from a C-style array, an STL-style container, or an iterator range `[begin, end)` |
+| `Bool()` | Yields sequence `{false, true}`. |
+| `Combine(g1, g2, ..., gN)` | Yields all combinations (Cartesian product) as std\:\:tuples of the values generated by the `N` generators. |
+
+<!-- mdformat on-->
For more details, see the comments at the definitions of these functions.
@@ -1407,7 +1413,10 @@ Please note that `INSTANTIATE_TEST_SUITE_P` will instantiate *all* tests in the
given test suite, whether their definitions come before or *after* the
`INSTANTIATE_TEST_SUITE_P` statement.
-You can see sample7_unittest.cc and sample8_unittest.cc for more examples.
+You can see [sample7_unittest.cc] and [sample8_unittest.cc] for more examples.
+
+[sample7_unittest.cc]: ../samples/sample7_unittest.cc "Parameterized Test example"
+[sample8_unittest.cc]: ../samples/sample8_unittest.cc "Parameterized Test example with multiple parameters"
### Creating Value-Parameterized Abstract Tests
@@ -1446,7 +1455,7 @@ returns the value of `testing::PrintToString(GetParam())`. It does not work for
NOTE: test names must be non-empty, unique, and may only contain ASCII
alphanumeric characters. In particular, they
-[should not contain underscores](https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore)
+[should not contain underscores](faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore)
```c++
class MyTestSuite : public testing::TestWithParam<int> {};
@@ -1555,7 +1564,9 @@ TYPED_TEST(FooTest, DoesBlah) {
TYPED_TEST(FooTest, HasPropertyA) { ... }
```
-You can see sample6_unittest.cc
+You can see [sample6_unittest.cc] for a complete example.
+
+[sample6_unittest.cc]: ../samples/sample6_unittest.cc "Typed Test example"
## Type-Parameterized Tests
@@ -1630,7 +1641,7 @@ that type directly without `::testing::Types<...>`, like this:
INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, int);
```
-You can see `sample6_unittest.cc` for a complete example.
+You can see [sample6_unittest.cc] for a complete example.
## Testing Private Code
@@ -1998,7 +2009,9 @@ You can do so by adding one line:
```
Now, sit back and enjoy a completely different output from your tests. For more
-details, you can read this sample9_unittest.cc
+details, see [sample9_unittest.cc].
+
+[sample9_unittest.cc]: ../samples/sample9_unittest.cc "Event listener example"
You may append more than one listener to the list. When an `On*Start()` or
`OnTestPartResult()` event is fired, the listeners will receive it in the order
@@ -2023,7 +2036,9 @@ handle `OnTestPartResult()` *before* listeners that can generate failures. This
ensures that failures generated by the latter are attributed to the right test
by the former.
-We have a sample of failure-raising listener sample10_unittest.cc
+See [sample10_unittest.cc] for an example of a failure-raising listener.
+
+[sample10_unittest.cc]: ../samples/sample10_unittest.cc "Failure-raising listener example"
## Running Test Programs: Advanced Options
diff --git a/googletest/docs/faq.md b/googletest/docs/faq.md
index d6e7f54a..9949fec2 100644
--- a/googletest/docs/faq.md
+++ b/googletest/docs/faq.md
@@ -263,7 +263,7 @@ If necessary, you can continue to derive test fixtures from a derived fixture.
googletest has no limit on how deep the hierarchy can be.
For a complete example using derived test fixtures, see
-[googletest sample](https://github.com/google/googletest/blob/master/googletest/samples/sample5_unittest.cc)
+[sample5_unittest.cc](../samples/sample5_unittest.cc).
## My compiler complains "void value not ignored as it ought to be." What does this mean?
diff --git a/googletest/docs/primer.md b/googletest/docs/primer.md
index 27598209..30d86a55 100644
--- a/googletest/docs/primer.md
+++ b/googletest/docs/primer.md
@@ -51,26 +51,34 @@ of misunderstanding these.
Historically, googletest started to use the term _Test Case_ for grouping
related tests, whereas current publications including the International Software
Testing Qualifications Board ([ISTQB](http://www.istqb.org/)) and various
-textbooks on Software Quality use the term _[Test
-Suite](http://glossary.istqb.org/search/test%20suite)_ for this.
+textbooks on Software Quality use the term _[Test Suite][istqb test suite]_ for
+this.
The related term _Test_, as it is used in the googletest, is corresponding to
-the term _[Test Case](http://glossary.istqb.org/search/test%20case)_ of ISTQB
-and others.
+the term _[Test Case][istqb test case]_ of ISTQB and others.
The term _Test_ is commonly of broad enough sense, including ISTQB's definition
of _Test Case_, so it's not much of a problem here. But the term _Test Case_ as
was used in Google Test is of contradictory sense and thus confusing.
-googletest recently started replacing the term _Test Case_ by _Test Suite_ The
-preferred API is TestSuite*. The older TestCase* API is being slowly deprecated
-and refactored away
+googletest recently started replacing the term _Test Case_ with _Test Suite_.
+The preferred API is *TestSuite*. The older TestCase API is being slowly
+deprecated and refactored away.
So please be aware of the different definitions of the terms:
-Meaning | googletest Term | [ISTQB](http://www.istqb.org/) Term
-:----------------------------------------------------------------------------------- | :---------------------- | :----------------------------------
-Exercise a particular program path with specific input values and verify the results | [TEST()](#simple-tests) | [Test Case](http://glossary.istqb.org/search/test%20case)
+| Meaning | googletest Term | [ISTQB](http://www.istqb.org/) |
+: : : Term :
+| :---------------- | :---------------------- | :----------------------------- |
+| Exercise a | [TEST()](#simple-tests) | [Test Case][istqb test case] |
+: particular : : :
+: program path with : : :
+: specific input : : :
+: values and verify : : :
+: the results : : :
+
+[istqb test case]: http://glossary.istqb.org/en/search/test%20case
+[istqb test suite]: http://glossary.istqb.org/en/search/test%20suite
## Basic Concepts
@@ -213,18 +221,16 @@ as `ASSERT_EQ(expected, actual)`, so lots of existing code uses this order. Now
The assertions in this group compare two **C strings**. If you want to compare
two `string` objects, use `EXPECT_EQ`, `EXPECT_NE`, and etc instead.
-| Fatal assertion | Nonfatal assertion | Verifies |
-| ----------------------- | ----------------------- | ---------------------- |
-| `ASSERT_STREQ(str1, | `EXPECT_STREQ(str1, | the two C strings have |
-: str2);` : str2);` : the same content :
-| `ASSERT_STRNE(str1, | `EXPECT_STRNE(str1, | the two C strings have |
-: str2);` : str2);` : different contents :
-| `ASSERT_STRCASEEQ(str1, | `EXPECT_STRCASEEQ(str1, | the two C strings have |
-: str2);` : str2);` : the same content, :
-: : : ignoring case :
-| `ASSERT_STRCASENE(str1, | `EXPECT_STRCASENE(str1, | the two C strings have |
-: str2);` : str2);` : different contents, :
-: : : ignoring case :
+<!-- mdformat off(github rendering does not support multiline tables) -->
+
+| Fatal assertion | Nonfatal assertion | Verifies |
+| -------------------------- | ------------------------------ | -------------------------------------------------------- |
+| `ASSERT_STREQ(str1,str2);` | `EXPECT_STREQ(str1,str2);` | the two C strings have the same content |
+| `ASSERT_STRNE(str1,str2);` | `EXPECT_STRNE(str1,str2);` | the two C strings have different contents |
+| `ASSERT_STRCASEEQ(str1,str2);` | `EXPECT_STRCASEEQ(str1,str2);` | the two C strings have the same content, ignoring case |
+| `ASSERT_STRCASENE(str1,str2);` | `EXPECT_STRCASENE(str1,str2);` | the two C strings have different contents, ignoring case |
+
+<!-- mdformat on-->
Note that "CASE" in an assertion name means that case is ignored. A `NULL`
pointer and an empty string are considered *different*.
@@ -235,9 +241,8 @@ of two wide strings fails, their values will be printed as UTF-8 narrow strings.
**Availability**: Linux, Windows, Mac.
**See also**: For more string comparison tricks (substring, prefix, suffix, and
-regular expression matching, for example), see
-[this](https://github.com/google/googletest/blob/master/googletest/docs/advanced.md)
-in the Advanced googletest Guide.
+regular expression matching, for example), see [this](advanced.md) in the
+Advanced googletest Guide.
## Simple Tests
diff --git a/googletest/include/gtest/gtest-typed-test.h b/googletest/include/gtest/gtest-typed-test.h
index b3319f68..25c26134 100644
--- a/googletest/include/gtest/gtest-typed-test.h
+++ b/googletest/include/gtest/gtest-typed-test.h
@@ -65,9 +65,9 @@ TYPED_TEST_SUITE(FooTest, MyTypes);
// Then, use TYPED_TEST() instead of TEST_F() to define as many typed
// tests for this test suite as you want.
TYPED_TEST(FooTest, DoesBlah) {
- // Inside a test, refer to TypeParam to get the type parameter.
- // Since we are inside a derived class template, C++ requires use to
- // visit the members of FooTest via 'this'.
+ // Inside a test, refer to the special name TypeParam to get the type
+ // parameter. Since we are inside a derived class template, C++ requires
+ // us to visit the members of FooTest via 'this'.
TypeParam n = this->value_;
// To visit static members of the fixture, add the TestFixture::
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index d12563cc..db81359d 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -412,6 +412,8 @@ class GTEST_API_ Test {
// test in test case Foo. Hence a sub-class can define its own
// SetUpTestSuite() method to shadow the one defined in the super
// class.
+ // Failures that happen during SetUpTestSuite are logged but otherwise
+ // ignored.
static void SetUpTestSuite() {}
// Tears down the stuff shared by all tests in this test suite.
@@ -420,6 +422,8 @@ class GTEST_API_ Test {
// test in test case Foo. Hence a sub-class can define its own
// TearDownTestSuite() method to shadow the one defined in the super
// class.
+ // Failures that happen during TearDownTestSuite are logged but otherwise
+ // ignored.
static void TearDownTestSuite() {}
// Legacy API is deprecated but still available
@@ -1312,7 +1316,7 @@ class GTEST_API_ UnitTest {
int failed_test_case_count() const;
int total_test_case_count() const;
int test_case_to_run_count() const;
-#endif // EMOVE_LEGACY_TEST_CASEAPI
+#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// Gets the number of successful tests.
int successful_test_count() const;
diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index e900b3ff..97533993 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -565,7 +565,10 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
test_param_names.insert(param_name);
- test_name_stream << test_info->test_base_name << "/" << param_name;
+ if (!test_info->test_base_name.empty()) {
+ test_name_stream << test_info->test_base_name << "/";
+ }
+ test_name_stream << param_name;
MakeAndRegisterTestInfo(
test_suite_name.c_str(), test_name_stream.GetString().c_str(),
nullptr, // No type parameter.
diff --git a/googletest/samples/sample9_unittest.cc b/googletest/samples/sample9_unittest.cc
index c0d8ff22..e502d08d 100644
--- a/googletest/samples/sample9_unittest.cc
+++ b/googletest/samples/sample9_unittest.cc
@@ -135,10 +135,10 @@ int main(int argc, char **argv) {
// This is an example of using the UnitTest reflection API to inspect test
// results. Here we discount failures from the tests we expected to fail.
int unexpectedly_failed_tests = 0;
- for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
- const TestCase& test_case = *unit_test.GetTestCase(i);
- for (int j = 0; j < test_case.total_test_count(); ++j) {
- const TestInfo& test_info = *test_case.GetTestInfo(j);
+ for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
+ const testing::TestSuite& test_suite = *unit_test.GetTestSuite(i);
+ for (int j = 0; j < test_suite.total_test_count(); ++j) {
+ const TestInfo& test_info = *test_suite.GetTestInfo(j);
// Counts failed tests that were not meant to fail (those without
// 'Fails' in the name).
if (test_info.result()->Failed() &&
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 78b30c60..a74041e7 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -1949,8 +1949,8 @@ bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
// Other unknown OSes may not define it either.
wint_t left, right;
do {
- left = towlower(*lhs++);
- right = towlower(*rhs++);
+ left = towlower(static_cast<wint_t>(*lhs++));
+ right = towlower(static_cast<wint_t>(*rhs++));
} while (left && left == right);
return left == right;
#endif // OS selector
@@ -3117,11 +3117,22 @@ class PrettyUnitTestResultPrinter : public TestEventListener {
void OnTestIterationStart(const UnitTest& unit_test, int iteration) override;
void OnEnvironmentsSetUpStart(const UnitTest& unit_test) override;
void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}
- void OnTestCaseStart(const TestSuite& test_suite) override;
+#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
+ void OnTestCaseStart(const TestCase& test_case) override;
+#else
+ void OnTestSuiteStart(const TestSuite& test_suite) override;
+#endif // OnTestCaseStart
+
void OnTestStart(const TestInfo& test_info) override;
+
void OnTestPartResult(const TestPartResult& result) override;
void OnTestEnd(const TestInfo& test_info) override;
- void OnTestCaseEnd(const TestSuite& test_suite) override;
+#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
+ void OnTestCaseEnd(const TestCase& test_case) override;
+#else
+ void OnTestSuiteEnd(const TestSuite& test_suite) override;
+#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
+
void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override;
void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}
void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
@@ -3175,7 +3186,22 @@ void PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart(
fflush(stdout);
}
-void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestSuite& test_suite) {
+#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
+void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {
+ const std::string counts =
+ FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
+ ColoredPrintf(COLOR_GREEN, "[----------] ");
+ printf("%s from %s", counts.c_str(), test_case.name());
+ if (test_case.type_param() == nullptr) {
+ printf("\n");
+ } else {
+ printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param());
+ }
+ fflush(stdout);
+}
+#else
+void PrettyUnitTestResultPrinter::OnTestSuiteStart(
+ const TestSuite& test_suite) {
const std::string counts =
FormatCountableNoun(test_suite.test_to_run_count(), "test", "tests");
ColoredPrintf(COLOR_GREEN, "[----------] ");
@@ -3187,6 +3213,7 @@ void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestSuite& test_suite) {
}
fflush(stdout);
}
+#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {
ColoredPrintf(COLOR_GREEN, "[ RUN ] ");
@@ -3233,7 +3260,19 @@ void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {
fflush(stdout);
}
-void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestSuite& test_suite) {
+#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
+void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) {
+ if (!GTEST_FLAG(print_time)) return;
+
+ const std::string counts =
+ FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
+ ColoredPrintf(COLOR_GREEN, "[----------] ");
+ printf("%s from %s (%s ms total)\n\n", counts.c_str(), test_case.name(),
+ internal::StreamableToString(test_case.elapsed_time()).c_str());
+ fflush(stdout);
+}
+#else
+void PrettyUnitTestResultPrinter::OnTestSuiteEnd(const TestSuite& test_suite) {
if (!GTEST_FLAG(print_time)) return;
const std::string counts =
@@ -3243,6 +3282,7 @@ void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestSuite& test_suite) {
internal::StreamableToString(test_suite.elapsed_time()).c_str());
fflush(stdout);
}
+#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart(
const UnitTest& /*unit_test*/) {
@@ -3367,17 +3407,17 @@ class TestEventRepeater : public TestEventListener {
void OnEnvironmentsSetUpStart(const UnitTest& unit_test) override;
void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) override;
// Legacy API is deprecated but still available
-#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI
+#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void OnTestCaseStart(const TestSuite& parameter) override;
-#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI
+#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void OnTestSuiteStart(const TestSuite& parameter) override;
void OnTestStart(const TestInfo& test_info) override;
void OnTestPartResult(const TestPartResult& result) override;
void OnTestEnd(const TestInfo& test_info) override;
// Legacy API is deprecated but still available
-#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI
- void OnTestCaseEnd(const TestSuite& parameter) override;
-#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI
+#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
+ void OnTestCaseEnd(const TestCase& parameter) override;
+#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void OnTestSuiteEnd(const TestSuite& parameter) override;
void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override;
void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) override;
diff --git a/googletest/test/googletest-listener-test.cc b/googletest/test/googletest-listener-test.cc
index f50faaf1..10457afe 100644
--- a/googletest/test/googletest-listener-test.cc
+++ b/googletest/test/googletest-listener-test.cc
@@ -35,6 +35,7 @@
#include <vector>
#include "gtest/gtest.h"
+#include "gtest/internal/custom/gtest.h"
using ::testing::AddGlobalTestEnvironment;
using ::testing::Environment;
@@ -76,10 +77,11 @@ class EventRecordingListener : public TestEventListener {
void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {
g_events->push_back(GetFullMethodName("OnEnvironmentsSetUpEnd"));
}
-
+#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void OnTestCaseStart(const TestCase& /*test_case*/) override {
g_events->push_back(GetFullMethodName("OnTestCaseStart"));
}
+#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void OnTestStart(const TestInfo& /*test_info*/) override {
g_events->push_back(GetFullMethodName("OnTestStart"));
@@ -93,9 +95,11 @@ class EventRecordingListener : public TestEventListener {
g_events->push_back(GetFullMethodName("OnTestEnd"));
}
+#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void OnTestCaseEnd(const TestCase& /*test_case*/) override {
g_events->push_back(GetFullMethodName("OnTestCaseEnd"));
}
+#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {
g_events->push_back(GetFullMethodName("OnEnvironmentsTearDownStart"));
@@ -283,6 +287,9 @@ int main(int argc, char **argv) {
::testing::GTEST_FLAG(repeat) = 2;
int ret_val = RUN_ALL_TESTS();
+#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
+
+ // The deprecated OnTestSuiteStart/OnTestCaseStart events are included
const char* const expected_events[] = {"1st.OnTestProgramStart",
"2nd.OnTestProgramStart",
"3rd.OnTestProgramStart",
@@ -393,6 +400,110 @@ int main(int argc, char **argv) {
"3rd.OnTestProgramEnd",
"2nd.OnTestProgramEnd",
"1st.OnTestProgramEnd"};
+#else
+ const char* const expected_events[] = {"1st.OnTestProgramStart",
+ "2nd.OnTestProgramStart",
+ "3rd.OnTestProgramStart",
+ "1st.OnTestIterationStart(0)",
+ "2nd.OnTestIterationStart(0)",
+ "3rd.OnTestIterationStart(0)",
+ "1st.OnEnvironmentsSetUpStart",
+ "2nd.OnEnvironmentsSetUpStart",
+ "3rd.OnEnvironmentsSetUpStart",
+ "Environment::SetUp",
+ "3rd.OnEnvironmentsSetUpEnd",
+ "2nd.OnEnvironmentsSetUpEnd",
+ "1st.OnEnvironmentsSetUpEnd",
+ "3rd.OnTestSuiteStart",
+ "ListenerTest::SetUpTestSuite",
+ "1st.OnTestStart",
+ "2nd.OnTestStart",
+ "3rd.OnTestStart",
+ "ListenerTest::SetUp",
+ "ListenerTest::* Test Body",
+ "1st.OnTestPartResult",
+ "2nd.OnTestPartResult",
+ "3rd.OnTestPartResult",
+ "ListenerTest::TearDown",
+ "3rd.OnTestEnd",
+ "2nd.OnTestEnd",
+ "1st.OnTestEnd",
+ "1st.OnTestStart",
+ "2nd.OnTestStart",
+ "3rd.OnTestStart",
+ "ListenerTest::SetUp",
+ "ListenerTest::* Test Body",
+ "1st.OnTestPartResult",
+ "2nd.OnTestPartResult",
+ "3rd.OnTestPartResult",
+ "ListenerTest::TearDown",
+ "3rd.OnTestEnd",
+ "2nd.OnTestEnd",
+ "1st.OnTestEnd",
+ "ListenerTest::TearDownTestSuite",
+ "3rd.OnTestSuiteEnd",
+ "1st.OnEnvironmentsTearDownStart",
+ "2nd.OnEnvironmentsTearDownStart",
+ "3rd.OnEnvironmentsTearDownStart",
+ "Environment::TearDown",
+ "3rd.OnEnvironmentsTearDownEnd",
+ "2nd.OnEnvironmentsTearDownEnd",
+ "1st.OnEnvironmentsTearDownEnd",
+ "3rd.OnTestIterationEnd(0)",
+ "2nd.OnTestIterationEnd(0)",
+ "1st.OnTestIterationEnd(0)",
+ "1st.OnTestIterationStart(1)",
+ "2nd.OnTestIterationStart(1)",
+ "3rd.OnTestIterationStart(1)",
+ "1st.OnEnvironmentsSetUpStart",
+ "2nd.OnEnvironmentsSetUpStart",
+ "3rd.OnEnvironmentsSetUpStart",
+ "Environment::SetUp",
+ "3rd.OnEnvironmentsSetUpEnd",
+ "2nd.OnEnvironmentsSetUpEnd",
+ "1st.OnEnvironmentsSetUpEnd",
+ "3rd.OnTestSuiteStart",
+ "ListenerTest::SetUpTestSuite",
+ "1st.OnTestStart",
+ "2nd.OnTestStart",
+ "3rd.OnTestStart",
+ "ListenerTest::SetUp",
+ "ListenerTest::* Test Body",
+ "1st.OnTestPartResult",
+ "2nd.OnTestPartResult",
+ "3rd.OnTestPartResult",
+ "ListenerTest::TearDown",
+ "3rd.OnTestEnd",
+ "2nd.OnTestEnd",
+ "1st.OnTestEnd",
+ "1st.OnTestStart",
+ "2nd.OnTestStart",
+ "3rd.OnTestStart",
+ "ListenerTest::SetUp",
+ "ListenerTest::* Test Body",
+ "1st.OnTestPartResult",
+ "2nd.OnTestPartResult",
+ "3rd.OnTestPartResult",
+ "ListenerTest::TearDown",
+ "3rd.OnTestEnd",
+ "2nd.OnTestEnd",
+ "1st.OnTestEnd",
+ "ListenerTest::TearDownTestSuite",
+ "3rd.OnTestSuiteEnd",
+ "1st.OnEnvironmentsTearDownStart",
+ "2nd.OnEnvironmentsTearDownStart",
+ "3rd.OnEnvironmentsTearDownStart",
+ "Environment::TearDown",
+ "3rd.OnEnvironmentsTearDownEnd",
+ "2nd.OnEnvironmentsTearDownEnd",
+ "1st.OnEnvironmentsTearDownEnd",
+ "3rd.OnTestIterationEnd(1)",
+ "2nd.OnTestIterationEnd(1)",
+ "1st.OnTestIterationEnd(1)",
+ "3rd.OnTestProgramEnd",
+ "2nd.OnTestProgramEnd",
+ "1st.OnTestProgramEnd"};
+#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
VerifyResults(events,
expected_events,
diff --git a/googletest/test/googletest-output-test-golden-lin.txt b/googletest/test/googletest-output-test-golden-lin.txt
index 270b15ae..038de921 100644
--- a/googletest/test/googletest-output-test-golden-lin.txt
+++ b/googletest/test/googletest-output-test-golden-lin.txt
@@ -12,7 +12,7 @@ Expected equality of these values:
3
Stack trace: (omitted)
-[==========] Running 84 tests from 39 test suites.
+[==========] Running 85 tests from 40 test suites.
[----------] Global test environment set-up.
FooEnvironment::SetUp() called.
BarEnvironment::SetUp() called.
@@ -966,6 +966,9 @@ Expected equality of these values:
Stack trace: (omitted)
[ FAILED ] PrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2
+[----------] 1 test from EmptyBasenameParamInst
+[ RUN ] EmptyBasenameParamInst.Passes/0
+[ OK ] EmptyBasenameParamInst.Passes/0
[----------] 2 tests from PrintingStrings/ParamTest
[ RUN ] PrintingStrings/ParamTest.Success/a
[ OK ] PrintingStrings/ParamTest.Success/a
@@ -992,8 +995,8 @@ Failed
Expected fatal failure.
Stack trace: (omitted)
-[==========] 84 tests from 39 test suites ran.
-[ PASSED ] 30 tests.
+[==========] 85 tests from 40 test suites ran.
+[ PASSED ] 31 tests.
[ FAILED ] 54 tests, listed below:
[ FAILED ] NonfatalFailureTest.EscapesStringOperands
[ FAILED ] NonfatalFailureTest.DiffForLongStrings
diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc
index f1222b6a..83be568c 100644
--- a/googletest/test/googletest-output-test_.cc
+++ b/googletest/test/googletest-output-test_.cc
@@ -96,6 +96,14 @@ INSTANTIATE_TEST_SUITE_P(PrintingFailingParams,
FailingParamTest,
testing::Values(2));
+// Tests that an empty value for the test suite basename yields just
+// the test name without any prior /
+class EmptyBasenameParamInst : public testing::TestWithParam<int> {};
+
+TEST_P(EmptyBasenameParamInst, Passes) { EXPECT_EQ(1, GetParam()); }
+
+INSTANTIATE_TEST_SUITE_P(, EmptyBasenameParamInst, testing::Values(1));
+
static const char kGoldenString[] = "\"Line\0 1\"\nLine 2";
TEST(NonfatalFailureTest, EscapesStringOperands) {
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 07ee171d..2b00b70a 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -2016,10 +2016,11 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestSuite(
const char* key) {
- const TestCase* test_case = UnitTest::GetInstance()->current_test_case();
- ASSERT_TRUE(test_case != nullptr);
+ const testing::TestSuite* test_suite =
+ UnitTest::GetInstance()->current_test_suite();
+ ASSERT_TRUE(test_suite != nullptr);
ExpectNonFatalFailureRecordingPropertyWithReservedKey(
- test_case->ad_hoc_test_result(), key);
+ test_suite->ad_hoc_test_result(), key);
}
void ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestSuite(
@@ -2049,8 +2050,10 @@ class UnitTestRecordPropertyTest :
"time");
Test::RecordProperty("test_case_key_1", "1");
+
const testing::TestSuite* test_suite =
- UnitTest::GetInstance()->current_test_case();
+ UnitTest::GetInstance()->current_test_suite();
+
ASSERT_TRUE(test_suite != nullptr);
ASSERT_EQ(1, test_suite->ad_hoc_test_result().test_property_count());