feat fix time_keeper_test failed.
This commit is contained in:
parent
eb483b6a50
commit
44e92a75f5
@ -14,6 +14,7 @@ namespace internal {
|
|||||||
constexpr auto kTestDuration = std::chrono::seconds(5);
|
constexpr auto kTestDuration = std::chrono::seconds(5);
|
||||||
constexpr auto kInterval = std::chrono::milliseconds(100);
|
constexpr auto kInterval = std::chrono::milliseconds(100);
|
||||||
constexpr auto kTimerNum = 100;
|
constexpr auto kTimerNum = 100;
|
||||||
|
constexpr auto kExpFactor = 0.5;
|
||||||
|
|
||||||
TEST(TimeKeeper, OneFastTimer)
|
TEST(TimeKeeper, OneFastTimer)
|
||||||
{
|
{
|
||||||
@ -22,7 +23,7 @@ TEST(TimeKeeper, OneFastTimer)
|
|||||||
std::this_thread::sleep_for(kTestDuration);
|
std::this_thread::sleep_for(kTestDuration);
|
||||||
TimeKeeper::Instance()->KillTimer(timer_id);
|
TimeKeeper::Instance()->KillTimer(timer_id);
|
||||||
constexpr auto expires_count = kTestDuration / kInterval;
|
constexpr auto expires_count = kTestDuration / kInterval;
|
||||||
constexpr auto eps = expires_count / 10;
|
constexpr auto eps = expires_count * kExpFactor;
|
||||||
ASSERT_NEAR(x, expires_count, eps);
|
ASSERT_NEAR(x, expires_count, eps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ TEST(TimeKeeper, SlowTimer)
|
|||||||
for (auto &&e : timers) { TimeKeeper::Instance()->KillTimer(e); }
|
for (auto &&e : timers) { TimeKeeper::Instance()->KillTimer(e); }
|
||||||
|
|
||||||
const auto expires_count = kTimerNum * (2 * kTestDuration / kInterval);
|
const auto expires_count = kTimerNum * (2 * kTestDuration / kInterval);
|
||||||
const auto eps = expires_count / 10;
|
const auto eps = expires_count * kExpFactor;
|
||||||
ASSERT_NEAR(x, expires_count, eps);
|
ASSERT_NEAR(x, expires_count, eps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ TEST(TimeKeeper, FastTimer)
|
|||||||
for (auto &&e : timers) { TimeKeeper::Instance()->KillTimer(e); }
|
for (auto &&e : timers) { TimeKeeper::Instance()->KillTimer(e); }
|
||||||
|
|
||||||
const auto expires_count = kTimerNum * (2 * kTestDuration / kInterval);
|
const auto expires_count = kTimerNum * (2 * kTestDuration / kInterval);
|
||||||
const auto eps = expires_count / 10;
|
const auto eps = expires_count * kExpFactor;
|
||||||
ASSERT_NEAR(x, expires_count, eps);
|
ASSERT_NEAR(x, expires_count, eps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user