修复了ReadInput函数中的系列错误

ReadInput函数测试通过
This commit is contained in:
jackfiled 2022-05-20 08:52:58 +08:00
parent 635ea8bdfa
commit 6095d0849b
6 changed files with 34 additions and 16 deletions

View File

@ -24,7 +24,7 @@ typedef struct bus bus_t;
/**
*
*/
extern bus_t the_bus;
extern bus_t *the_bus;
/**
* 使

View File

@ -6,6 +6,9 @@
#define AUTO_PILOT_BUS_BUS_IO_H
#include "rail.h"
#include "query.h"
#include "define.h"
#include "string.h"
#include "stdio.h"
/**
* 使

View File

@ -1,3 +1,3 @@
#include "bus.h"
bus_t *the_bus;
bus_t *the_bus = NULL;

View File

@ -2,7 +2,6 @@
// Created by ricardo on 2022/5/6.
//
#include "bus_io.h"
#include "define.h"
int ReadInput(char* inputString)
{
@ -16,22 +15,27 @@ int ReadInput(char* inputString)
}
else if (0 == strcmp("counterclockwise",src))
{
bus_query_t *CreateQuery(BUS_COUNTER_CLOCK_WISE, FindNode(num));
CreateQuery(BUS_COUNTER_CLOCK_WISE, FindNode(rails ,num));
return IO_READING;
}
else if (0 == strcmp("clockwise",src))
{
bus_query_t *CreateQuery(BUS_CLOCK_WISE,FindNode(num));
CreateQuery(BUS_CLOCK_WISE,FindNode(rails, num));
return IO_READING;
}
else if (0 == strcmp("target",src))
{
bus_query_t *CreateQuery(BUS_TARGET,FindNode(num));
CreateQuery(BUS_TARGET,FindNode(rails, num));
return IO_READING;
}
else if (0 == strcmp("end",src))
{
return IO_END;
}
else
{
// 匹配失败则返回-1
return -1;
}
}

View File

@ -8,15 +8,32 @@
extern "C"
{
#endif
#include "rail.h"
#include "bus_io.h"
#include "define.h"
#ifdef __cplusplus
}
#endif
using namespace testing;
TEST(test, test)
TEST(bus_io, ReadInput_clock)
{
int result = add(1, 1);
EXPECT_EQ(2, result);
int result;
char str[10] = "clock\n";
result = ReadInput(str);
EXPECT_EQ(result, IO_CLOCK);
}
TEST(bus_io, ReadInput_end)
{
char str[5] = "end\n";
int result = ReadInput(str);
EXPECT_EQ(result, IO_END);
}
TEST(bus_io, ReadInput_reading)
{
char str[20] = "target 8\n";
int result = ReadInput(str);
EXPECT_EQ(result, IO_READING);
}

View File

@ -50,12 +50,6 @@ TEST(rail, FindNode)
EXPECT_EQ(p->id, 9);
}
TEST(rail, FreeRails)
{
rail_node_t *head = CreateRails(10, 10);
FreeRails(head);
}