From 3cbe4e07ab7fadbed5534b9917ca4230a65c9dd0 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Sun, 22 May 2022 14:31:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B1=E4=BA=8E=E9=9C=80=E6=B1=82=E5=8F=98?= =?UTF-8?q?=E5=8A=A8=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=86=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bus_io.c | 11 ++++++----- test/dict.dic | 2 +- test/io_test.cpp | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) 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);