Skip to content

Commit 7aca844

Browse files
Abseil Teamrogeeff
Abseil Team
authored andcommitted
Googletest export
Simplify FooConcrete static calls in googlemock cookbook. PiperOrigin-RevId: 332437041
1 parent bb27253 commit 7aca844

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

googlemock/docs/cook_book.md

+3-19
Original file line numberDiff line numberDiff line change
@@ -781,28 +781,12 @@ perhaps your test doesn't need to mock `Concrete()` at all (but it would be
781781
oh-so painful to have to define a new mock class whenever you don't need to mock
782782
one of its methods).
783783

784-
The trick is to leave a back door in your mock class for accessing the real
785-
methods in the base class:
786-
787-
```cpp
788-
class MockFoo : public Foo {
789-
public:
790-
// Mocking a pure method.
791-
MOCK_METHOD(void, Pure, (int n), (override));
792-
// Mocking a concrete method. Foo::Concrete() is shadowed.
793-
MOCK_METHOD(int, Concrete, (const char* str), (override));
794-
795-
// Use this to call Concrete() defined in Foo.
796-
int FooConcrete(const char* str) { return Foo::Concrete(str); }
797-
};
798-
```
799-
800-
Now, you can call `Foo::Concrete()` inside an action by:
784+
You can call `Foo::Concrete()` inside an action by:
801785

802786
```cpp
803787
...
804788
EXPECT_CALL(foo, Concrete).WillOnce([&foo](const char* str) {
805-
return foo.FooConcrete(str);
789+
return foo.Foo::Concrete(str);
806790
});
807791
```
808792

@@ -811,7 +795,7 @@ or tell the mock object that you don't want to mock `Concrete()`:
811795
```cpp
812796
...
813797
ON_CALL(foo, Concrete).WillByDefault([&foo](const char* str) {
814-
return foo.FooConcrete(str);
798+
return foo.Foo::Concrete(str);
815799
});
816800
```
817801

0 commit comments

Comments
 (0)