I would like to set custom value to a void pointer which acts as an out parameter. For e.g. in the below mock function, I would like to set the data_p to a custom value.
MOCK_METHOD3(file_read, int(const char *file_name, const char
*type_name, void *data_p));
I defined a custom action
ACTION_P(SetArg2ToMCValue, value) {
reinterpret_cast<void *>(arg2) = value;
}
In my test,the following is set
struct.param1 = 5.0;
struct.param2 = 5.0;
EXPECT_CALL(*lib_mock, file_read(_,_,_)).WillOnce(DoAll(SetArg2ToMCValue(&struct), Return(0)));
When the unit under test is called, I do not see the values I set in the struct. I get 0 for both param1 and param2.
Can someone let me know what is wrong with the above logic?
Regards,
Ganesh