I am trying to practice some simple gtest with test fixture but somehow I kept getting errors like saying my test has not been declared when I ran catkin_make run_tests. Here are the errors:
:28:19: error: ‘countingtest1’ has not been declared
Test_F(counttest, countingtest1) {
:28:32: error: ISO C++ forbids declaration of ‘Test_F’ with no type [-fpermissive]
Test_F(counttest, countingtest1) {
:14:7: note: because the following virtual functions are pure within ‘counttest’:
class counttest : public testing::Test {
/usr/include/gtest/gtest.h:422:16: note: virtual void testing::Test::TestBody()
virtual void TestBody() = 0;
Makefile:186: recipe for target 'run_tests' failed
make: *** [run_tests] Error 2
Invoking "make run_tests -j4 -l4" failed
Here are my code:
'''C++
#include "ros/ros.h"
#include "gtest/gtest.h"
using namespace std;
class counting {
public:
int addcount() {
static int count = 0;
cout << count << " ";
count += 1;
return count;
}
};
class counttest : public testing::Test {
public:
counting counting1;
int num = 0;
virtual void SetUp(){
counting counting1;
}
virtual void startcounting(){
for (int i=0; i<5; i++)
int num = counting1.addcount();
}
};
Test_F(counttest, countingtest1) {
int num = 0;
EXPECT_EQ(num,5);
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
'''
Aucun commentaire:
Enregistrer un commentaire