'How to use an argument as return value in gmock
I have the following call:
EXPECT_CALL(myMock, myFunction(someSpecifiedParameter, _, _))
.WillOnce(DoAll(SaveArg<2>(&bufferSize), Return(make_pair(Success, bufferSize))));
I'm trying to return whatever value that is passed as the second _ as my second element in the pair. Is it the best (or at least right) way to do it?
This bufferSize variable was declared in the test class.
EDIT:
Putting in other words:
Suppose I have the following:
class object{
pair<int, int> f(int x);
}
object obj;
constexpr int fixedValue = 5;
EXPECT_CALL(obj, f(_)).WillOnce(
Return(make_pair(fixedValue, <PARAMETER PASSED TO F>));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
