gmock真是很好用!
例子如下:
MOCK_METHOD1(test, void(void** data));
char ch = 'm';
void* a = (void*)&ch;
EXPECT_CALL(myMock, test(_)) .WillOnce(SetArgPointee<0>(a));
在头文件gmock.h看到了这个:
// Creates an action that sets the variable pointed by the N-th
// (0-based) function argument to 'value'.
template <size_t N, typename T>
PolymorphicAction<
internal::SetArgumentPointeeAction<
N, T, internal::IsAProtocolMessage<T>::value> >
SetArgPointee(const T& x) {
return MakePolymorphicAction(internal::SetArgumentPointeeAction<
N, T, internal::IsAProtocolMessage<T>::value>(x));
}
网友评论