修复了半自动测试系统读取文件过程中存在的系列问题
This commit is contained in:
parent
8b4b560250
commit
ce65bf8ee0
|
@ -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/"
|
||||
$<TARGET_FILE_DIR:bus_all_test>)
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/test_cases"
|
||||
"$<TARGET_FILE_DIR:bus_all_test>/test_cases")
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -4,4 +4,14 @@
|
|||
#include "controller.h"
|
||||
|
||||
bus_query_t *target_query = NULL;
|
||||
int chosen_strategy = -1;
|
||||
int chosen_strategy = -1;
|
||||
|
||||
int FCFSDirection()
|
||||
{
|
||||
return BUS_STOP;
|
||||
}
|
||||
|
||||
bus_query_t *FCFSQuery()
|
||||
{
|
||||
return NULL;
|
||||
}
|
Loading…
Reference in New Issue
Block a user