GMOCK设置功能输入和输出参数

时间:2017-12-02 12:58:01

标签: c++ c++11 gmock

我有一个GMOCK方法,如下所示:

MOCK_METHOD2(FnCall, bool(const Message* request, Message*& reply));

我有以下测试代码来设置值:

const Message* message = new  MockMesage(9);
Message* reply = new MockMesage();

EXPECT_CALL(mMock, FnCall(::testing::_, ::testing::_)).WillOnce(::testing::SetArgReferee<0>(message));

But I get compilation errors:

C:/work/googletest/googlemock/include/gmock/gmock-more-actions.h:192:3: error: static assertion failed: SetArgReferee_must_be_used_with_a_reference_argument
   GTEST_COMPILE_ASSERT_(internal::is_reference<argk_type>::value,
   ^
C:/work/googletest/googlemock/include/gmock/gmock-more-actions.h:194:27: error: assignment of read-only location 'std::get<0ull, {const Message*, Message*&}>((* & args))'
   ::testing::get<k>(args) = value;
error: no matching function for call to 'SetArgReferee(Message*&)'

我们如何设置模拟函数参数,其类型是指针和对指针的引用?

0 个答案:

没有答案