美文网首页
gmock 设置输出参数 SetArgPointee

gmock 设置输出参数 SetArgPointee

作者: 我的随笔 | 来源:发表于2019-11-01 16:41 被阅读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));

    }

    相关文章

      网友评论

          本文标题:gmock 设置输出参数 SetArgPointee

          本文链接:https://www.haomeiwen.com/subject/dtqqbctx.html