gmock 设置输出参数 SetArgPointee

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

PolymorphicAction<

  internal::SetArgumentPointeeAction<

    N, T, internal::IsAProtocolMessage::value> >

SetArgPointee(const T& x) {

  return MakePolymorphicAction(internal::SetArgumentPointeeAction<

      N, T, internal::IsAProtocolMessage::value>(x));

}

你可能感兴趣的:(gmock 设置输出参数 SetArgPointee)