gmock
In gmock, Is there a way to have mock object return an instance of an user defined object?
For UT purposes, I am trying to Mock out a function that returns a vector of user defined structs. std::vector<myStruct> myClass::foo() In gmock, Is there a way to do something like this: std::vector<myStruct> TestVector; //code to populate my vector .... ON_CALL(MockMyClass, foo()).WillByDefault(Return(TestVector)) I couldn't find anything in the gmock cookbook, it looks like the return values are all primitives. Thanks
I ended up using ReturnPointee https://code.google.com/p/googlemock/wiki/CookBook#Returning_Live_Values_from_Mock_Methods std::vector * ptr; //instantiate and populate vector... ON_CALL(MockMyClass, foo()).WillByDefault(ReturnPointee(ptr));
Related Links
gmock ReturnRef returns compilation error
How to call function pointer which is passed to Mock method?
In gmock, Is there a way to have mock object return an instance of an user defined object?
GMock testing destructor calls
set EXPECT_CALL to redirect the call to the original method
Capture GMOCK string parameter
Mocking non-virtual method generating errors
gmock matcher doesn't match my arguments by reference
What did you do to solve gmock you mentioned (link enclosed)?
how to set custom ref-variable in gmock