From 82f5b2292bff4bfd9ca3a13f56a4d1f1fb74bae6 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Sun, 8 May 2022 11:48:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E7=BC=96=E8=AF=91=E7=BC=BA=E5=B0=91=E5=A4=B4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BA=86=E6=B5=8B=E8=AF=95=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/{io.h => bus_io.h} | 6 +++--- include/rail.h | 2 ++ src/{io.c => bus_io.c} | 2 +- src/rail.c | 7 ++++++- test/CMakeLists.txt | 2 ++ test/io_test.cpp | 21 +++++++++++++++++++++ 6 files changed, 35 insertions(+), 5 deletions(-) rename include/{io.h => bus_io.h} (90%) rename src/{io.c => bus_io.c} (67%) create mode 100644 test/io_test.cpp 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); +}