現在 gtest を実装していますが、エラーが表示されます: main 以前にここで定義されています。
これがutest.cppです
// Bring in my package's API, which is what I'm testing
#include "../src/test.cpp"
// Bring in gtest
#include <gtest/gtest.h>
// Declare a test
TEST(TestSuite, testCase1)
{
EXPECT_EQ(5,getX(5));
}
// Run all the tests that were declared with TEST()
int main(int argc, char **argv){
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
そして、これがtest.cppをテストしているコードです
#include "ros/ros.h"
#include "std_msgs/String.h"
#include <Project2Sample/R_ID.h>
#include <geometry_msgs/Twist.h>
#include <nav_msgs/Odometry.h>
#include <sensor_msgs/LaserScan.h>
#include <sstream>
#include "math.h"
int getX(int x)
{
return x;
}
int main(int argc, char **argv)
{
return 0;
}
test.cpp main には何もありませんが、実際のコードには main にいくつかのコードがあります。
utest および test cpp ファイルのヘッダー ファイルがありません
私は試した
#ifndef UTEST_H
#define UTEST_H
エラーを解決しませんでした。