c++ - Googletest compilation errors: ‘xyzTest’ was not declared in this scope -


i learning tdd, using googletest framework. have built gtest , have been able build , run samples. however, when tried simple sample wrote, getting compilation errors.

here source , build commands used:

// ################################################ //proj1.h #ifndef  __scratch_proj1_h #define  __scratch_proj1_h  int addone(int i);  #endif /*__scratch_proj1_h */  // ################################################  //proj1.cpp #include "proj1.h"  int addone(int i){     return i+1; }   // ################################################ //proj1_unittest.cpp  #include "proj1.h" #include "gtest/gtest.h"  // test function test(addonetest, positive) {     expect_eq(1,addonetest(0));            // <- line # 24     expect_eq(2,addonetest(1));            // <- line # 25     expect_eq(40320, addonetest(40319));   // <- line # 26 }  test(addonetest, negative) {     expect_false(addonetest(-1));          // <- line # 30 }   gtest_api_ int main(int argc, char **argv) {   testing::initgoogletest(&argc, argv);   return run_all_tests(); } 

console output:

g++ -isystem ${gtest_dir}/include -pthread -c /home/user1/scratch/proj1_unittest.cpp /home/user1/scratch/proj1_unittest.cpp: in member function ‘virtual void addonetest_positive_test::testbody()’: /home/user1/scratch/proj1_unittest.cpp:24:5: error: ‘addonetest’ not declared in scope /home/user1/scratch/proj1_unittest.cpp:25:5: error: ‘addonetest’ not declared in scope /home/user1/scratch/proj1_unittest.cpp:26:5: error: ‘addonetest’ not declared in scope /home/user1/scratch/proj1_unittest.cpp: in member function ‘virtual void addonetest_negative_test::testbody()’: /home/user1/scratch/proj1_unittest.cpp:30:5: error: ‘addonetest’ not declared in scope

judging line numbers in error messages, seems expect_* macros have not been defined - but, have included gtest/gtest.h in compilation unit.

what causing these errors - , how fix it?

as says, addonetest not declared anywhere. i'm guessing meant call addone instead.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -