diff --git a/test/uvw/fs_req.cpp b/test/uvw/fs_req.cpp index 3fb76101..ab7af517 100644 --- a/test/uvw/fs_req.cpp +++ b/test/uvw/fs_req.cpp @@ -765,3 +765,40 @@ TEST(FsReq, LchownSync) { loop->run(); } + +TEST(FsReq, ReadDir) { + const std::string dir_name = std::string{TARGET_FS_REQ_DIR}; + + auto loop = uvw::Loop::getDefault(); + auto fsReq = loop->resource(); + + bool checkFsReadDirEvent = false; + bool checkFsOpenDirEvent = false; + bool checkFsCloseDirEvent = false; + + fsReq->on([](const auto &, auto &) { FAIL(); }); + + fsReq->on>([&checkFsCloseDirEvent](const auto &, auto &) { + ASSERT_FALSE(checkFsCloseDirEvent); + checkFsCloseDirEvent = true; + }); + + fsReq->on>([&checkFsReadDirEvent](const auto &, auto &hndl) { + ASSERT_FALSE(checkFsReadDirEvent); + checkFsReadDirEvent = true; + hndl.closedir(); + }); + + fsReq->on>([&checkFsOpenDirEvent](const auto &, auto &hndl) { + ASSERT_FALSE(checkFsOpenDirEvent); + checkFsOpenDirEvent = true; + hndl.readdir(); + }); + + fsReq->opendir(dir_name); + loop->run(); + + ASSERT_TRUE(checkFsCloseDirEvent); + ASSERT_TRUE(checkFsReadDirEvent); + ASSERT_TRUE(checkFsOpenDirEvent); +}