tests: tty + minor changes
This commit is contained in:
parent
be305657f1
commit
d9d544e1b5
@ -46,6 +46,7 @@ set(TARGET_RESOURCE resource)
|
||||
set(TARGET_SIGNAL signal)
|
||||
set(TARGET_TCP tcp)
|
||||
set(TARGET_TIMER timer)
|
||||
set(TARGET_TTY tty)
|
||||
set(TARGET_UDP udp)
|
||||
set(TARGET_UTIL util)
|
||||
set(TARGET_WORK work)
|
||||
@ -175,6 +176,14 @@ target_include_directories(${TARGET_TIMER} PRIVATE ${COMMON_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_TIMER} PRIVATE ${COMMON_LINK_LIBS})
|
||||
add_test(NAME ${TARGET_TIMER} COMMAND ${TARGET_TIMER})
|
||||
|
||||
# Test TARGET_TTY
|
||||
|
||||
set(TARGET_TTY_SOURCES $<TARGET_OBJECTS:odr> uvw/tty.cpp)
|
||||
add_executable(${TARGET_TTY} ${TARGET_TTY_SOURCES})
|
||||
target_include_directories(${TARGET_TTY} PRIVATE ${COMMON_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_TTY} PRIVATE ${COMMON_LINK_LIBS})
|
||||
add_test(NAME ${TARGET_TTY} COMMAND ${TARGET_TTY})
|
||||
|
||||
# Test TARGET_UDP
|
||||
|
||||
set(TARGET_UDP_SOURCES $<TARGET_OBJECTS:odr> uvw/udp.cpp)
|
||||
|
||||
@ -9,7 +9,7 @@ struct TestEmitter: uvw::Emitter<TestEmitter> {
|
||||
};
|
||||
|
||||
|
||||
TEST(Emitter, ClearAndClear) {
|
||||
TEST(Emitter, EmptyAndClear) {
|
||||
TestEmitter emitter{};
|
||||
|
||||
ASSERT_TRUE(emitter.empty());
|
||||
|
||||
@ -16,8 +16,7 @@ TEST(Loop, DefaultLoop) {
|
||||
}
|
||||
|
||||
|
||||
TEST(Loop, PartiallyDone) {
|
||||
|
||||
TEST(Loop, Functionalities) {
|
||||
auto loop = uvw::Loop::create();
|
||||
auto handle = loop->resource<uvw::PrepareHandle>();
|
||||
auto req = loop->resource<uvw::WorkReq>([]{});
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
struct Res: uvw::Resource<Res, int> { };
|
||||
|
||||
|
||||
TEST(Resource, Basics) {
|
||||
TEST(Resource, Functionalities) {
|
||||
ASSERT_FALSE(std::is_copy_constructible<uvw::AsyncHandle>::value);
|
||||
ASSERT_FALSE(std::is_copy_assignable<uvw::AsyncHandle>::value);
|
||||
|
||||
|
||||
32
test/uvw/tty.cpp
Normal file
32
test/uvw/tty.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <uvw.hpp>
|
||||
|
||||
|
||||
TEST(TTY, Functionalities) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto handle = loop->resource<uvw::TTYHandle>(uvw::StdOUT, false);
|
||||
auto timer = loop->resource<uvw::TimerHandle>();
|
||||
|
||||
bool checkWriteEvent = false;
|
||||
|
||||
handle->on<uvw::WriteEvent>([&checkWriteEvent](const auto &, auto &hndl){
|
||||
ASSERT_FALSE(checkWriteEvent);
|
||||
checkWriteEvent = true;
|
||||
hndl.close();
|
||||
});
|
||||
|
||||
timer->on<uvw::TimerEvent>([handle](const auto &, auto &hndl){
|
||||
auto data = std::make_unique<char[]>('*');
|
||||
handle->write(std::move(data), 1);
|
||||
hndl.close();
|
||||
});
|
||||
|
||||
ASSERT_TRUE(handle->reset());
|
||||
ASSERT_TRUE(handle->mode(uvw::TTYHandle::Mode::NORMAL));
|
||||
ASSERT_NO_THROW(handle->getWinSize());
|
||||
|
||||
timer->start(uvw::TimerHandle::Time{0}, uvw::TimerHandle::Time{0});
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkWriteEvent);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user