diff --git a/src/bus_io.c b/src/bus_io.c index 72f2e96..e46aa08 100644 --- a/src/bus_io.c +++ b/src/bus_io.c @@ -69,14 +69,15 @@ rail_node_t *ReadConfigFile() p++; } - if (*p == '1' && *(p + 1) != '\n') - { - total_station = 10; - } - else if (*(p + 1) == '\n') + // 讲道理,应该只有两位数,所以就这样处理了 + if (*(p + 1) == '\n') { total_station = *p - 48; } + else + { + total_station = (*p - 48) * 10 + *(p + 1) - 48; + } break; case 'S': diff --git a/test/dict.dic b/test/dict.dic index d6d1d36..0eea586 100644 --- a/test/dict.dic +++ b/test/dict.dic @@ -1,6 +1,6 @@ # The Config file of bus # Comment -TOTAL_STATION = 10 +TOTAL_STATION = 12 DISTANCE = 5 # STRATEGY = SCAN STRATEGY = FCFS diff --git a/test/io_test.cpp b/test/io_test.cpp index 9beb68d..698aeff 100644 --- a/test/io_test.cpp +++ b/test/io_test.cpp @@ -46,7 +46,7 @@ TEST(bus_file, all) rail_node_t *p = result; ASSERT_TRUE(p != nullptr); - for(int i = 1; i <= 10; i++) + for(int i = 1; i <= 12; i++) { EXPECT_EQ(p->id, i); EXPECT_EQ(p->next_node_distance, 5); @@ -55,7 +55,7 @@ TEST(bus_file, all) } p = result->last_node; - for(int i = 10; i >= 1; i--) + for(int i = 12; i >= 1; i--) { EXPECT_EQ(p->id, i); EXPECT_EQ(p->next_node_distance, 5);