mirror of
https://github.com/google/googletest.git
synced 2024-12-25 09:10:50 +08:00
the public version already has the const qualifier
PiperOrigin-RevId: 706721910 Change-Id: I8a76a66d62028176a70678954f095ac70996cc9e
This commit is contained in:
parent
79219e26e0
commit
f3c355f9dd
@ -177,7 +177,7 @@ class StackInterface {
|
||||
template <typename Elem>
|
||||
class MockStack : public StackInterface<Elem> {
|
||||
...
|
||||
MOCK_METHOD(int, GetSize, (), (override));
|
||||
MOCK_METHOD(int, GetSize, (), (const, override));
|
||||
MOCK_METHOD(void, Push, (const Elem& x), (override));
|
||||
};
|
||||
```
|
||||
@ -3419,14 +3419,14 @@ itself, as gMock already prints it for you.
|
||||
|
||||
#### Argument Types
|
||||
|
||||
The type of the value being matched (`arg_type`) is determined by the
|
||||
context in which you use the matcher and is supplied to you by the compiler, so
|
||||
you don't need to worry about declaring it (nor can you). This allows the
|
||||
matcher to be polymorphic. For example, `IsDivisibleBy7()` can be used to match
|
||||
any type where the value of `(arg % 7) == 0` can be implicitly converted to a
|
||||
`bool`. In the `Bar(IsDivisibleBy7())` example above, if method `Bar()` takes an
|
||||
`int`, `arg_type` will be `int`; if it takes an `unsigned long`, `arg_type` will
|
||||
be `unsigned long`; and so on.
|
||||
The type of the value being matched (`arg_type`) is determined by the context in
|
||||
which you use the matcher and is supplied to you by the compiler, so you don't
|
||||
need to worry about declaring it (nor can you). This allows the matcher to be
|
||||
polymorphic. For example, `IsDivisibleBy7()` can be used to match any type where
|
||||
the value of `(arg % 7) == 0` can be implicitly converted to a `bool`. In the
|
||||
`Bar(IsDivisibleBy7())` example above, if method `Bar()` takes an `int`,
|
||||
`arg_type` will be `int`; if it takes an `unsigned long`, `arg_type` will be
|
||||
`unsigned long`; and so on.
|
||||
|
||||
### Writing New Parameterized Matchers Quickly
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user