我试图使用Truly匹配器,以捕获变量。
#include "gmock/gmock.h"
#include "gtest/gtest.h"
void TestsClass::Set_Values(double TmpStmp, double Point_0_Y,
double Point_0_Width, double Point_0_Qual, bool RCom_Flag)
{
struct pData;
pData.var1 = TmpStmp;
pData.Point_0.Point_0_Y = Point_0_Y;
pData.Point_0.Point_0_Width = Point_0_Width;
pData.Point_0.Point_0_Qual = Point_0_Qual;
EXPECT_CALL(mockFunction, Function(_)).WillOnce(DoAll(SetArgPointee<0>(pData), Return(RCom_Flag)));
EXPECT_CALL(
mockArHudModuleWrapper,
updatePackage(Matcher<const ArHud::MergedEgoLaneCenterLine&>(
Truly([p0Y = Point_0_Y] (const ArHud::MergedEgoLaneCenterLine package) -> bool {
package.getPoint(0) == p0Y;
return true;
})
)));
}
如您所见,我正在尝试捕获p0Y。
但是,当我尝试构建它时,出现错误:
line 1813: error #20: identifier "p0Y" is undefined
EXPECT_CALL(
line 1813: error #17: expected a "]"
我省略了模拟类定义和语法的其他部分,因为我认为它们与这种情况无关。