test/dlist_tests.c

changeset 35
fdabd1240b69
parent 33
9c219a62070d
child 36
a9d656e4f7ce
     1.1 --- a/test/dlist_tests.c	Fri Jun 01 12:35:30 2012 +0200
     1.2 +++ b/test/dlist_tests.c	Wed Aug 15 19:32:29 2012 +0200
     1.3 @@ -165,3 +165,37 @@
     1.4      ucx_dlist_free(list);
     1.5      ucx_dlist_free(copy);
     1.6  }
     1.7 +
     1.8 +UCX_TEST_IMPLEMENT(test_ucx_dlist_qsort) {
     1.9 +    UcxDlist *list = ucx_dlist_append(NULL, "this");
    1.10 +    list = ucx_dlist_append(list, "is");
    1.11 +    list = ucx_dlist_append(list, "a");
    1.12 +    list = ucx_dlist_append(list, "test");
    1.13 +    list = ucx_dlist_append(list, "for");
    1.14 +    list = ucx_dlist_append(list, "partial");
    1.15 +    list = ucx_dlist_append(list, "correctness");
    1.16 +
    1.17 +    UcxDlist *expected = ucx_dlist_append(NULL, "a");
    1.18 +    expected = ucx_dlist_append(expected, "correctness");
    1.19 +    expected = ucx_dlist_append(expected, "for");
    1.20 +    expected = ucx_dlist_append(expected, "is");
    1.21 +    expected = ucx_dlist_append(expected, "partial");
    1.22 +    expected = ucx_dlist_append(expected, "test");
    1.23 +    expected = ucx_dlist_append(expected, "this");
    1.24 +
    1.25 +    list = ucx_dlist_qsort(list, cmp_string, NULL);
    1.26 +
    1.27 +    UCX_TEST_BEGIN
    1.28 +    UCX_TEST_ASSERT(
    1.29 +            ucx_dlist_equals(list, expected, cmp_string, NULL), "failed");
    1.30 +    UcxDlist *l = list;
    1.31 +    UCX_TEST_ASSERT(l->prev == NULL, "prev field of first entry is not null");
    1.32 +    while (l->next != NULL) {
    1.33 +        UCX_TEST_ASSERT(l->next->prev == l, "prev pointer corrupted");
    1.34 +        l = l->next;
    1.35 +    }
    1.36 +    UCX_TEST_END
    1.37 +
    1.38 +    ucx_dlist_free(expected);
    1.39 +    ucx_dlist_free(list);
    1.40 +}

mercurial