由于需求变动,修改了配置文件读取函数
This commit is contained in:
parent
01a5f8a289
commit
3cbe4e07ab
11
src/bus_io.c
11
src/bus_io.c
|
@ -69,14 +69,15 @@ rail_node_t *ReadConfigFile()
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p == '1' && *(p + 1) != '\n')
|
// 讲道理,应该只有两位数,所以就这样处理了
|
||||||
{
|
if (*(p + 1) == '\n')
|
||||||
total_station = 10;
|
|
||||||
}
|
|
||||||
else if (*(p + 1) == '\n')
|
|
||||||
{
|
{
|
||||||
total_station = *p - 48;
|
total_station = *p - 48;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
total_station = (*p - 48) * 10 + *(p + 1) - 48;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# The Config file of bus
|
# The Config file of bus
|
||||||
# Comment
|
# Comment
|
||||||
TOTAL_STATION = 10
|
TOTAL_STATION = 12
|
||||||
DISTANCE = 5
|
DISTANCE = 5
|
||||||
# STRATEGY = SCAN
|
# STRATEGY = SCAN
|
||||||
STRATEGY = FCFS
|
STRATEGY = FCFS
|
||||||
|
|
|
@ -46,7 +46,7 @@ TEST(bus_file, all)
|
||||||
rail_node_t *p = result;
|
rail_node_t *p = result;
|
||||||
|
|
||||||
ASSERT_TRUE(p != nullptr);
|
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->id, i);
|
||||||
EXPECT_EQ(p->next_node_distance, 5);
|
EXPECT_EQ(p->next_node_distance, 5);
|
||||||
|
@ -55,7 +55,7 @@ TEST(bus_file, all)
|
||||||
}
|
}
|
||||||
|
|
||||||
p = result->last_node;
|
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->id, i);
|
||||||
EXPECT_EQ(p->next_node_distance, 5);
|
EXPECT_EQ(p->next_node_distance, 5);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user