大佬教程收集整理的这篇文章主要介绍了c – 为什么Google Test会出现分段错误?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在考虑this example.如果我在任何测试中插入这样的东西,我将开始得到段错误:
EXPECT_EQ(8,2 * 3);
重申一下,这只是在我设置了Gtest_BREAK_ON_FAILURE = 1时.我从命令行运行,也运行gdb.如果未设置该环境变量,则会报告错误但不会发生段错误.
什么可能导致这个/我做错了什么的任何线索?我一直在寻找类似的问题,但我还没有碰到任何东西.
仅供参考我在64位CrunchBang Linux 11“Waldorf”上运行Google Test 1.7.0版.
// Tests factorial of positive numbers. TEST(FactorialTest,PositivE) { EXPECT_EQ(1,Factorial(1)); EXPECT_EQ(2,Factorial(2)); EXPECT_EQ(6,Factorial(3)); EXPECT_EQ(40320,Factorial(8)); }
调试器输出:
(gdb) run StarTing program: /home/yourfavoriteprotein/bin/cpp_unit_test_frameworks/gtest-1.7.0/samples/myTest [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Running main() from test_R_534_11845@ain.cc [==========] Running 6 tests from 2 test cases. [----------] Global test environment set-up. [----------] 3 tests from FactorialTest [ RUN ] FactorialTest.Negative [ OK ] FactorialTest.Negative (0 ms) [ RUN ] FactorialTest.Zero [ OK ] FactorialTest.Zero (0 ms) [ RUN ] FactorialTest.Positive sample1_unittest.cc:112: Failure Value of: 2*3 Actual: 6 Expected: 8 Program received signal SIGSEGV,Segmentation fault. 0x0000000000413427 in tesTing::UnitTest::AddTestPartResult(tesTing::TestPartResult::Type,char const*,int,std::string const&,std::string const&) () (gdb) quit
以上是大佬教程为你收集整理的c – 为什么Google Test会出现分段错误?全部内容,希望文章能够帮你解决c – 为什么Google Test会出现分段错误?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。