Fri, 05 Oct 2012 13:23:25 +0200
moved allocator to seperate file
function signatures are now "generic" and not restricted to UcxMempool
9 | 1 | /* |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
2 | * tests of dlist implementation |
9 | 3 | */ |
4 | ||
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
5 | #include "dlist_tests.h" |
9 | 6 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
7 | UCX_TEST_IMPLEMENT(test_ucx_dlist_append) { |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
8 | UcxDlist *list = ucx_dlist_append(NULL, "Hello"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
9 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
10 | |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
11 | UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
12 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
13 | list = ucx_dlist_append(list, " World!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
14 | |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
15 | UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
16 | UCX_TEST_ASSERT(list->next->next == NULL, "failed"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
17 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
18 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
19 | ucx_dlist_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
20 | } |
9 | 21 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
22 | UCX_TEST_IMPLEMENT(test_ucx_dlist_prepend) { |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
23 | UcxDlist *list = ucx_dlist_prepend(NULL, " World!"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
24 | UCX_TEST_BEGIN |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
25 | |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
26 | list = ucx_dlist_prepend(list, "Hello"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
27 | |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
28 | UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
29 | UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
30 | UCX_TEST_ASSERT(list->next->next == NULL, "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
31 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
32 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
33 | ucx_dlist_free(list); |
24
e04822101291
changed make clean + added dlist_clone with copy test + added va_end statements to string.c
Mike Becker <universe@uap-core.de>
parents:
22
diff
changeset
|
34 | } |
e04822101291
changed make clean + added dlist_clone with copy test + added va_end statements to string.c
Mike Becker <universe@uap-core.de>
parents:
22
diff
changeset
|
35 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
36 | UCX_TEST_IMPLEMENT(test_ucx_dlist_equals) { |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
37 | UcxDlist *list = ucx_dlist_append(NULL, "Hello"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
38 | list = ucx_dlist_append(list, " World!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
39 | UcxDlist *list2 = ucx_dlist_prepend(NULL, " World!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
40 | list2 = ucx_dlist_prepend(list2, "Hello"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
41 | UcxDlist *list3 = ucx_dlist_prepend(NULL, " Welt!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
42 | list3 = ucx_dlist_prepend(list3, "Hallo"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
43 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
44 | |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
45 | UCX_TEST_ASSERT(ucx_dlist_equals(list, list2, cmp_string, NULL), "failed"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
46 | UCX_TEST_ASSERT(!ucx_dlist_equals(list, list3, cmp_string, NULL), "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
47 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
48 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
49 | ucx_dlist_free(list3); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
50 | ucx_dlist_free(list2); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
51 | ucx_dlist_free(list); |
18
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
52 | } |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
53 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
54 | UCX_TEST_IMPLEMENT(test_ucx_dlist_concat) { |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
55 | UcxDlist *list = ucx_dlist_append(NULL, "Hello"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
56 | UcxDlist *list2 = ucx_dlist_prepend(NULL, " World!"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
57 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
58 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
59 | list = ucx_dlist_concat(list, list2); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
60 | |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
61 | UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
62 | UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
63 | UCX_TEST_ASSERT(list->next->next == NULL, "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
64 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
65 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
66 | ucx_dlist_free(list); |
24
e04822101291
changed make clean + added dlist_clone with copy test + added va_end statements to string.c
Mike Becker <universe@uap-core.de>
parents:
22
diff
changeset
|
67 | } |
e04822101291
changed make clean + added dlist_clone with copy test + added va_end statements to string.c
Mike Becker <universe@uap-core.de>
parents:
22
diff
changeset
|
68 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
69 | UCX_TEST_IMPLEMENT(test_ucx_dlist_size) { |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
70 | UcxDlist *list = ucx_dlist_append(NULL, "This "); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
71 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
72 | list = ucx_dlist_append(list, "list "); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
73 | list = ucx_dlist_append(list, "has "); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
74 | list = ucx_dlist_append(list, "size "); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
75 | list = ucx_dlist_append(list, "5!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
76 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
77 | UCX_TEST_ASSERT(ucx_dlist_size(list) == 5, "failed"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
78 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
79 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
80 | ucx_dlist_free(list); |
9 | 81 | } |
82 | ||
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
83 | UCX_TEST_IMPLEMENT(test_ucx_dlist_first) { |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
84 | UcxDlist *list = ucx_dlist_append(NULL, "Find "); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
85 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
86 | list = ucx_dlist_append(list, "the "); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
87 | list = ucx_dlist_append(list, "first!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
88 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
89 | char* first = (char*) (ucx_dlist_first(list)->data); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
90 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
91 | UCX_TEST_ASSERT(strncmp(first, "Find ", 5) == 0, "failed"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
92 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
93 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
94 | ucx_dlist_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
95 | } |
9 | 96 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
97 | UCX_TEST_IMPLEMENT(test_ucx_dlist_last) { |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
98 | UcxDlist *list = ucx_dlist_append(NULL, "Find "); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
99 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
100 | list = ucx_dlist_append(list, "the "); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
101 | list = ucx_dlist_append(list, "last!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
102 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
103 | char* last = (char*) (ucx_dlist_last(list)->data); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
104 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
105 | UCX_TEST_ASSERT(strncmp(last, "last!", 5) == 0, "failed"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
106 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
107 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
108 | ucx_dlist_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
109 | } |
24
e04822101291
changed make clean + added dlist_clone with copy test + added va_end statements to string.c
Mike Becker <universe@uap-core.de>
parents:
22
diff
changeset
|
110 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
111 | UCX_TEST_IMPLEMENT(test_ucx_dlist_get) { |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
112 | UcxDlist *list = ucx_dlist_append(NULL, "Find "); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
113 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
114 | list = ucx_dlist_append(list, "the "); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
115 | list = ucx_dlist_append(list, "mid!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
116 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
117 | char* mid = (char*) (ucx_dlist_get(list, 1)->data); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
118 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
119 | UCX_TEST_ASSERT(strncmp(mid, "the ", 4) == 0, "failed"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
120 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
121 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
122 | ucx_dlist_free(list); |
9 | 123 | } |
11 | 124 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
125 | UCX_TEST_IMPLEMENT(test_ucx_dlist_remove) { |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
126 | UcxDlist *list = ucx_dlist_append(NULL, "Hello"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
127 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
128 | list = ucx_dlist_append(list, " fucking"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
129 | list = ucx_dlist_append(list, " World!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
130 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
131 | list = ucx_dlist_remove(list, ucx_dlist_get(list, 1)); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
132 | |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
133 | UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
134 | UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
135 | UCX_TEST_ASSERT(list->next->next == NULL, "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
136 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
137 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
138 | ucx_dlist_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
139 | } |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
140 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
141 | UCX_TEST_IMPLEMENT(test_ucx_dlist_clone) { |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
142 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
143 | char *hello = (char*)malloc(6); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
144 | char *world = (char*)malloc(8); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
145 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
146 | memcpy(hello, "Hello", 6); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
147 | memcpy(world, " World!", 8); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
148 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
149 | UcxDlist *list = ucx_dlist_append(NULL, hello); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
150 | list = ucx_dlist_append(list, world); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
151 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
152 | UcxDlist *copy = ucx_dlist_clone(list, copy_string, NULL); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
153 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
154 | |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
155 | UCX_TEST_ASSERT(ucx_dlist_equals(list, copy, cmp_string, NULL), "failed"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
156 | UCX_TEST_ASSERT(hello != copy->data, "first element is no copy"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
157 | UCX_TEST_ASSERT(world != copy->next->data, "second element is no copy"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
158 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
159 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
160 | free(copy->next->data); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
161 | free(copy->data); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
162 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
163 | free(world); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
164 | free(hello); |
30 | 165 | ucx_dlist_free(list); |
166 | ucx_dlist_free(copy); | |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
167 | } |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
168 | |
36
a9d656e4f7ce
changed API of sort algorithms (no further hint for the algorithms used in preparation for the upcomming change from qsort to natural merge sort)
Mike Becker <universe@uap-core.de>
parents:
35
diff
changeset
|
169 | UCX_TEST_IMPLEMENT(test_ucx_dlist_sort) { |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
170 | UcxDlist *list = ucx_dlist_append(NULL, "this"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
171 | list = ucx_dlist_append(list, "is"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
172 | list = ucx_dlist_append(list, "a"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
173 | list = ucx_dlist_append(list, "test"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
174 | list = ucx_dlist_append(list, "for"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
175 | list = ucx_dlist_append(list, "partial"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
176 | list = ucx_dlist_append(list, "correctness"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
177 | |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
178 | UcxDlist *expected = ucx_dlist_append(NULL, "a"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
179 | expected = ucx_dlist_append(expected, "correctness"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
180 | expected = ucx_dlist_append(expected, "for"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
181 | expected = ucx_dlist_append(expected, "is"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
182 | expected = ucx_dlist_append(expected, "partial"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
183 | expected = ucx_dlist_append(expected, "test"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
184 | expected = ucx_dlist_append(expected, "this"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
185 | |
36
a9d656e4f7ce
changed API of sort algorithms (no further hint for the algorithms used in preparation for the upcomming change from qsort to natural merge sort)
Mike Becker <universe@uap-core.de>
parents:
35
diff
changeset
|
186 | list = ucx_dlist_sort(list, cmp_string, NULL); |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
187 | |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
188 | UCX_TEST_BEGIN |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
189 | UCX_TEST_ASSERT( |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
190 | ucx_dlist_equals(list, expected, cmp_string, NULL), "failed"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
191 | UcxDlist *l = list; |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
192 | UCX_TEST_ASSERT(l->prev == NULL, "prev field of first entry is not null"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
193 | while (l->next != NULL) { |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
194 | UCX_TEST_ASSERT(l->next->prev == l, "prev pointer corrupted"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
195 | l = l->next; |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
196 | } |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
197 | UCX_TEST_END |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
198 | |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
199 | ucx_dlist_free(expected); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
200 | ucx_dlist_free(list); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
201 | } |