Skip to content

Commit 34119bf

Browse files
committed
tests
1 parent 60f5d71 commit 34119bf

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

test/uvw/fs_event.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,36 @@
22
#include <uvw.hpp>
33

44

5-
TEST(FsEvent, StartAndStop) {
6-
const std::string dirname = std::string{TARGET_FS_EVENT_DIR};
5+
TEST(FsEvent, Functionalities) {
6+
const std::string relative = std::string{"test.file"};
7+
const std::string absolute = std::string{TARGET_FS_EVENT_DIR} + "/" + relative;
8+
const std::string rename = std::string{TARGET_FS_EVENT_DIR} + std::string{"/test.rename"};
79

810
auto loop = uvw::Loop::getDefault();
911
auto handle = loop->resource<uvw::FsEventHandle>();
10-
auto req = loop->resource<uvw::FsReq>();
12+
auto fileReq = loop->resource<uvw::FileReq>();
13+
auto fsReq = loop->resource<uvw::FsReq>();
1114

1215
bool checkFsEventEvent = false;
1316

14-
req->mkdirSync(dirname, 0755);
15-
1617
handle->on<uvw::ErrorEvent>([](const auto &, auto &) { FAIL(); });
17-
req->on<uvw::ErrorEvent>([](const auto &, auto &) { FAIL(); });
18+
fileReq->on<uvw::ErrorEvent>([](const auto &, auto &) { FAIL(); });
19+
fsReq->on<uvw::ErrorEvent>([](const auto &, auto &) { FAIL(); });
1820

19-
handle->on<uvw::FsEventEvent>([&checkFsEventEvent, &dirname](const auto &, auto &hndl) {
21+
handle->on<uvw::FsEventEvent>([&checkFsEventEvent, &relative](const auto &event, auto &hndl) {
2022
ASSERT_FALSE(checkFsEventEvent);
23+
ASSERT_EQ(std::string{event.filename}, relative);
2124
checkFsEventEvent = true;
2225
hndl.stop();
2326
hndl.close();
2427
ASSERT_TRUE(hndl.closing());
2528
});
2629

27-
req->rmdir(dirname);
28-
handle->start(dirname);
30+
fileReq->openSync(absolute, O_CREAT | O_RDWR | O_TRUNC, 0644);
31+
fsReq->rename(absolute, rename);
32+
handle->start(absolute);
2933

30-
ASSERT_EQ(handle->path(), dirname);
34+
ASSERT_EQ(handle->path(), absolute);
3135
ASSERT_TRUE(handle->active());
3236
ASSERT_FALSE(handle->closing());
3337

0 commit comments

Comments
 (0)