I am using Gmock in my project. I have the following mock function.
MOCK_METHOD2(helper,
bool(const std::string&, std::string*));
Goal is to set value of parameter 1 to parameter 2 for all mock calls.
I did the following.
std::string temp;
EXPECT_CALL(
MockObj,
helper(_,_))
.WillRepeatedly(
DoAll(SaveArg<0>(&temp), //Save first arg to temp
SetArgPointee<1>(temp), //assign it to second arg
Return(true)));
However I see that parameter 2 is set to the original value of tmp rather than the value saved. Is there any other way to solve this? I want to make this EXPECT_CALL dynamic rather than doing SetArgPointee<1>("testval").