From 8b4b5602501c5cae16fad17316ca362a710a4d79 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Wed, 25 May 2022 11:03:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E5=9C=A8?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=9C=80=E5=90=8E=E4=B8=80=E8=A1=8C=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E8=AF=BB=E5=8F=96=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bus_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bus_io.c b/src/bus_io.c index e87c575..a4f63c4 100644 --- a/src/bus_io.c +++ b/src/bus_io.c @@ -70,7 +70,7 @@ rail_node_t *ReadConfigFile() } // 讲道理,应该只有两位数,所以就这样处理了 - if (*(p + 1) == '\n') + if (*(p + 1) == '\n' || *(p + 1) == '\0') { total_station = *p - 48; } @@ -125,7 +125,7 @@ rail_node_t *ReadConfigFile() p++; } - if (*(p + 1) == '\n') + if (*(p + 1) == '\n' || *(p + 1) == '\0') { distance = *p - 48; } From ce65bf8ee0197a951ea7d82ea74b6e2fa833ef2b Mon Sep 17 00:00:00 2001 From: jackfiled Date: Wed, 25 May 2022 11:04:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=8D=8A?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B5=8B=E8=AF=95=E7=B3=BB=E7=BB=9F=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E6=96=87=E4=BB=B6=E8=BF=87=E7=A8=8B=E4=B8=AD=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E7=B3=BB=E5=88=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- all_test/CMakeLists.txt | 6 +++--- all_test/main.c | 14 +++++++++++--- all_test/src/tools.c | 15 ++++++++------- all_test/test_cases/1/{ouput.txt => output.txt} | 0 src/controller.c | 12 +++++++++++- 5 files changed, 33 insertions(+), 14 deletions(-) rename all_test/test_cases/1/{ouput.txt => output.txt} (100%) diff --git a/all_test/CMakeLists.txt b/all_test/CMakeLists.txt index 7aa513d..df43eb9 100644 --- a/all_test/CMakeLists.txt +++ b/all_test/CMakeLists.txt @@ -10,6 +10,6 @@ aux_source_directory("${CMAKE_CURRENT_SOURCE_DIR}/src" ALL_TEST_SRCS) add_executable(bus_all_test ${SRCS} ${ALL_TEST_SRCS} main.c) add_custom_command(TARGET bus_all_test POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${CMAKE_CURRENT_SOURCE_DIR}/test_cases/" - $) \ No newline at end of file + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${CMAKE_CURRENT_SOURCE_DIR}/test_cases" + "$/test_cases") \ No newline at end of file diff --git a/all_test/main.c b/all_test/main.c index 4d5333b..b606558 100644 --- a/all_test/main.c +++ b/all_test/main.c @@ -33,7 +33,7 @@ int main() FILE *output_file = NULL; printf("Please choose which test case to use:"); - scanf("%d\n", &index); + scanf("%d", &index); ChooseTestCaseInput(path, index); input_file = fopen(path, "r"); @@ -55,7 +55,11 @@ int main() ReadOutputFile(read_output, output_file); if(CheckOutput(output, read_output) == BUS_FAlSE) { - printf("%s\n", output); + printf("Right:\n"); + printf("%s", read_output); + printf("Wrong:\n"); + printf("%s", output); + printf("\n"); // 打印一个空白作为分界线 } else { @@ -112,7 +116,11 @@ int main() ReadOutputFile(read_output, output_file); if(CheckOutput(output, read_output) == BUS_FAlSE) { - printf("%s\n", output); + printf("Right:\n"); + printf("%s", read_output); + printf("Wrong:\n"); + printf("%s", output); + printf("\n"); // 打印一个空白行作为分界线 } else { diff --git a/all_test/src/tools.c b/all_test/src/tools.c index 8c32166..bb63d27 100644 --- a/all_test/src/tools.c +++ b/all_test/src/tools.c @@ -67,7 +67,7 @@ rail_node_t *ChooseConfigFile(int index) sprintf(case_path, "%d", index); - char file_path[30]; + char file_path[30] = {0}; strcat(file_path, root_path); strcat(file_path, case_path); @@ -106,14 +106,15 @@ rail_node_t *ReadChosenConfigFile(char *config_file_path) p++; } - if (*p == '1' && *(p + 1) != '\n') - { - total_station = 10; - } - else if (*(p + 1) == '\n') + // 讲道理,应该只有两位数,所以就这样处理了 + if (*(p + 1) == '\n' || *(p + 1) == '\0') { total_station = *p - 48; } + else + { + total_station = (*p - 48) * 10 + *(p + 1) - 48; + } break; case 'S': @@ -161,7 +162,7 @@ rail_node_t *ReadChosenConfigFile(char *config_file_path) p++; } - if (*(p + 1) == '\n') + if (*(p + 1) == '\n' || *(p + 1) == '\0') { distance = *p - 48; } diff --git a/all_test/test_cases/1/ouput.txt b/all_test/test_cases/1/output.txt similarity index 100% rename from all_test/test_cases/1/ouput.txt rename to all_test/test_cases/1/output.txt diff --git a/src/controller.c b/src/controller.c index 6121a52..bd52255 100644 --- a/src/controller.c +++ b/src/controller.c @@ -4,4 +4,14 @@ #include "controller.h" bus_query_t *target_query = NULL; -int chosen_strategy = -1; \ No newline at end of file +int chosen_strategy = -1; + +int FCFSDirection() +{ + return BUS_STOP; +} + +bus_query_t *FCFSQuery() +{ + return NULL; +} \ No newline at end of file