summaryrefslogtreecommitdiff
path: root/toxcore/mono_time_test.cc
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-01 23:02:13 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-08-16 21:01:43 +0000
commitd6d305feeb76735ee4b4e14c6bca737a5482bc19 (patch)
tree99005c635a452245006b3b5de44f1dd80da9f77f /toxcore/mono_time_test.cc
parent54066f338f185f2fbd6694d9a4877f42cbfa21c8 (diff)
Use per-instance `Mono_Time` for Messenger and onion.
Diffstat (limited to 'toxcore/mono_time_test.cc')
-rw-r--r--toxcore/mono_time_test.cc28
1 files changed, 18 insertions, 10 deletions
diff --git a/toxcore/mono_time_test.cc b/toxcore/mono_time_test.cc
index 5ad91322..3e241b17 100644
--- a/toxcore/mono_time_test.cc
+++ b/toxcore/mono_time_test.cc
@@ -5,26 +5,34 @@
5namespace { 5namespace {
6 6
7TEST(Util, UnixTimeIncreasesOverTime) { 7TEST(Util, UnixTimeIncreasesOverTime) {
8 unix_time_update(); 8 Mono_Time *mono_time = mono_time_new();
9 uint64_t const start = unix_time();
10 9
11 while (start == unix_time()) { 10 mono_time_update(mono_time);
12 unix_time_update(); 11 uint64_t const start = mono_time_get(mono_time);
12
13 while (start == mono_time_get(mono_time)) {
14 mono_time_update(mono_time);
13 } 15 }
14 16
15 uint64_t const end = unix_time(); 17 uint64_t const end = mono_time_get(mono_time);
16 EXPECT_GT(end, start); 18 EXPECT_GT(end, start);
19
20 mono_time_free(mono_time);
17} 21}
18 22
19TEST(Util, IsTimeout) { 23TEST(Util, IsTimeout) {
20 uint64_t const start = unix_time(); 24 Mono_Time *mono_time = mono_time_new();
21 EXPECT_FALSE(is_timeout(start, 1));
22 25
23 while (start == unix_time()) { 26 uint64_t const start = mono_time_get(mono_time);
24 unix_time_update(); 27 EXPECT_FALSE(mono_time_is_timeout(mono_time, start, 1));
28
29 while (start == mono_time_get(mono_time)) {
30 mono_time_update(mono_time);
25 } 31 }
26 32
27 EXPECT_TRUE(is_timeout(start, 1)); 33 EXPECT_TRUE(mono_time_is_timeout(mono_time, start, 1));
34
35 mono_time_free(mono_time);
28} 36}
29 37
30} // namespace 38} // namespace