test/list_tests.c

changeset 308
d6f580621512
parent 259
2f5dea574a75
child 323
b8c49e7a1dba
--- a/test/list_tests.c	Mon May 14 17:56:03 2018 +0200
+++ b/test/list_tests.c	Mon May 14 18:12:14 2018 +0200
@@ -70,14 +70,14 @@
 
 UCX_TEST(test_ucx_list_append_once) {
     UcxList *list, *first;
-    list = first = ucx_list_append_once(NULL, (void*)"Hello", ucx_strcmp, NULL);
+    list = first = ucx_list_append_once(NULL, (void*)"Hello", ucx_cmp_str, NULL);
     UCX_TEST_BEGIN
     
     UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
             "failed");
     
-    list = ucx_list_append_once(list, (void*)"Hello", ucx_strcmp, NULL);
-    list = ucx_list_append_once(list, (void*)" World!", ucx_strcmp, NULL);
+    list = ucx_list_append_once(list, (void*)"Hello", ucx_cmp_str, NULL);
+    list = ucx_list_append_once(list, (void*)" World!", ucx_cmp_str, NULL);
     
     UCX_TEST_ASSERT(list == first, "does not return first element");
     UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
@@ -102,8 +102,8 @@
     list4 = ucx_list_prepend(list4, (void*)"Hello");
     UCX_TEST_BEGIN
     
-    UCX_TEST_ASSERT(ucx_list_equals(list, list4, ucx_strcmp, NULL), "failed");
-    UCX_TEST_ASSERT(!ucx_list_equals(list, list3, ucx_strcmp, NULL), "failed");
+    UCX_TEST_ASSERT(ucx_list_equals(list, list4, ucx_cmp_str, NULL), "failed");
+    UCX_TEST_ASSERT(!ucx_list_equals(list, list3, ucx_cmp_str, NULL), "failed");
     UCX_TEST_ASSERT(ucx_list_equals(list, list2, NULL, NULL), "failed");
     
     UCX_TEST_END
@@ -245,15 +245,15 @@
     
     UCX_TEST_BEGIN
     
-    UCX_TEST_ASSERT(ucx_list_find(l,(void*)"some ",ucx_strcmp,NULL) == 1,
+    UCX_TEST_ASSERT(ucx_list_find(l,(void*)"some ",ucx_cmp_str,NULL) == 1,
         "doesn't find string");
-    UCX_TEST_ASSERT(ucx_list_find(l,(void*)"a",ucx_strcmp,NULL) == -1,
+    UCX_TEST_ASSERT(ucx_list_find(l,(void*)"a",ucx_cmp_str,NULL) == -1,
         "finds non-existing string");
     
     UCX_TEST_ASSERT(ucx_list_find(l,(void*)teststr,NULL,NULL) == 2,
         "doesn't find integer without cmp_func");
     
-    UCX_TEST_ASSERT(ucx_list_find(NULL, (void*)"some ",ucx_strcmp,NULL) == -1,
+    UCX_TEST_ASSERT(ucx_list_find(NULL, (void*)"some ",ucx_cmp_str,NULL) == -1,
         "empty list");
     
     UCX_TEST_END
@@ -267,9 +267,9 @@
     
     UCX_TEST_BEGIN
     
-    UCX_TEST_ASSERT(ucx_list_contains(l,(void*)"a ",ucx_strcmp,NULL),
+    UCX_TEST_ASSERT(ucx_list_contains(l,(void*)"a ",ucx_cmp_str,NULL),
         "false negative");
-    UCX_TEST_ASSERT(!ucx_list_contains(l,(void*)"a",ucx_strcmp,NULL),
+    UCX_TEST_ASSERT(!ucx_list_contains(l,(void*)"a",ucx_cmp_str,NULL),
         "false positive");
     
     UCX_TEST_END
@@ -356,7 +356,7 @@
     UcxList *copy = ucx_list_clone(list, ucx_strcpy, NULL);
     UCX_TEST_BEGIN
 
-    UCX_TEST_ASSERT(ucx_list_equals(list, copy, ucx_strcmp, NULL), "failed");
+    UCX_TEST_ASSERT(ucx_list_equals(list, copy, ucx_cmp_str, NULL), "failed");
     UCX_TEST_ASSERT(hello != copy->data, "first element is no copy");
     UCX_TEST_ASSERT(world != copy->next->data, "second element is no copy");
 
@@ -405,11 +405,11 @@
     expected = ucx_list_append(expected, (void*)"this");
     expected = ucx_list_append(expected, (void*)"this");
 
-    list = ucx_list_sort(list, ucx_strcmp, NULL);
+    list = ucx_list_sort(list, ucx_cmp_str, NULL);
 
     UCX_TEST_BEGIN
     UCX_TEST_ASSERT(
-            ucx_list_equals(list, expected, ucx_strcmp, NULL), "failed");
+            ucx_list_equals(list, expected, ucx_cmp_str, NULL), "failed");
     UCX_TEST_ASSERT(ucx_list_size(list) == 16, "list has now a wrong size");
     UcxList *l = list;
     UCX_TEST_ASSERT(l->prev == NULL, "prev field of first entry is not null");
@@ -417,7 +417,7 @@
         UCX_TEST_ASSERT(l->next->prev == l, "next or prev pointer corrupted");
         l = l->next;
     }
-    UCX_TEST_ASSERT(!ucx_list_sort(NULL, ucx_strcmp, NULL),
+    UCX_TEST_ASSERT(!ucx_list_sort(NULL, ucx_cmp_str, NULL),
         "failed to sort empty list");
     UCX_TEST_END
 

mercurial