Lines Matching refs:matcher
874 A frequently used matcher is `_`, which matches anything:
920 mistake if you use a matcher of the wrong type (for example, if you use `Eq(5)`
924 some slack. One example is that you have a matcher for `long` and the argument
928 giving it to the matcher.
931 casts a matcher `m` to type `Matcher<T>`. To ensure safety, gMock checks that
940 matcher may be interested in the address of the `U` value).
1001 different argument types, you may need to specify the exact type of a matcher,
1002 either by wrapping your matcher in `Matcher<type>()`, or using a matcher whose
1070 The expression inside `With()` must be a matcher of type `Matcher<std::tuple<A1,
1094 including the `Lt()` matcher above. See
1105 Have you noticed that a matcher is just a fancy predicate that also knows how to
1110 Luckily, you can use a matcher where a unary predicate functor is expected by
1151 predicate function or functor as a matcher - as long as the predicate accepts a
1177 define your own matcher function or callback and use it with `Truly()`, as the
1209 is a matcher that matches a `Foo` object whose `bar` member variable satisfies
1210 matcher `m`.
1216 is a matcher that matches a `Foo` object whose `baz()` method returns a value
1217 that satisfies matcher `m`.
1242 will always fail regardless of the inner matcher.
1270 matcher.
1313 For more advanced cases, you may need to define your own matcher class. A custom
1314 matcher allows you to test a specific invariant property of that object. Let's
1320 invariant.) Here's how we can write and use a matcher class to do so:
1368 You can use the `ElementsAre()` or `UnorderedElementsAre()` matcher in such
1381 The above matcher says that the container must have 4 elements, which must be 1,
1458 Under the hood, a gMock matcher object consists of a pointer to a ref-counted
1460 the pointer is copied. When the last matcher that references the implementation
1463 Therefore, if you have some complex matcher that you want to use again and
1464 again, there is no need to build it every time. Just assign it to a matcher
1474 ... use in_range as a matcher in multiple EXPECT_CALLs ...
1480 WARNING: gMock does not guarantee when or how many times a matcher will be
1483 the matcher's parameters and the value being matched.
1485 This requirement must be satisfied no matter how a matcher is defined (e.g., if
1486 it is one of the standard matchers, or a custom matcher). In particular, a
1487 matcher can never call a mock function, as that will affect the state of the
1646 Remember that `_` is the wildcard matcher that matches anything. With this, if
3289 WARNING: gMock does not guarantee when or how many times a matcher will be
3300 will define a matcher with the given name that executes the statements, which
3306 matcher does, and is used to generate the failure message when the match fails.
3308 evaluate to the description of the matcher when `negation` is `false`, or that
3309 of the matcher's negation when `negation` is `true`.
3312 case gMock will use the sequence of words in the matcher name as the
3351 automatically calculated from the matcher name `IsDivisibleBy7`.
3391 matcher definitions. In many cases, this allows you to write your matcher more
3417 the matcher is used inside `Not()`. There is no need to print the argument value
3423 context in which you use the matcher and is supplied to you by the compiler, so
3425 matcher to be polymorphic. For example, `IsDivisibleBy7()` can be used to match
3433 Sometimes you'll want to define a matcher that has parameters. For that you can
3463 Note that both the matcher description and its parameter are printed, making the
3466 In the matcher definition body, you can write `foo_type` to reference the type
3479 the matcher, where the parameters have been bound to actual values. Therefore
3481 lets you do that by referencing the matcher parameters in the description string
3504 sequence of words in the matcher name followed by the parameter values printed
3538 matcher is used.
3546 While you can instantiate a matcher template with reference types, passing the
3549 message generated by the matcher you will see the value of the referenced object
3560 matcher, you should also consider implementing the matcher interface directly
3561 instead (see the recipes that follow), especially if you need to use the matcher
3563 the types of the value being matched and the matcher parameters, which in
3570 A matcher of argument type `T` implements the matcher interface for `T` and does
3571 two things: it tests whether a value of type `T` matches the matcher, and can
3575 A matcher of `T` must declare a typedef like:
3585 bool matched = matcher.MatchAndExplain(value, maybe_os);
3590 matcher.DescribeTo(os);
3591 matcher.DescribeNegationTo(os);
3595 If you need a custom matcher but `Truly()` is not a good option (for example,
3597 may want your matcher to be polymorphic as `Eq(value)` is), you can define a
3598 matcher to do whatever you want in two steps: first implement the matcher
3599 interface, and then define a factory function to create a matcher instance. The
3600 second step is not strictly needed but it makes the syntax of using the matcher
3603 For example, you can define a matcher to test whether an `int` is divisible by 7
3634 You may improve the matcher message by streaming additional information to the
3674 // To implement a polymorphic matcher, we just need to make MatchAndExplain a
3686 // Describes the property of a value matching this matcher.
3689 // Describes the property of a value NOT matching this matcher.
3705 several supporting classes and virtual functions. To implement a matcher for
3729 // Returns true if and only if the matcher matches x; also explains the match
3733 // Describes this matcher to an ostream.
3736 // Describes the negation of this matcher to an ostream.
3741 Fortunately, most of the time you can define a polymorphic matcher easily with
3752 // To implement a polymorphic matcher, first define a COPYABLE class
3766 // Describes the property of a value matching this matcher.
3769 // Describes the property of a value NOT matching this matcher.
3773 // To construct a polymorphic matcher, pass an instance of the class
3785 **Note:** Your polymorphic matcher class does **not** need to inherit from
3789 Like in a monomorphic matcher, you may explain the match result by streaming