Can I for a return value on a parameter?

1,154 views
Skip to first unread message

Chris F

unread,
Jan 4, 2013, 12:20:27 PM1/4/13
to googl...@googlegroups.com
Say I'm mocking this function

void foo(const int inputVal, int& outputVal);

and the calling function is this

int input=0;
int output=0;
foo(input, output);

Can I force the outputVal to return a certain value with an ON_CALL macro? If so how? Thanks!

Billy Donahue

unread,
Jan 4, 2013, 12:27:53 PM1/4/13
to Chris F, googl...@googlegroups.com
I think:

ON_CALL(*obj, foo(_,_)).SetArgReferee<1>(value)

Billy Donahue

unread,
Jan 4, 2013, 12:30:03 PM1/4/13
to Chris F, googl...@googlegroups.com
On Fri, Jan 4, 2013 at 12:27 PM, Billy Donahue <billyd...@google.com> wrote:
I think:

ON_CALL(*obj, foo(_,_)).SetArgReferee<1>(value)


Correction:

ON_CALL(*obj, foo(_,_))
    .WillByDefault(SetArgReferee<1>(value));

Chris F

unread,
Jan 4, 2013, 1:20:50 PM1/4/13
to googl...@googlegroups.com, Chris F, billyd...@google.com
Ok I'll try it. What "using ::testing::*;" does that fall under?

Billy Donahue

unread,
Jan 4, 2013, 1:24:02 PM1/4/13
to Chris F, googl...@googlegroups.com
using ::testing::SetArgReferee;

Chris F

unread,
Jan 4, 2013, 1:37:26 PM1/4/13
to googl...@googlegroups.com, Chris F, billyd...@google.com
I get for some reason, and I added using ::testing::SetArgReferee.

error: 'class testing::internal::OnCallSpec<int(const char*, sqlite3**)>' has no member named 'SetArgReferee'

Billy Donahue

unread,
Jan 4, 2013, 1:49:57 PM1/4/13
to Chris F, googl...@googlegroups.com
On Fri, Jan 4, 2013 at 1:37 PM, Chris F <zil...@gmail.com> wrote:
I get for some reason, and I added using ::testing::SetArgReferee.

error: 'class testing::internal::OnCallSpec<int(const char*, sqlite3**)>' has no member named 'SetArgReferee'

CL and sponge link or it didn't happen.  :)

Chris F

unread,
Jan 4, 2013, 1:59:08 PM1/4/13
to googl...@googlegroups.com, Chris F, billyd...@google.com
:)

This is just a compile error, not run error. Thanks.
Reply all
Reply to author
Forward
0 new messages