You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
896 B
39 lines
896 B
5 years ago
|
#include <gtest/gtest.h>
|
||
|
|
||
4 years ago
|
#include "webfuse_provider/impl/timer/timepoint.h"
|
||
5 years ago
|
|
||
|
#include <thread>
|
||
|
#include <chrono>
|
||
|
|
||
|
using namespace std::chrono_literals;
|
||
|
|
||
4 years ago
|
TEST(wfp_timer_timepoint, now)
|
||
5 years ago
|
{
|
||
4 years ago
|
wfp_timer_timepoint start = wfp_timer_timepoint_now();
|
||
5 years ago
|
std::this_thread::sleep_for(42ms);
|
||
4 years ago
|
wfp_timer_timepoint end = wfp_timer_timepoint_now();
|
||
5 years ago
|
|
||
|
ASSERT_LT(start, end);
|
||
|
ASSERT_LT(end, start + 500);
|
||
|
}
|
||
|
|
||
4 years ago
|
TEST(wfp_timer_timepoint, in_msec)
|
||
5 years ago
|
{
|
||
4 years ago
|
wfp_timer_timepoint now = wfp_timer_timepoint_now();
|
||
|
wfp_timer_timepoint later = wfp_timer_timepoint_in_msec(42);
|
||
5 years ago
|
|
||
|
ASSERT_LT(now, later);
|
||
|
ASSERT_LT(later, now + 500);
|
||
|
}
|
||
|
|
||
4 years ago
|
TEST(wfp_timer_timepoint, elapsed)
|
||
5 years ago
|
{
|
||
4 years ago
|
wfp_timer_timepoint now;
|
||
5 years ago
|
|
||
4 years ago
|
now = wfp_timer_timepoint_now();
|
||
|
ASSERT_TRUE(wfp_timer_timepoint_is_elapsed(now - 1));
|
||
5 years ago
|
|
||
4 years ago
|
now = wfp_timer_timepoint_now();
|
||
|
ASSERT_FALSE(wfp_timer_timepoint_is_elapsed(now + 500));
|
||
5 years ago
|
}
|