c++ - google mock 多个 EXPECT_CALL 相互冲突?
问题描述
我有这个代码片段,它运行良好:
class If2{
public:
virtual void set(const char* s)=0;
};
class Impl2:public If2{
public:
MOCK_METHOD1(set, void(const char*));
};
TEST(t2,case2){
Impl2 mock;
EXPECT_CALL(mock,set).Times(Between(1,5));
mock.set("aa");
}
但是当我为 set() 添加 2 EXPECT_CALL 时,它不起作用:
TEST(t2,case2){
Impl2 mock;
EXPECT_CALL(mock,set).Times(Between(1,5));
EXPECT_CALL(mock,set(Not(HasSubstr("bb"))));
mock.set("aa");
}
错误信息是:
Actual function call count doesn't match EXPECT_CALL(mock, set)...
Expected: to be called between 1 and 5 times
Actual: never called - unsatisfied and active
对我来说真的很奇怪,我已经调用了一次“set”,为什么多个 EXPECT_CALL 在这里不起作用?谢谢。
解决方案
推荐阅读
- c# - 有没有办法将工件 nuget 作者姓名从(默认?) VssAdministrator 更改为我的首选作者姓名?
- java - 我在事件处理方面做的每一件事都是正确的。但是,我遗漏了一些东西。请问这是什么?
- reactjs - 尝试将 const 导出到 React 中的另一个组件
- amazon-web-services - 证书未由受信任的 CA 正确签名
- c++ - 在一个类中使用另一个类中的函数,而无需在 C++ 中继承
- r - 在 Shiny 中插入警告信息
- javascript - 如何在反应中删除ckeditor5工具栏上的图像插件
- css - 隐藏水平滚动条但可以继续滚动
- javascript - 禁用所有事件,除非在自定义上下文菜单的情况下单击左键
- amazon-web-services - 如何在 AWS-SDK JS 版本 3 中获取签名的 S3 Url?