[英]Tests fail when throw exception anywhere in TEST macro googletest
I have some problems with google testing framework我对谷歌测试框架有一些问题
So, when I run the following code:因此,当我运行以下代码时:
void f(){
throw runtime_error("");
}
TEST(test, test1){
EXPECT_THROW(f(), std::runtime_error);
}
So, I got such error:所以,我得到了这样的错误:
make[2]: *** [test/CMakeFiles/gTest.dir/build.make:101: test/gTest] Segmentation fault (core dumped)
make[2]: *** Deleting file 'test/gTest'
make[1]: *** [CMakeFiles/Makefile2:173: test/CMakeFiles/gTest.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
But when f() does not throw anything, so test just not passed.但是当 f() 没有抛出任何东西时,所以测试没有通过。 Even if I use try catch it still shows me the same error
即使我使用 try catch 它仍然显示相同的错误
Could you help to solve this problem?你能帮忙解决这个问题吗? Thanks
谢谢
The problem was with type of exception, thanks.问题出在异常类型上,谢谢。 Presented code works
提交的代码有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.