From 57756968ac04f9f569796fd5fd9dcd2cfeee2793 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Wed, 25 Jan 2017 12:35:35 +0100 Subject: [PATCH] minor changes --- test/uvw/async.cpp | 7 +-- test/uvw/check.cpp | 7 +-- test/uvw/file_req.cpp | 49 +++++-------------- test/uvw/fs_req.cpp | 107 ++++++++++-------------------------------- test/uvw/idle.cpp | 7 +-- test/uvw/prepare.cpp | 7 +-- test/uvw/timer.cpp | 15 ++---- test/uvw/work.cpp | 19 +++----- 8 files changed, 50 insertions(+), 168 deletions(-) diff --git a/test/uvw/async.cpp b/test/uvw/async.cpp index ca57920b..4d132feb 100644 --- a/test/uvw/async.cpp +++ b/test/uvw/async.cpp @@ -6,13 +6,9 @@ TEST(Async, Send) { auto loop = uvw::Loop::getDefault(); auto handle = loop->resource(); - bool checkErrorEvent = false; bool checkAsyncEvent = false; - handle->on([&checkErrorEvent](const auto &, auto &) { - ASSERT_FALSE(checkErrorEvent); - checkErrorEvent = true; - }); + handle->on([](const auto &, auto &) { FAIL(); }); handle->on([&checkAsyncEvent](const auto &, auto &hndl) { ASSERT_FALSE(checkAsyncEvent); @@ -28,7 +24,6 @@ TEST(Async, Send) { loop->run(); - ASSERT_FALSE(checkErrorEvent); ASSERT_TRUE(checkAsyncEvent); } diff --git a/test/uvw/check.cpp b/test/uvw/check.cpp index b26a439b..7dea9bea 100644 --- a/test/uvw/check.cpp +++ b/test/uvw/check.cpp @@ -6,13 +6,9 @@ TEST(Check, StartAndStop) { auto loop = uvw::Loop::getDefault(); auto handle = loop->resource(); - bool checkErrorEvent = false; bool checkCheckEvent = false; - handle->on([&checkErrorEvent](const auto &, auto &) { - ASSERT_FALSE(checkErrorEvent); - checkErrorEvent = true; - }); + handle->on([](const auto &, auto &) { FAIL(); }); handle->on([&checkCheckEvent](const auto &, auto &hndl) { ASSERT_FALSE(checkCheckEvent); @@ -29,7 +25,6 @@ TEST(Check, StartAndStop) { loop->run(); - ASSERT_FALSE(checkErrorEvent); ASSERT_TRUE(checkCheckEvent); } diff --git a/test/uvw/file_req.cpp b/test/uvw/file_req.cpp index 1b8b55e9..936d8f8d 100644 --- a/test/uvw/file_req.cpp +++ b/test/uvw/file_req.cpp @@ -60,9 +60,7 @@ TEST(FileReq, OpenAndClose) { bool checkFileOpenEvent = false; bool checkFileCloseEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFileCloseEvent](const auto &, auto &) { ASSERT_FALSE(checkFileCloseEvent); @@ -106,9 +104,7 @@ TEST(FileReq, RWChecked) { bool checkFileWriteEvent = false; bool checkFileReadEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFileReadEvent](const auto &event, auto &req) { ASSERT_FALSE(checkFileReadEvent); @@ -146,9 +142,7 @@ TEST(FileReq, RWUnchecked) { bool checkFileWriteEvent = false; bool checkFileReadEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFileReadEvent](const auto &event, auto &req) { ASSERT_FALSE(checkFileReadEvent); @@ -209,9 +203,7 @@ TEST(FileReq, Stat) { bool checkFileStatEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFileStatEvent](const auto &, auto &req) { ASSERT_FALSE(checkFileStatEvent); @@ -257,9 +249,7 @@ TEST(FileReq, Sync) { bool checkFileSyncEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFileSyncEvent](const auto &, auto &req) { ASSERT_FALSE(checkFileSyncEvent); @@ -301,9 +291,7 @@ TEST(FileReq, Datasync) { bool checkFileDatasyncEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFileDatasyncEvent](const auto &, auto &req) { ASSERT_FALSE(checkFileDatasyncEvent); @@ -345,9 +333,7 @@ TEST(FileReq, Truncate) { bool checkFileTruncateEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFileTruncateEvent](const auto &, auto &req) { ASSERT_FALSE(checkFileTruncateEvent); @@ -391,18 +377,13 @@ TEST(FileReq, SendFile) { bool checkFileSendFileEvent = false; - dstReq->on([](const auto &, auto &) { - FAIL(); - }); + dstReq->on([](const auto &, auto &) { FAIL(); }); + srcReq->on([](const auto &, auto &) { FAIL(); }); dstReq->on>([&srcReq](const auto &, auto &req) { srcReq->sendfile(static_cast(req), 0, 0); }); - srcReq->on([](const auto &, auto &) { - FAIL(); - }); - srcReq->on>([&checkFileSendFileEvent, &dstReq](const auto &, auto &req) { ASSERT_FALSE(checkFileSendFileEvent); checkFileSendFileEvent = true; @@ -451,9 +432,7 @@ TEST(FileReq, Chmod) { bool checkFileChmodEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFileChmodEvent](const auto &, auto &req) { ASSERT_FALSE(checkFileChmodEvent); @@ -495,9 +474,7 @@ TEST(FileReq, Utime) { bool checkFileUtimeEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFileUtimeEvent](const auto &, auto &req) { ASSERT_FALSE(checkFileUtimeEvent); @@ -548,9 +525,7 @@ TEST(FileReq, Chown) { bool checkFileChownEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFileChownEvent](const auto &, auto &req) { ASSERT_FALSE(checkFileChownEvent); diff --git a/test/uvw/fs_req.cpp b/test/uvw/fs_req.cpp index e6e91f4a..17d6a9bd 100644 --- a/test/uvw/fs_req.cpp +++ b/test/uvw/fs_req.cpp @@ -17,9 +17,7 @@ TEST(FsReq, MkdirAndRmdir) { bool checkFsMkdirEvent = false; bool checkFsRmdirEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFsRmdirEvent](const auto &, auto &) { ASSERT_FALSE(checkFsRmdirEvent); @@ -63,9 +61,7 @@ TEST(FsReq, MkdtempAndRmdir) { bool checkFsMkdtempEvent = false; bool checkFsRmdirEvent = false; - request->on([](const auto &, auto &) { - FAIL(); - }); + request->on([](const auto &, auto &) { FAIL(); }); request->on>([&checkFsRmdirEvent](const auto &, auto &) { ASSERT_FALSE(checkFsRmdirEvent); @@ -125,19 +121,14 @@ TEST(FsReq, Stat) { bool checkFsStatEvent = false; - fsReq->on([](const auto &, auto &) { - FAIL(); - }); + fsReq->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); fsReq->on>([&checkFsStatEvent](const auto &, auto &) { ASSERT_FALSE(checkFsStatEvent); checkFsStatEvent = true; }); - fileReq->on([](const auto &, auto &) { - FAIL(); - }); - fileReq->on>([&fsReq, &filename](const auto &, auto &) { fsReq->stat(filename); }); @@ -181,19 +172,14 @@ TEST(FsReq, Lstat) { bool checkFsLstatEvent = false; - fsReq->on([](const auto &, auto &) { - FAIL(); - }); + fsReq->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); fsReq->on>([&checkFsLstatEvent](const auto &, auto &) { ASSERT_FALSE(checkFsLstatEvent); checkFsLstatEvent = true; }); - fileReq->on([](const auto &, auto &) { - FAIL(); - }); - fileReq->on>([&fsReq, &filename](const auto &, auto &) { fsReq->lstat(filename); }); @@ -238,19 +224,14 @@ TEST(FsReq, Rename) { bool checkFsRenameEvent = false; - fsReq->on([](const auto &, auto &) { - FAIL(); - }); + fsReq->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); fsReq->on>([&checkFsRenameEvent](const auto &, auto &) { ASSERT_FALSE(checkFsRenameEvent); checkFsRenameEvent = true; }); - fileReq->on([](const auto &, auto &) { - FAIL(); - }); - fileReq->on>([&fsReq, &filename, &rename](const auto &, auto &) { fsReq->rename(filename, rename); }); @@ -292,19 +273,14 @@ TEST(FsReq, Access) { bool checkFsAccessEvent = false; - fsReq->on([](const auto &, auto &) { - FAIL(); - }); + fsReq->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); fsReq->on>([&checkFsAccessEvent](const auto &, auto &) { ASSERT_FALSE(checkFsAccessEvent); checkFsAccessEvent = true; }); - fileReq->on([](const auto &, auto &) { - FAIL(); - }); - fileReq->on>([&fsReq, &filename](const auto &, auto &) { fsReq->access(filename, R_OK); }); @@ -345,19 +321,14 @@ TEST(FsReq, Chmod) { bool checkFsChmodEvent = false; - fsReq->on([](const auto &, auto &) { - FAIL(); - }); + fsReq->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); fsReq->on>([&checkFsChmodEvent](const auto &, auto &) { ASSERT_FALSE(checkFsChmodEvent); checkFsChmodEvent = true; }); - fileReq->on([](const auto &, auto &) { - FAIL(); - }); - fileReq->on>([&fsReq, &filename](const auto &, auto &) { fsReq->chmod(filename, 0644); }); @@ -398,19 +369,14 @@ TEST(FsReq, Utime) { bool checkFsUtimeEvent = false; - fsReq->on([](const auto &, auto &) { - FAIL(); - }); + fsReq->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); fsReq->on>([&checkFsUtimeEvent](const auto &, auto &) { ASSERT_FALSE(checkFsUtimeEvent); checkFsUtimeEvent = true; }); - fileReq->on([](const auto &, auto &) { - FAIL(); - }); - fileReq->on>([&fsReq, &filename](const auto &, auto &) { auto now = std::chrono::system_clock::now(); auto epoch = now.time_since_epoch(); @@ -461,9 +427,8 @@ TEST(FsReq, LinkAndUnlink) { bool checkFsLinkEvent = false; bool checkFsUnlinkEvent = false; - fsReq->on([](const auto &, auto &) { - FAIL(); - }); + fsReq->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); fsReq->on>([&checkFsUnlinkEvent](const auto &, auto &) { ASSERT_FALSE(checkFsUnlinkEvent); @@ -476,10 +441,6 @@ TEST(FsReq, LinkAndUnlink) { request.unlink(linkname); }); - fileReq->on([](const auto &, auto &) { - FAIL(); - }); - fileReq->on>([&fsReq, &filename, &linkname](const auto &, auto &) { fsReq->link(filename, linkname); }); @@ -525,9 +486,8 @@ TEST(FsReq, SymlinkAndUnlink) { bool checkFsLinkEvent = false; bool checkFsUnlinkEvent = false; - fsReq->on([](const auto &, auto &) { - FAIL(); - }); + fsReq->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); fsReq->on>([&checkFsUnlinkEvent](const auto &, auto &) { ASSERT_FALSE(checkFsUnlinkEvent); @@ -540,10 +500,6 @@ TEST(FsReq, SymlinkAndUnlink) { request.unlink(linkname); }); - fileReq->on([](const auto &, auto &) { - FAIL(); - }); - fileReq->on>([&fsReq, &filename, &linkname](const auto &, auto &) { fsReq->symlink(filename, linkname, 0); }); @@ -588,9 +544,8 @@ TEST(FsReq, Readlink) { bool checkFsReadlinkEvent = false; - fsReq->on([](const auto &, auto &) { - FAIL(); - }); + fsReq->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); fsReq->on>([&checkFsReadlinkEvent, &linkname](const auto &, auto &request) { ASSERT_FALSE(checkFsReadlinkEvent); @@ -602,10 +557,6 @@ TEST(FsReq, Readlink) { request.readlink(linkname); }); - fileReq->on([](const auto &, auto &) { - FAIL(); - }); - fileReq->on>([&fsReq, &filename, &linkname](const auto &, auto &) { fsReq->symlink(filename, linkname, 0); }); @@ -652,9 +603,8 @@ TEST(FsReq, Realpath) { bool checkFsRealpathEvent = false; - fsReq->on([](const auto &, auto &) { - FAIL(); - }); + fsReq->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); fsReq->on>([&checkFsRealpathEvent](const auto &event, auto &) { ASSERT_FALSE(checkFsRealpathEvent); @@ -662,10 +612,6 @@ TEST(FsReq, Realpath) { checkFsRealpathEvent = true; }); - fileReq->on([](const auto &, auto &) { - FAIL(); - }); - fileReq->on>([&fsReq, &filename](const auto &, auto &) { fsReq->realpath(filename); }); @@ -710,9 +656,8 @@ TEST(FsReq, Chown) { bool checkFsChownEvent = false; - fsReq->on([](const auto &, auto &) { - FAIL(); - }); + fsReq->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); fsReq->on>([&checkFsChownEvent](const auto &, auto &) { ASSERT_FALSE(checkFsChownEvent); @@ -723,10 +668,6 @@ TEST(FsReq, Chown) { request.chown(filename, event.stat.st_uid, event.stat.st_gid); }); - fileReq->on([](const auto &, auto &) { - FAIL(); - }); - fileReq->on>([&fsReq, &filename](const auto &, auto &) { fsReq->stat(filename); }); diff --git a/test/uvw/idle.cpp b/test/uvw/idle.cpp index e4afb344..19626f64 100644 --- a/test/uvw/idle.cpp +++ b/test/uvw/idle.cpp @@ -6,13 +6,9 @@ TEST(Idle, StartAndStop) { auto loop = uvw::Loop::getDefault(); auto handle = loop->resource(); - bool checkErrorEvent = false; bool checkIdleEvent = false; - handle->on([&checkErrorEvent](const auto &, auto &) { - ASSERT_FALSE(checkErrorEvent); - checkErrorEvent = true; - }); + handle->on([](const auto &, auto &) { FAIL(); }); handle->on([&checkIdleEvent](const auto &, auto &hndl) { ASSERT_FALSE(checkIdleEvent); @@ -29,7 +25,6 @@ TEST(Idle, StartAndStop) { loop->run(); - ASSERT_FALSE(checkErrorEvent); ASSERT_TRUE(checkIdleEvent); } diff --git a/test/uvw/prepare.cpp b/test/uvw/prepare.cpp index f2c39c96..477a072e 100644 --- a/test/uvw/prepare.cpp +++ b/test/uvw/prepare.cpp @@ -6,13 +6,9 @@ TEST(Prepare, StartAndStop) { auto loop = uvw::Loop::getDefault(); auto handle = loop->resource(); - bool checkErrorEvent = false; bool checkPrepareEvent = false; - handle->on([&checkErrorEvent](const auto &, auto &) { - ASSERT_FALSE(checkErrorEvent); - checkErrorEvent = true; - }); + handle->on([](const auto &, auto &) { FAIL(); }); handle->on([&checkPrepareEvent](const auto &, auto &hndl) { ASSERT_FALSE(checkPrepareEvent); @@ -29,7 +25,6 @@ TEST(Prepare, StartAndStop) { loop->run(); - ASSERT_FALSE(checkErrorEvent); ASSERT_TRUE(checkPrepareEvent); } diff --git a/test/uvw/timer.cpp b/test/uvw/timer.cpp index 20ae4308..1d47a0ec 100644 --- a/test/uvw/timer.cpp +++ b/test/uvw/timer.cpp @@ -7,19 +7,11 @@ TEST(Timer, StartAndStop) { auto handleNoRepeat = loop->resource(); auto handleRepeat = loop->resource(); - bool checkErrorEvent = false; bool checkTimerNoRepeatEvent = false; bool checkTimerRepeatEvent = false; - handleNoRepeat->on([&checkErrorEvent](const auto &, auto &) { - ASSERT_FALSE(checkErrorEvent); - checkErrorEvent = true; - }); - - handleRepeat->on([&checkErrorEvent](const auto &, auto &) { - ASSERT_FALSE(checkErrorEvent); - checkErrorEvent = true; - }); + handleNoRepeat->on([](const auto &, auto &) { FAIL(); }); + handleRepeat->on([](const auto &, auto &) { FAIL(); }); handleNoRepeat->on([&checkTimerNoRepeatEvent](const auto &, auto &handle) { ASSERT_FALSE(checkTimerNoRepeatEvent); @@ -51,7 +43,6 @@ TEST(Timer, StartAndStop) { loop->run(); - ASSERT_FALSE(checkErrorEvent); ASSERT_TRUE(checkTimerNoRepeatEvent); ASSERT_TRUE(checkTimerRepeatEvent); } @@ -62,7 +53,7 @@ TEST(Timer, Again) { auto handle = loop->resource(); bool checkErrorEvent = false; - bool checkTimerEvent = true; + bool checkTimerEvent = false; handle->on([&checkErrorEvent](const auto &, auto &) { ASSERT_FALSE(checkErrorEvent); diff --git a/test/uvw/work.cpp b/test/uvw/work.cpp index 6cce150e..aa4a5537 100644 --- a/test/uvw/work.cpp +++ b/test/uvw/work.cpp @@ -5,7 +5,6 @@ TEST(Work, RunTask) { auto loop = uvw::Loop::getDefault(); - bool checkErrorEvent = false; bool checkWorkEvent = false; bool checkTask = false; @@ -14,20 +13,16 @@ TEST(Work, RunTask) { checkTask = true; }); + req->on([](const auto &, auto &) { FAIL(); }); + req->on([&checkWorkEvent](const auto &, auto &) { ASSERT_FALSE(checkWorkEvent); checkWorkEvent = true; }); - req->on([&checkErrorEvent](const auto &, auto &) { - ASSERT_FALSE(checkErrorEvent); - checkErrorEvent = true; - }); - req->queue(); loop->run(); - ASSERT_FALSE(checkErrorEvent); ASSERT_TRUE(checkWorkEvent); ASSERT_TRUE(checkTask); } @@ -44,16 +39,16 @@ TEST(Work, Cancellation) { checkTask = true; }); - req->on([&checkWorkEvent](const auto &, auto &) { - ASSERT_FALSE(checkWorkEvent); - checkWorkEvent = true; - }); - req->on([&checkErrorEvent](const auto &, auto &) { ASSERT_FALSE(checkErrorEvent); checkErrorEvent = true; }); + req->on([&checkWorkEvent](const auto &, auto &) { + ASSERT_FALSE(checkWorkEvent); + checkWorkEvent = true; + }); + req->queue(); req->cancel(); loop->run();