-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathUtilsTest.cc
65 lines (48 loc) · 1.21 KB
/
UtilsTest.cc
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "KcpuvTest.h"
#include <iostream>
namespace kcpuv_test {
using namespace ::std;
using namespace ::testing;
class UtilsTest : public Test {
protected:
UtilsTest(){};
};
TEST_F(UtilsTest, kcpuv_link) {
kcpuv_link *head = kcpuv_link_create(NULL);
kcpuv_link *current = head;
kcpuv_link *ptr;
for (int i = 0; i < 3; i += 1) {
int *node = new int;
*node = i;
kcpuv_link *link = kcpuv_link_create(node);
kcpuv_link_add(head, link);
}
for (int i = 0; i < 3; i += 1) {
current = current->next;
EXPECT_EQ(*(static_cast<int *>(current->node)), i);
}
current = head->next->next;
ptr = kcpuv_link_get_pointer(head, current->node);
free(ptr);
free(current->node);
current = head->next;
EXPECT_EQ(*(static_cast<int *>(current->node)), 0);
current = current->next;
EXPECT_EQ(*(static_cast<int *>(current->node)), 2);
current = NULL;
ptr = kcpuv_link_get_pointer(head, current);
free(ptr);
kcpuv_link *next = NULL;
current = head;
while (current != NULL) {
next = current->next;
free(current->node);
free(current);
current = next;
}
}
TEST_F(UtilsTest, iclock) {
IUINT32 time = iclock();
EXPECT_TRUE(time);
}
} // namespace kcpuv_test