我是google测试的新手,并且开始尝试模拟对象,在模拟对象后,我的原始方法总是会被调用

时间:2018-11-08 13:01:01

标签: c++ mocking googletest gmock

原始函数原型

virtual void GetSegment(const std::string& polygonId,
                        mi::Uint32& numSegment,
                        std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3>>>* points,
                        std::vector<mi::Uint32>* exclusive);

模拟我的功能

MOCK_METHOD4(GetSegment,
             void(const std::string&, mi::Uint32&, std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3>>>*,
                  std::vector<mi::Uint32>*));

这是我的动作。

mi::Uint32 numSegment = 1;
std::vector<mi::Uint32> exclusive(0);
std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3> >> points{
    {{50.8981,  213.265, 125},
     {117.287,  184.577, 125},
     {215.488,  129.682, 125},
     {276.487,  92.0992, 125}}};

ON_CALL(*mock.get(), GetSegment(refrenceId, _, _, _)).
  WillByDefault(DoAll(SetArgReferee<1>(numSegment), SetArgPointee<2>(points), SetArgPointee<3>(exclusive)));

调用该函数后,总是会调用我的原始文件。

0 个答案:

没有答案
相关问题