diff --git a/include/io.h b/include/bus_io.h similarity index 90% rename from include/io.h rename to include/bus_io.h index 435fd5a..8bac72d 100644 --- a/include/io.h +++ b/include/bus_io.h @@ -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 diff --git a/include/rail.h b/include/rail.h index c48f56f..02f237d 100644 --- a/include/rail.h +++ b/include/rail.h @@ -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 diff --git a/src/io.c b/src/bus_io.c similarity index 67% rename from src/io.c rename to src/bus_io.c index 1544ebd..27fb895 100644 --- a/src/io.c +++ b/src/bus_io.c @@ -1,4 +1,4 @@ // // Created by ricardo on 2022/5/6. // -#include "io.h" +#include "bus_io.h" diff --git a/src/rail.c b/src/rail.c index e7ebe6f..0dd3efd 100644 --- a/src/rail.c +++ b/src/rail.c @@ -1,3 +1,8 @@ #include "rail.h" -rail_node_t *rails; \ No newline at end of file +rail_node_t *rails; + +int add(int a, int b) +{ + return a+ b; +} \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a81ac16..a142fe9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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) diff --git a/test/io_test.cpp b/test/io_test.cpp new file mode 100644 index 0000000..77a01a1 --- /dev/null +++ b/test/io_test.cpp @@ -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); +}