How to cascade return values with ON_CALL

34 views
Skip to first unread message

Markus Degen

unread,
Jan 10, 2012, 10:14:07 AM1/10/12
to Google C++ Mocking Framework
Hi,

as we would like to set up our ON_CALL or EXPECT_CALLs at startup of
the testcase we had the following problem.

It is possible to cascade Rteurn values with EXPECT_CALL
like this
EXPECT_CALL( fooMock2, defaultInt() )
.WillOnce(Return(1)).WillOnce(Return(2));

Is there something similar that i can do with ON_CALL???

Thanks for your help
Markus

Daniel Walker

unread,
Jan 10, 2012, 10:29:38 AM1/10/12
to Markus Degen, Google C++ Mocking Framework

Just off the top of my head, set ExpectCall with Times(1) and the desired return value separately for each different value in your 'cascade'. I think the most recently set expectation (and return) value will get hit first. You might need to set RetiresOnSaturation.

Markus Degen

unread,
Jan 10, 2012, 10:36:51 AM1/10/12
to Google C++ Mocking Framework
Thanks Daniel. EXPECT_CALL will always assert the expectation, i don't
care if it is called, so i thought there might be an ON_CALL solution

On 10 Jan., 16:29, Daniel Walker <dam...@gmail.com> wrote:
> Just off the top of my head, set ExpectCall with Times(1) and the desired
> return value separately for each different value in your 'cascade'. I think
> the most recently set expectation (and return) value will get hit first.
> You might need to set RetiresOnSaturation.
Reply all
Reply to author
Forward
0 new messages