我想设置对gmock对象的期望。当“avout”作为我的方法的一个参数传递时,期望值应该适用。我设置的期望是这样的:需要gmock TypedEq相同的字符串不同的地址
EXPECT_CALL(actx_mock, getDeviceClientService(TypedEq<const char*>("avout"),_,_)).WillOnce(DoAll(SetArgPointee<2>(&mockAVOut), Return(0)));
TypedEq因为该方法被重载,接受字符串或一个const char *。当我运行我的测试,我得到以下错误:
CAniSpiceServices_test.cpp:1357: EXPECT_CALL(actx_mock, getDeviceClientService(TypedEq<const char*>("avout"),_,_))...
Expected arg #0: is equal to 0x4dbf41 pointing to "avout"
Actual: 0x7fbc6861370d pointing to "avout"
因此,看起来即使字符串是一样的,因为它是指向不同的地址做串的不同实例,这不是”比赛?有没有办法使它匹配任何匹配该值的字符串,而不考虑地址?
请你能发布完整的'EXPECT_CALL' fn吗? – sjsam
好的,这样做。不认为它匹配后做了什么,因为它不匹配。 –