Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rnburn authored and Johannes Tax committed Jul 7, 2020
1 parent 4b162e4 commit 3212ed4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sdk/test/event/async_timer/dispatcher_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ TEST(DispatcherTest, Timer)
EXPECT_TRUE(duration < std::chrono::milliseconds{200});
}

TEST(DispatcherTest, ResetTimer)
{
Dispatcher dispatcher;
std::chrono::steady_clock::time_point t1, t2;
auto timer = dispatcher.CreateTimer([&] { t2 = std::chrono::steady_clock::now(); });
timer->EnableTimer(std::chrono::milliseconds{500});
timer->EnableTimer(std::chrono::milliseconds{100});
t1 = std::chrono::steady_clock::now();
dispatcher.Run();
auto duration = t2 - t1;
EXPECT_TRUE(duration > std::chrono::milliseconds{50});
EXPECT_TRUE(duration < std::chrono::milliseconds{200});
}

TEST(DispatcherTest, TimerOrder)
{
Dispatcher dispatcher;
Expand Down

0 comments on commit 3212ed4

Please sign in to comment.