Commit a5a5daef authored by Maxim Georgiev's avatar Maxim Georgiev Committed by facebook-github-bot-1

Adding a unit test for HHWheelTimer exercising the default timeout functionality.

Summary: Recently default timeout logic was added to HHWheelTimer interface. This diff adds a unit test exercising this new logic.

Reviewed By: @djwatson

Differential Revision: D2376834
parent 7b772a7b
......@@ -389,6 +389,41 @@ TEST_F(HHWheelTimerTest, SlowLoop) {
T_CHECK_TIMEOUT(start2, end2, milliseconds(10), milliseconds(1));
}
/*
* Test scheduling a mix of timers with default timeout and variable timeout.
*/
TEST_F(HHWheelTimerTest, DefaultTimeout) {
milliseconds defaultTimeout(milliseconds(5));
StackWheelTimer t(&eventBase,
milliseconds(1),
AsyncTimeout::InternalEnum::NORMAL,
defaultTimeout);
TestTimeout t1;
TestTimeout t2;
ASSERT_EQ(t.count(), 0);
ASSERT_EQ(t.getDefaultTimeout(), defaultTimeout);
t.scheduleTimeout(&t1);
t.scheduleTimeout(&t2, milliseconds(10));
ASSERT_EQ(t.count(), 2);
TimePoint start;
eventBase.loop();
TimePoint end;
ASSERT_EQ(t1.timestamps.size(), 1);
ASSERT_EQ(t2.timestamps.size(), 1);
ASSERT_EQ(t.count(), 0);
T_CHECK_TIMEOUT(start, t1.timestamps[0], defaultTimeout);
T_CHECK_TIMEOUT(start, t2.timestamps[0], milliseconds(10));
T_CHECK_TIMEOUT(start, end, milliseconds(10));
}
TEST_F(HHWheelTimerTest, lambda) {
StackWheelTimer t(&eventBase, milliseconds(1));
size_t count = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment