gmock 设置输出参数 SetArgPointee

2019-11-01  本文已影响0人  我的随笔

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));

}

上一篇 下一篇

猜你喜欢

热点阅读