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-20 08:52:58 +08:00
|
|
|
#include "bus_io.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 namespace testing;
|
|
|
|
|
2022-05-20 08:52:58 +08:00
|
|
|
TEST(bus_io, ReadInput_clock)
|
2022-05-08 11:48:04 +08:00
|
|
|
{
|
2022-05-20 08:52:58 +08:00
|
|
|
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);
|
2022-05-17 20:22:29 +08:00
|
|
|
}
|