summaryrefslogtreecommitdiff
path: root/toxcore/util_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/util_test.cpp')
-rw-r--r--toxcore/util_test.cpp55
1 files changed, 0 insertions, 55 deletions
diff --git a/toxcore/util_test.cpp b/toxcore/util_test.cpp
deleted file mode 100644
index 8de63848..00000000
--- a/toxcore/util_test.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
1#include "util.h"
2
3#include "crypto_core.h"
4
5#include <gtest/gtest.h>
6
7TEST(Util, UnixTimeIncreasesOverTime)
8{
9 unix_time_update();
10 uint64_t const start = unix_time();
11
12 while (start == unix_time()) {
13 unix_time_update();
14 }
15
16 uint64_t const end = unix_time();
17 EXPECT_GT(end, start);
18}
19
20TEST(Util, IsTimeout)
21{
22 uint64_t const start = unix_time();
23 EXPECT_FALSE(is_timeout(start, 1));
24
25 while (start == unix_time()) {
26 unix_time_update();
27 }
28
29 EXPECT_TRUE(is_timeout(start, 1));
30}
31
32TEST(Util, TwoRandomIdsAreNotEqual)
33{
34 uint8_t pk1[CRYPTO_PUBLIC_KEY_SIZE];
35 uint8_t sk1[CRYPTO_SECRET_KEY_SIZE];
36 uint8_t pk2[CRYPTO_PUBLIC_KEY_SIZE];
37 uint8_t sk2[CRYPTO_SECRET_KEY_SIZE];
38
39 crypto_new_keypair(pk1, sk1);
40 crypto_new_keypair(pk2, sk2);
41
42 EXPECT_FALSE(id_equal(pk1, pk2));
43}
44
45TEST(Util, IdCopyMakesKeysEqual)
46{
47 uint8_t pk1[CRYPTO_PUBLIC_KEY_SIZE];
48 uint8_t sk1[CRYPTO_SECRET_KEY_SIZE];
49 uint8_t pk2[CRYPTO_PUBLIC_KEY_SIZE] = {0};
50
51 crypto_new_keypair(pk1, sk1);
52 id_copy(pk2, pk1);
53
54 EXPECT_TRUE(id_equal(pk1, pk2));
55}