Skip to content

Commit ec25eea

Browse files
Abseil Teamcopybara-github
Abseil Team
authored andcommitted
Mention using MockFunction as a way to mock free functions.
PiperOrigin-RevId: 502901538 Change-Id: I0cf351b9ad1411ae9c45e09550c24e006a24e179
1 parent bdb3b0a commit ec25eea

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/gmock_cook_book.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ If you are concerned about the performance overhead incurred by virtual
285285
functions, and profiling confirms your concern, you can combine this with the
286286
recipe for [mocking non-virtual methods](#MockingNonVirtualMethods).
287287

288+
Alternatively, instead of introducing a new interface, you can rewrite your code
289+
to accept a std::function instead of the free function, and then use
290+
[MockFunction](#MockFunction) to mock the std::function.
291+
288292
### Old-Style `MOCK_METHODn` Macros
289293

290294
Before the generic `MOCK_METHOD` macro

0 commit comments

Comments
 (0)