aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDino Radakovic <dinor@google.com>2023-10-03 11:41:17 -0700
committerCopybara-Service <copybara-worker@google.com>2023-10-03 11:41:48 -0700
commitbeb552fb47e9e8a6ddab20526663c2dddd601ec6 (patch)
tree7d814ad258250ca130435ceddbd408be0a19c88e
parenta6d7fa8c0cebaa8b493a1cecdfa05018f6adc8df (diff)
downloadgoogletest-beb552fb47e9e8a6ddab20526663c2dddd601ec6.tar.gz
gmock_cook_book: Document `DoAll`'s return type requirement
The requirement is vaguely documented by "Only the return value of the last action in the sequence will be used.". However, this can be misleading, as users could potentially expect default-constructed values to be returned in absence of a matching return type. PiperOrigin-RevId: 570450839 Change-Id: Ibd98a6e6b2aaf2a8cfc15ed6aeab442526eab98e
-rw-r--r--docs/gmock_cook_book.md6
1 files changed, 6 insertions, 0 deletions
diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md
index da10918c..5e9b6647 100644
--- a/docs/gmock_cook_book.md
+++ b/docs/gmock_cook_book.md
@@ -1927,6 +1927,12 @@ class MockFoo : public Foo {
action_n));
```
+The return value of the last action **must** match the return type of the mocked
+method. In the example above, `action_n` could be `Return(true)`, or a lambda
+that returns a `bool`, but not `SaveArg`, which returns `void`. Otherwise the
+signature of `DoAll` would not match the signature expected by `WillOnce`, which
+is the signature of the mocked method, and it wouldn't compile.
+
### Verifying Complex Arguments {#SaveArgVerify}
If you want to verify that a method is called with a particular argument but the