0
gtest를 구현 중이며 이전에 여기에서 정의한 main이라는 오류가 발생합니다.오류 : 'int main (int, char **)'는 C++에서 이전에 여기에 정의되었습니다.
여기 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에 주요하지만, 실제 코드에 아무것도 본관.
은 내가
#ifndef UTEST_H
#define UTEST_H
을 시도하고 오류가 해결되지 않는 utest 및 테스트 CPP 파일
에 대한 헤더 파일을 필요 없다.
작동합니다! 감사합니다 :) 5 분 후에 답변을 수락합니다! :) – Leanne