diff -r 0dcd2ca2a223 -r fdabd1240b69 test/dlist_tests.c --- a/test/dlist_tests.c Fri Jun 01 12:35:30 2012 +0200 +++ b/test/dlist_tests.c Wed Aug 15 19:32:29 2012 +0200 @@ -165,3 +165,37 @@ ucx_dlist_free(list); ucx_dlist_free(copy); } + +UCX_TEST_IMPLEMENT(test_ucx_dlist_qsort) { + UcxDlist *list = ucx_dlist_append(NULL, "this"); + list = ucx_dlist_append(list, "is"); + list = ucx_dlist_append(list, "a"); + list = ucx_dlist_append(list, "test"); + list = ucx_dlist_append(list, "for"); + list = ucx_dlist_append(list, "partial"); + list = ucx_dlist_append(list, "correctness"); + + UcxDlist *expected = ucx_dlist_append(NULL, "a"); + expected = ucx_dlist_append(expected, "correctness"); + expected = ucx_dlist_append(expected, "for"); + expected = ucx_dlist_append(expected, "is"); + expected = ucx_dlist_append(expected, "partial"); + expected = ucx_dlist_append(expected, "test"); + expected = ucx_dlist_append(expected, "this"); + + list = ucx_dlist_qsort(list, cmp_string, NULL); + + UCX_TEST_BEGIN + UCX_TEST_ASSERT( + ucx_dlist_equals(list, expected, cmp_string, NULL), "failed"); + UcxDlist *l = list; + UCX_TEST_ASSERT(l->prev == NULL, "prev field of first entry is not null"); + while (l->next != NULL) { + UCX_TEST_ASSERT(l->next->prev == l, "prev pointer corrupted"); + l = l->next; + } + UCX_TEST_END + + ucx_dlist_free(expected); + ucx_dlist_free(list); +}