summaryrefslogtreecommitdiff
path: root/toxcore/mono_time_test.cc
blob: 5ad913224dbb42fff4e7dbe6e5c32d2e9793a2aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "mono_time.h"

#include <gtest/gtest.h>

namespace {

TEST(Util, UnixTimeIncreasesOverTime) {
  unix_time_update();
  uint64_t const start = unix_time();

  while (start == unix_time()) {
    unix_time_update();
  }

  uint64_t const end = unix_time();
  EXPECT_GT(end, start);
}

TEST(Util, IsTimeout) {
  uint64_t const start = unix_time();
  EXPECT_FALSE(is_timeout(start, 1));

  while (start == unix_time()) {
    unix_time_update();
  }

  EXPECT_TRUE(is_timeout(start, 1));
}

}  // namespace