Calling a method when expected method on mock was invoked

大城市里の小女人 提交于 2019-12-05 18:34:39
VladLosev
EXPECT_CALL(mockA, foo()).WillOnce(InvokeWithoutArgs(&impl, &ImplC::bla));

Should work. If you have to pass more complex parameters, use boost::bind (notice the different order of the class instance and method in the parameter list):

EXPECT_CALL(mockA, foo())
    .WillOnce(Invoke(boost::bind(&ImplC::bla, &impl, other_params)));

And if foo() is given some parameters that should be passed into bla(), use WithArgs:

EXPECT_CALL(mockA, foo(Lt(1), _))
    .WillOnce(WithArgs<0>(Invoke(&impl, &ImplC::bla)));

Also take a look at the Google Mock Cheat Sheet wiki page - it provides more information about function- and method calling actions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!