test/list_tests.c

changeset 308
d6f580621512
parent 259
2f5dea574a75
child 323
b8c49e7a1dba
     1.1 --- a/test/list_tests.c	Mon May 14 17:56:03 2018 +0200
     1.2 +++ b/test/list_tests.c	Mon May 14 18:12:14 2018 +0200
     1.3 @@ -70,14 +70,14 @@
     1.4  
     1.5  UCX_TEST(test_ucx_list_append_once) {
     1.6      UcxList *list, *first;
     1.7 -    list = first = ucx_list_append_once(NULL, (void*)"Hello", ucx_strcmp, NULL);
     1.8 +    list = first = ucx_list_append_once(NULL, (void*)"Hello", ucx_cmp_str, NULL);
     1.9      UCX_TEST_BEGIN
    1.10      
    1.11      UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    1.12              "failed");
    1.13      
    1.14 -    list = ucx_list_append_once(list, (void*)"Hello", ucx_strcmp, NULL);
    1.15 -    list = ucx_list_append_once(list, (void*)" World!", ucx_strcmp, NULL);
    1.16 +    list = ucx_list_append_once(list, (void*)"Hello", ucx_cmp_str, NULL);
    1.17 +    list = ucx_list_append_once(list, (void*)" World!", ucx_cmp_str, NULL);
    1.18      
    1.19      UCX_TEST_ASSERT(list == first, "does not return first element");
    1.20      UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    1.21 @@ -102,8 +102,8 @@
    1.22      list4 = ucx_list_prepend(list4, (void*)"Hello");
    1.23      UCX_TEST_BEGIN
    1.24      
    1.25 -    UCX_TEST_ASSERT(ucx_list_equals(list, list4, ucx_strcmp, NULL), "failed");
    1.26 -    UCX_TEST_ASSERT(!ucx_list_equals(list, list3, ucx_strcmp, NULL), "failed");
    1.27 +    UCX_TEST_ASSERT(ucx_list_equals(list, list4, ucx_cmp_str, NULL), "failed");
    1.28 +    UCX_TEST_ASSERT(!ucx_list_equals(list, list3, ucx_cmp_str, NULL), "failed");
    1.29      UCX_TEST_ASSERT(ucx_list_equals(list, list2, NULL, NULL), "failed");
    1.30      
    1.31      UCX_TEST_END
    1.32 @@ -245,15 +245,15 @@
    1.33      
    1.34      UCX_TEST_BEGIN
    1.35      
    1.36 -    UCX_TEST_ASSERT(ucx_list_find(l,(void*)"some ",ucx_strcmp,NULL) == 1,
    1.37 +    UCX_TEST_ASSERT(ucx_list_find(l,(void*)"some ",ucx_cmp_str,NULL) == 1,
    1.38          "doesn't find string");
    1.39 -    UCX_TEST_ASSERT(ucx_list_find(l,(void*)"a",ucx_strcmp,NULL) == -1,
    1.40 +    UCX_TEST_ASSERT(ucx_list_find(l,(void*)"a",ucx_cmp_str,NULL) == -1,
    1.41          "finds non-existing string");
    1.42      
    1.43      UCX_TEST_ASSERT(ucx_list_find(l,(void*)teststr,NULL,NULL) == 2,
    1.44          "doesn't find integer without cmp_func");
    1.45      
    1.46 -    UCX_TEST_ASSERT(ucx_list_find(NULL, (void*)"some ",ucx_strcmp,NULL) == -1,
    1.47 +    UCX_TEST_ASSERT(ucx_list_find(NULL, (void*)"some ",ucx_cmp_str,NULL) == -1,
    1.48          "empty list");
    1.49      
    1.50      UCX_TEST_END
    1.51 @@ -267,9 +267,9 @@
    1.52      
    1.53      UCX_TEST_BEGIN
    1.54      
    1.55 -    UCX_TEST_ASSERT(ucx_list_contains(l,(void*)"a ",ucx_strcmp,NULL),
    1.56 +    UCX_TEST_ASSERT(ucx_list_contains(l,(void*)"a ",ucx_cmp_str,NULL),
    1.57          "false negative");
    1.58 -    UCX_TEST_ASSERT(!ucx_list_contains(l,(void*)"a",ucx_strcmp,NULL),
    1.59 +    UCX_TEST_ASSERT(!ucx_list_contains(l,(void*)"a",ucx_cmp_str,NULL),
    1.60          "false positive");
    1.61      
    1.62      UCX_TEST_END
    1.63 @@ -356,7 +356,7 @@
    1.64      UcxList *copy = ucx_list_clone(list, ucx_strcpy, NULL);
    1.65      UCX_TEST_BEGIN
    1.66  
    1.67 -    UCX_TEST_ASSERT(ucx_list_equals(list, copy, ucx_strcmp, NULL), "failed");
    1.68 +    UCX_TEST_ASSERT(ucx_list_equals(list, copy, ucx_cmp_str, NULL), "failed");
    1.69      UCX_TEST_ASSERT(hello != copy->data, "first element is no copy");
    1.70      UCX_TEST_ASSERT(world != copy->next->data, "second element is no copy");
    1.71  
    1.72 @@ -405,11 +405,11 @@
    1.73      expected = ucx_list_append(expected, (void*)"this");
    1.74      expected = ucx_list_append(expected, (void*)"this");
    1.75  
    1.76 -    list = ucx_list_sort(list, ucx_strcmp, NULL);
    1.77 +    list = ucx_list_sort(list, ucx_cmp_str, NULL);
    1.78  
    1.79      UCX_TEST_BEGIN
    1.80      UCX_TEST_ASSERT(
    1.81 -            ucx_list_equals(list, expected, ucx_strcmp, NULL), "failed");
    1.82 +            ucx_list_equals(list, expected, ucx_cmp_str, NULL), "failed");
    1.83      UCX_TEST_ASSERT(ucx_list_size(list) == 16, "list has now a wrong size");
    1.84      UcxList *l = list;
    1.85      UCX_TEST_ASSERT(l->prev == NULL, "prev field of first entry is not null");
    1.86 @@ -417,7 +417,7 @@
    1.87          UCX_TEST_ASSERT(l->next->prev == l, "next or prev pointer corrupted");
    1.88          l = l->next;
    1.89      }
    1.90 -    UCX_TEST_ASSERT(!ucx_list_sort(NULL, ucx_strcmp, NULL),
    1.91 +    UCX_TEST_ASSERT(!ucx_list_sort(NULL, ucx_cmp_str, NULL),
    1.92          "failed to sort empty list");
    1.93      UCX_TEST_END
    1.94  

mercurial