minor changes

This commit is contained in:
Michele Caini 2017-01-26 14:51:33 +01:00
parent a5ca11c521
commit 511dc309c8

View File

@ -4,10 +4,18 @@
TEST(Work, RunTask) {
auto loop = uvw::Loop::getDefault();
auto handle = loop->resource<uvw::CheckHandle>();
bool checkWorkEvent = false;
bool checkTask = false;
handle->on<uvw::CheckEvent>([&checkWorkEvent](const auto &, auto &hndl) {
if(checkWorkEvent) {
hndl.stop();
hndl.close();
}
});
auto req = loop->resource<uvw::WorkReq>([&checkTask]() {
ASSERT_FALSE(checkTask);
checkTask = true;
@ -20,6 +28,7 @@ TEST(Work, RunTask) {
checkWorkEvent = true;
});
handle->start();
req->queue();
loop->run();
@ -29,11 +38,17 @@ TEST(Work, RunTask) {
TEST(Work, Cancellation) {
auto loop = uvw::Loop::getDefault();
auto handle = loop->resource<uvw::CheckHandle>();
bool checkErrorEvent = false;
bool checkWorkEvent = false;
bool checkTask = false;
handle->on<uvw::CheckEvent>([](const auto &, auto &hndl) {
hndl.stop();
hndl.close();
});
auto req = loop->resource<uvw::WorkReq>([&checkTask]() {
ASSERT_FALSE(checkTask);
checkTask = true;
@ -49,6 +64,7 @@ TEST(Work, Cancellation) {
checkWorkEvent = true;
});
handle->start();
req->queue();
req->cancel();
loop->run();