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
This commit is contained in:
Dino Radakovic 2023-10-03 11:41:17 -07:00 committed by Copybara-Service
parent a6d7fa8c0c
commit beb552fb47

View File

@ -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