调用ASSERT_TRUE的函数,返回值类型定义必须是void,如果想返回别的类型,就用EXPECT_TRUE:

void abc::fun()
{
ASSERT_TRUE(fun1());
} bool abc::fun()
{
bool result = fun1();
EXPECT_TRUE(result );
return result ;
}
ASSERT_TRUE is a macro. When expanded it will contain a branch like:

if (fun1() == false) {
return;
}
This is how ASSERT_TRUE does a hard stop on failure, but it also means that your method bool abc::fun() now has a void return exit path, in conflict with its signature. Possible fixes include don't use hard stop asserts: bool abc::fun(){
bool result = fun1();
EXPECT_TRUE(result); //No return in expansion
//No hard stop!
return result;
}
or change your methods return type if not needed: void abc::fun(){
ASSERT_TRUE(fun1()); //Hard stop on failure
}
or return by reference: void abc::fun(bool &outResult){
outResult = fun1(); //return result by reference
ASSERT_TRUE(result);
}

引用地址

最新文章

  1. 19.在HTTP 1.0中,状态码401的含义是(?);如果返回“找不到文件”的提示,则可用 header 函数,其语句为(?)写出http常见的状态码和含义,至少5个.[完善题目]
  2. openlayers 注册事件例子
  3. 好的博客mark
  4. 单例模式(Winform窗体的实现)
  5. 针对BootStrap中tabs控件的美化和完善
  6. 汉字编码:GB2312, GBK, GB18030, Big5
  7. 关于”机器学习方法“,"深度学习方法"系列
  8. auDemo
  9. shell-逐行读取文件
  10. 获取Django项目的全部url
  11. bzoj 2303: [Apio2011]方格染色
  12. 利用FPN构建Faster R-CNN检测
  13. 网上看到一份详细sql游标说明 《转载 https://www.cnblogs.com/xiongzaiqiren/p/sql-cursor.html》
  14. 《Java大学教程》—第14章 抽象、继承和接口
  15. Python:Day53 Template基础
  16. 生产环境Linux常用命令【随时更新】
  17. Cartographer源码阅读(8):imu_tracker
  18. mysql日期操作
  19. Android Retrofit2.1.0设置编码格式GBK
  20. Codeforces 1077 F2 - Pictures with Kittens (hard version)

热门文章

  1. 定义Portal显示规则
  2. samba 奇怪问题
  3. memory management in oracle 11G R2
  4. 中间件解析FDMEMTABLE.delta生成SQL的方法
  5. gradle: 修改gradle-xx-bin.zip下载地址
  6. 还原对于server失败 备份集中的数据库备份与现有数据库不同
  7. C++中stringstream ostringstream istringstream使用方式
  8. Modular_exponentiation模幂运算
  9. 第一篇 Windows 8 开发Windows Metro style app环境配置
  10. Quartz.net使用入门(三)