`_` | `argument` can be any value of the correct type.
`_` | `argument` can be any value of the correct type.
`A<type>()` or `An<type>()` | `argument` can be any value of type `type`.
`A<type>()` or `An<type>()` | `argument` can be any value of type `type`.
#### Generic Comparison
### Generic Comparison
<!-- mdformat off(no multiline tables) -->
<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| Matcher | Description |
...
@@ -289,7 +289,7 @@ Boolean. In other cases, you can use the basic
...
@@ -289,7 +289,7 @@ Boolean. In other cases, you can use the basic
[`EXPECT_TRUE` and `EXPECT_FALSE`](../../googletest/docs/primer#basic-assertions)
[`EXPECT_TRUE` and `EXPECT_FALSE`](../../googletest/docs/primer#basic-assertions)
assertions.
assertions.
#### Floating-Point Matchers {#FpMatchers}
### Floating-Point Matchers {#FpMatchers}
<!-- mdformat off(no multiline tables) -->
<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| Matcher | Description |
...
@@ -317,7 +317,7 @@ user wants.
...
@@ -317,7 +317,7 @@ user wants.
| `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. |
| `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 -->
<!-- mdformat on -->
#### String Matchers
### String Matchers
The `argument` can be either a C string or a C++ string object:
The `argument` can be either a C string or a C++ string object:
...
@@ -341,7 +341,7 @@ use the regular expression syntax defined
...
@@ -341,7 +341,7 @@ use the regular expression syntax defined
these matchers, except `ContainsRegex()` and `MatchesRegex()` work for wide
these matchers, except `ContainsRegex()` and `MatchesRegex()` work for wide
strings as well.
strings as well.
#### Container Matchers
### Container Matchers
Most STL-style containers support `==`, so you can use `Eq(expected_container)`
Most STL-style containers support `==`, so you can use `Eq(expected_container)`
or simply `expected_container` to match a container exactly. If you want to
or simply `expected_container` to match a container exactly. If you want to
| `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_. |
| `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 -->
<!-- mdformat on -->
#### Matching the Result of a Function, Functor, or Callback
### Matching the Result of a Function, Functor, or Callback
<!-- mdformat off(no multiline tables) -->
<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| Matcher | Description |
...
@@ -411,7 +411,7 @@ messages, you can use:
...
@@ -411,7 +411,7 @@ messages, you can use:
| `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 -->
<!-- mdformat on -->
#### Pointer Matchers
### Pointer Matchers
<!-- mdformat off(no multiline tables) -->
<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| Matcher | Description |
...
@@ -424,7 +424,7 @@ messages, you can use:
...
@@ -424,7 +424,7 @@ messages, you can use:
<!-- GOOGLETEST_CM0027 DO NOT DELETE -->
<!-- GOOGLETEST_CM0027 DO NOT DELETE -->
#### Multi-argument Matchers {#MultiArgMatchers}
### Multi-argument Matchers {#MultiArgMatchers}
Technically, all matchers match a *single* value. A "multi-argument" matcher is
Technically, all matchers match a *single* value. A "multi-argument" matcher is
just one that matches a *tuple*. The following matchers can be used to match a
just one that matches a *tuple*. The following matchers can be used to match a
...
@@ -449,7 +449,7 @@ reorder them) to participate in the matching:
...
@@ -449,7 +449,7 @@ reorder them) to participate in the matching:
| `Args<N1, N2, ..., Nk>(m)` | The tuple of the `k` selected (using 0-based indices) arguments matches `m`, e.g. `Args<1, 2>(Eq())`. |
| `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 -->
<!-- mdformat on -->
#### Composite Matchers
### Composite Matchers
You can make a matcher from one or more other matchers:
You can make a matcher from one or more other matchers:
...
@@ -465,7 +465,7 @@ You can make a matcher from one or more other matchers:
...
@@ -465,7 +465,7 @@ You can make a matcher from one or more other matchers:
<!-- GOOGLETEST_CM0028 DO NOT DELETE -->
<!-- GOOGLETEST_CM0028 DO NOT DELETE -->
#### Adapters for Matchers
### Adapters for Matchers
<!-- mdformat off(no multiline tables) -->
<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| Matcher | Description |
...
@@ -478,7 +478,7 @@ You can make a matcher from one or more other matchers:
...
@@ -478,7 +478,7 @@ You can make a matcher from one or more other matchers:
`AddressSatisfies(callback)` and `Truly(callback)` take ownership of `callback`,
`AddressSatisfies(callback)` and `Truly(callback)` take ownership of `callback`,
which must be a permanent callback.
which must be a permanent callback.
#### Using Matchers as Predicates {#MatchersAsPredicatesCheat}
### Using Matchers as Predicates {#MatchersAsPredicatesCheat}
<!-- mdformat off(no multiline tables) -->
<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| Matcher | Description |
...
@@ -488,7 +488,7 @@ which must be a permanent callback.
...
@@ -488,7 +488,7 @@ which must be a permanent callback.
| `Value(value, m)` | evaluates to `true` if `value` matches `m`. |
| `Value(value, m)` | evaluates to `true` if `value` matches `m`. |
<!-- mdformat on -->
<!-- mdformat on -->
#### Defining Matchers
### Defining Matchers
<!-- mdformat off(no multiline tables) -->
<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| Matcher | Description |
...
@@ -507,11 +507,11 @@ which must be a permanent callback.
...
@@ -507,11 +507,11 @@ which must be a permanent callback.
3. You can use `PrintToString(x)` to convert a value `x` of any type to a
3. You can use `PrintToString(x)` to convert a value `x` of any type to a
string.
string.
### Actions {#ActionList}
## Actions {#ActionList}
**Actions** specify what a mock function should do when invoked.
**Actions** specify what a mock function should do when invoked.
#### Returning a Value
### Returning a Value
<!-- mdformat off(no multiline tables) -->
<!-- mdformat off(no multiline tables) -->
| | |
| | |
...
@@ -527,7 +527,7 @@ which must be a permanent callback.
...
@@ -527,7 +527,7 @@ which must be a permanent callback.
| `ReturnRoundRobin({a1, ..., ak})` | Each call will return the next `ai` in the list, starting at the beginning when the end of the list is reached. |
| `ReturnRoundRobin({a1, ..., ak})` | Each call will return the next `ai` in the list, starting at the beginning when the end of the list is reached. |
<!-- mdformat on -->
<!-- mdformat on -->
#### Side Effects
### Side Effects
<!-- mdformat off(no multiline tables) -->
<!-- mdformat off(no multiline tables) -->
| | |
| | |
...
@@ -544,7 +544,7 @@ which must be a permanent callback.
...
@@ -544,7 +544,7 @@ which must be a permanent callback.
| `Throw(exception)` | Throws the given exception, which can be any copyable value. Available since v1.1.0. |
| `Throw(exception)` | Throws the given exception, which can be any copyable value. Available since v1.1.0. |
<!-- mdformat on -->
<!-- mdformat on -->
#### Using a Function, Functor, or Lambda as an Action
### Using a Function, Functor, or Lambda as an Action
In the following, by "callable" we mean a free function, `std::function`,
In the following, by "callable" we mean a free function, `std::function`,