mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
add real timeout test
This commit is contained in:
parent
68c827609a
commit
0c998a7598
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
TEST(MonoTime, UnixTimeIncreasesOverTime)
|
TEST(MonoTime, UnixTimeIncreasesOverTime)
|
||||||
|
@ -41,6 +44,24 @@ TEST(MonoTime, IsTimeout)
|
||||||
mono_time_free(mem, mono_time);
|
mono_time_free(mem, mono_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(MonoTime, IsTimeoutReal)
|
||||||
|
{
|
||||||
|
const Memory *mem = system_memory();
|
||||||
|
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
|
||||||
|
ASSERT_NE(mono_time, nullptr);
|
||||||
|
|
||||||
|
uint64_t const start = mono_time_get(mono_time);
|
||||||
|
EXPECT_FALSE(mono_time_is_timeout(mono_time, start, 5));
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
mono_time_update(mono_time);
|
||||||
|
|
||||||
|
// should still not have timed out (5sec) after sleeping ~100ms
|
||||||
|
EXPECT_FALSE(mono_time_is_timeout(mono_time, start, 5));
|
||||||
|
|
||||||
|
mono_time_free(mem, mono_time);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(MonoTime, CustomTime)
|
TEST(MonoTime, CustomTime)
|
||||||
{
|
{
|
||||||
const Memory *mem = system_memory();
|
const Memory *mem = system_memory();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user