2022-05-08 11:48:04 +08:00
|
|
|
//
|
|
|
|
// Created by ricardo on 2022/5/7.
|
|
|
|
//
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "gmock/gmock.h"
|
2022-05-12 15:32:45 +08:00
|
|
|
// 在C++中引用C语言中的函数
|
|
|
|
#ifdef __cplusplus
|
2022-05-08 11:48:04 +08:00
|
|
|
extern "C"
|
|
|
|
{
|
2022-05-12 15:32:45 +08:00
|
|
|
#endif
|
2022-05-08 11:48:04 +08:00
|
|
|
#include "rail.h"
|
2022-05-17 20:22:29 +08:00
|
|
|
#include "bus_io.h"
|
|
|
|
#include "query.h"
|
|
|
|
#include "define.h"
|
2022-05-12 15:32:45 +08:00
|
|
|
#ifdef __cplusplus
|
2022-05-08 11:48:04 +08:00
|
|
|
}
|
2022-05-12 15:32:45 +08:00
|
|
|
#endif
|
2022-05-08 11:48:04 +08:00
|
|
|
|
|
|
|
using ::testing::Return;
|
|
|
|
using ::testing::AtLeast;
|
|
|
|
using ::testing::Exactly;
|
|
|
|
|
|
|
|
using namespace testing;
|
|
|
|
|
|
|
|
TEST(test, test)
|
|
|
|
{
|
|
|
|
int result = add(1, 1);
|
|
|
|
EXPECT_EQ(2, result);
|
|
|
|
}
|
2022-05-17 20:22:29 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 测试输入读取函数读取clock时的行为
|
|
|
|
*/
|
|
|
|
TEST(io_test, io_clock)
|
|
|
|
{
|
|
|
|
char input[7] = "clock\n";
|
|
|
|
int result = ReadInput(input);
|
|
|
|
EXPECT_EQ(result, IO_CLOCK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 测试顺时针3号站台上车请求
|
|
|
|
*/
|
|
|
|
TEST(io_test, reading)
|
|
|
|
{
|
|
|
|
char input[] = "counterclockwise 3\n";
|
|
|
|
int result = ReadInput(input);
|
|
|
|
EXPECT_EQ(result, IO_READING);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(io_test, end)
|
|
|
|
{
|
|
|
|
char input[] = "end\n";
|
|
|
|
int result = ReadInput(input);
|
|
|
|
EXPECT_EQ(result, IO_END);
|
|
|
|
}
|