修复了测试框架编译缺少头文件的问题

添加了测试示例
This commit is contained in:
jackfiled 2022-05-08 11:48:04 +08:00
parent 42df13da84
commit 82f5b2292b
6 changed files with 35 additions and 5 deletions

View File

@ -2,8 +2,8 @@
// Created by ricardo on 2022/5/6.
//
#ifndef AUTO_PILOT_BUS_IO_H
#define AUTO_PILOT_BUS_IO_H
#ifndef AUTO_PILOT_BUS_BUS_IO_H
#define AUTO_PILOT_BUS_BUS_IO_H
#include "rail.h"
#include "query.h"
@ -49,4 +49,4 @@ read_state_t ReadInput(up_bus_t* up_queries, down_bus_t* down_queries);
*/
void PrintState(up_bus_t* up_queries, down_bus_t* down_queries, rail_node_t* rails);
#endif //AUTO_PILOT_BUS_IO_H
#endif //AUTO_PILOT_BUS_BUS_IO_H

View File

@ -38,4 +38,6 @@ extern rail_node_t* rails;
*/
rail_node_t *FindNode(int id);
int add(int a, int b);
#endif //AUTO_PILOT_BUS_RAIL_H

View File

@ -1,4 +1,4 @@
//
// Created by ricardo on 2022/5/6.
//
#include "io.h"
#include "bus_io.h"

View File

@ -1,3 +1,8 @@
#include "rail.h"
rail_node_t *rails;
int add(int a, int b)
{
return a+ b;
}

View File

@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.0)
project(bus_test)
set(CMAKE_CXX_STANDARD 11)
add_subdirectory(./GTest)
include_directories(GTest/googletest/include)

21
test/io_test.cpp Normal file
View File

@ -0,0 +1,21 @@
//
// Created by ricardo on 2022/5/7.
//
#include "gtest/gtest.h"
#include "gmock/gmock.h"
extern "C"
{
#include "rail.h"
}
using ::testing::Return;
using ::testing::AtLeast;
using ::testing::Exactly;
using namespace testing;
TEST(test, test)
{
int result = add(1, 1);
EXPECT_EQ(2, result);
}