forked from andreimaximov/uthread
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathio.cpp
More file actions
32 lines (23 loc) · 639 Bytes
/
Copy pathio.cpp
File metadata and controls
32 lines (23 loc) · 639 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <uthread/gtest.hpp>
#include <uthread/uthread.hpp>
namespace uthread {
class IoTest : public ::testing::TestWithParam<Io::Timer> {};
TEST(IoTest, IoShutsDownIfNoReadyThreads) {
Executor exe;
Io io(&exe);
exe.run();
}
TEST_P(IoTest, SleepsForApproximateTime) {
static constexpr auto kSleepTime = std::chrono::milliseconds(100);
Executor exe;
Io io(&exe);
exe.add([&]() {
ASSERT_TAKES_APPROX_MS(io.sleep_for(kSleepTime, GetParam()), 100);
});
ASSERT_TAKES_APPROX_MS(exe.run(), 100);
}
INSTANTIATE_TEST_CASE_P(
SleepTimers,
IoTest,
::testing::Values(Io::Timer::Libevent, Io::Timer::CpuLoop));
}