Point from the "Defining Matchers" section in the reference doc to the cookbook, which is much more detailed. PiperOrigin-RevId: 852639172 Change-Id: Ia39a01702c7c64404950a1be19b1ebdfdff8f010
diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 22ad021..b53cbd5 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md
@@ -3566,7 +3566,7 @@ They also allow overloading matchers based on parameter types (as opposed to just based on the number of parameters). -### Writing New Monomorphic Matchers +### Writing New Monomorphic Matchers {#MonomorphicMatchers} A matcher of type `testing::Matcher<T>` implements the matcher interface for `T` and does two things: it tests whether a value of type `T` matches the matcher, @@ -3666,11 +3666,11 @@ Tip: for convenience, `MatchAndExplain()` can take a `MatchResultListener*` instead of `std::ostream*`. -### Writing New Polymorphic Matchers +### Writing New Polymorphic Matchers {#PolymorphicMatchers} Unlike a monomorphic matcher, which can only be used to match a value of a particular type, a *polymorphic* matcher is one that can be used to match values -of multiple types. For example, `Eq(5)` is a polymorhpic matcher as it can be +of multiple types. For example, `Eq(5)` is a polymorphic matcher as it can be used to match an `int`, a `double`, a `float`, and so on. You should think of a polymorphic matcher as a *matcher factory* as opposed to a `testing::Matcher<SomeType>` - itself is not an actual matcher, but can be
diff --git a/docs/reference/matchers.md b/docs/reference/matchers.md index 4c234e1..665feee 100644 --- a/docs/reference/matchers.md +++ b/docs/reference/matchers.md
@@ -1,5 +1,7 @@ # Matchers Reference +<!-- disableFinding(LINK_RELATIVE_G3DOC) --> + A **matcher** matches a *single* argument. You can use it inside `ON_CALL()` or `EXPECT_CALL()`, or use it to validate a value directly using two macros: @@ -297,6 +299,13 @@ ## Defining Matchers +{: .callout .note} +Note: full details about defining new matchers are in the +[cookbook](../gmock_cook_book.md#NewMatchers). In particular, if `MATCHER` +macros are not sufficient, you can directly implement +[monomorphic](../gmock_cook_book.md#MonomorphicMatchers) or +[polymorphic](../gmock_cook_book.md#PolymorphicMatchers) matchers. + | Macro | Description | | :----------------------------------- | :------------------------------------ | | `MATCHER(IsEven, "") { return (arg % 2) == 0; }` | Defines a matcher `IsEven()` to match an even number. |