Skip to content

Commit 933738a

Browse files
authored
tests: review (skypjack#91)
tests: review
1 parent b294b4f commit 933738a

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

test/uvw/fs_poll.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ TEST(FsPoll, Functionalities) {
2727
});
2828

2929
request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0755);
30-
handle->start(filename, uvw::FsPollHandle::Time{5});
30+
handle->start(filename, uvw::FsPollHandle::Time{1000});
3131
request->write(std::unique_ptr<char[]>{new char[1]{ 42 }}, 1, 0);
3232

3333
ASSERT_EQ(handle->path(), filename);

test/uvw/work.cpp

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,27 @@ TEST(Work, RunTask) {
3838

3939
TEST(Work, Cancellation) {
4040
auto loop = uvw::Loop::getDefault();
41-
auto handle = loop->resource<uvw::CheckHandle>();
41+
auto handle = loop->resource<uvw::TimerHandle>();
4242

4343
bool checkErrorEvent = false;
44-
bool checkWorkEvent = false;
45-
bool checkTask = false;
4644

47-
handle->on<uvw::CheckEvent>([](const auto &, auto &hndl) {
45+
handle->on<uvw::TimerEvent>([](const auto &, auto &hndl) {
4846
hndl.stop();
4947
hndl.close();
5048
});
5149

52-
auto req = loop->resource<uvw::WorkReq>([&checkTask]() {
53-
ASSERT_FALSE(checkTask);
54-
checkTask = true;
55-
});
50+
for(auto i = 0; i < 5 /* default uv thread pool size + 1 */; ++i) {
51+
auto req = loop->resource<uvw::WorkReq>([]() {});
5652

57-
req->on<uvw::ErrorEvent>([&checkErrorEvent](const auto &, auto &) {
58-
ASSERT_FALSE(checkErrorEvent);
59-
checkErrorEvent = true;
60-
});
53+
req->on<uvw::WorkEvent>([](const auto &, auto &) {});
54+
req->on<uvw::ErrorEvent>([&checkErrorEvent](const auto &, auto &) { checkErrorEvent = true; });
6155

62-
req->on<uvw::WorkEvent>([&checkWorkEvent](const auto &, auto &) {
63-
ASSERT_FALSE(checkWorkEvent);
64-
checkWorkEvent = true;
65-
});
56+
req->queue();
57+
req->cancel();
58+
}
6659

67-
handle->start();
68-
req->queue();
69-
req->cancel();
60+
handle->start(uvw::TimerHandle::Time{500}, uvw::TimerHandle::Time{500});
7061
loop->run();
7162

7263
ASSERT_TRUE(checkErrorEvent);
73-
ASSERT_FALSE(checkWorkEvent);
74-
ASSERT_FALSE(checkTask);
7564
}

0 commit comments

Comments
 (0)