Skip to content

Commit 76cd89b

Browse files
Abseil Teamcopybara-github
authored andcommitted
Point from the "Defining Matchers" section in the reference doc to the cookbook, which is much more detailed.
PiperOrigin-RevId: 852639172 Change-Id: Ia39a01702c7c64404950a1be19b1ebdfdff8f010
1 parent 9156d4c commit 76cd89b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

docs/gmock_cook_book.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,7 +3566,7 @@ general leads to better compiler error messages that pay off in the long run.
35663566
They also allow overloading matchers based on parameter types (as opposed to
35673567
just based on the number of parameters).
35683568

3569-
### Writing New Monomorphic Matchers
3569+
### Writing New Monomorphic Matchers {#MonomorphicMatchers}
35703570

35713571
A matcher of type `testing::Matcher<T>` implements the matcher interface for `T`
35723572
and does two things: it tests whether a value of type `T` matches the matcher,
@@ -3666,11 +3666,11 @@ Expected: is divisible by 7
36663666
Tip: for convenience, `MatchAndExplain()` can take a `MatchResultListener*`
36673667
instead of `std::ostream*`.
36683668

3669-
### Writing New Polymorphic Matchers
3669+
### Writing New Polymorphic Matchers {#PolymorphicMatchers}
36703670

36713671
Unlike a monomorphic matcher, which can only be used to match a value of a
36723672
particular type, a *polymorphic* matcher is one that can be used to match values
3673-
of multiple types. For example, `Eq(5)` is a polymorhpic matcher as it can be
3673+
of multiple types. For example, `Eq(5)` is a polymorphic matcher as it can be
36743674
used to match an `int`, a `double`, a `float`, and so on. You should think of a
36753675
polymorphic matcher as a *matcher factory* as opposed to a
36763676
`testing::Matcher<SomeType>` - itself is not an actual matcher, but can be

docs/reference/matchers.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Matchers Reference
22

3+
<!-- disableFinding(LINK_RELATIVE_G3DOC) -->
4+
35
A **matcher** matches a *single* argument. You can use it inside `ON_CALL()` or
46
`EXPECT_CALL()`, or use it to validate a value directly using two macros:
57

@@ -297,6 +299,13 @@ which must be a permanent callback.
297299
298300
## Defining Matchers
299301
302+
{: .callout .note}
303+
Note: full details about defining new matchers are in the
304+
[cookbook](../gmock_cook_book.md#NewMatchers). In particular, if `MATCHER`
305+
macros are not sufficient, you can directly implement
306+
[monomorphic](../gmock_cook_book.md#MonomorphicMatchers) or
307+
[polymorphic](../gmock_cook_book.md#PolymorphicMatchers) matchers.
308+
300309
| Macro | Description |
301310
| :----------------------------------- | :------------------------------------ |
302311
| `MATCHER(IsEven, "") { return (arg % 2) == 0; }` | Defines a matcher `IsEven()` to match an even number. |

0 commit comments

Comments
 (0)