test/dlist_tests.c

changeset 35
fdabd1240b69
parent 33
9c219a62070d
child 36
a9d656e4f7ce
equal deleted inserted replaced
34:0dcd2ca2a223 35:fdabd1240b69
163 free(world); 163 free(world);
164 free(hello); 164 free(hello);
165 ucx_dlist_free(list); 165 ucx_dlist_free(list);
166 ucx_dlist_free(copy); 166 ucx_dlist_free(copy);
167 } 167 }
168
169 UCX_TEST_IMPLEMENT(test_ucx_dlist_qsort) {
170 UcxDlist *list = ucx_dlist_append(NULL, "this");
171 list = ucx_dlist_append(list, "is");
172 list = ucx_dlist_append(list, "a");
173 list = ucx_dlist_append(list, "test");
174 list = ucx_dlist_append(list, "for");
175 list = ucx_dlist_append(list, "partial");
176 list = ucx_dlist_append(list, "correctness");
177
178 UcxDlist *expected = ucx_dlist_append(NULL, "a");
179 expected = ucx_dlist_append(expected, "correctness");
180 expected = ucx_dlist_append(expected, "for");
181 expected = ucx_dlist_append(expected, "is");
182 expected = ucx_dlist_append(expected, "partial");
183 expected = ucx_dlist_append(expected, "test");
184 expected = ucx_dlist_append(expected, "this");
185
186 list = ucx_dlist_qsort(list, cmp_string, NULL);
187
188 UCX_TEST_BEGIN
189 UCX_TEST_ASSERT(
190 ucx_dlist_equals(list, expected, cmp_string, NULL), "failed");
191 UcxDlist *l = list;
192 UCX_TEST_ASSERT(l->prev == NULL, "prev field of first entry is not null");
193 while (l->next != NULL) {
194 UCX_TEST_ASSERT(l->next->prev == l, "prev pointer corrupted");
195 l = l->next;
196 }
197 UCX_TEST_END
198
199 ucx_dlist_free(expected);
200 ucx_dlist_free(list);
201 }

mercurial