renames ucx_strcmp() to ucx_cmp_str()

Mon, 14 May 2018 18:12:14 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 14 May 2018 18:12:14 +0200
changeset 308
d6f580621512
parent 306
90b6d69bb499
child 309
4355c6039a28

renames ucx_strcmp() to ucx_cmp_str()

src/ucx/avl.h file | annotate | diff | comparison | revisions
src/ucx/utils.h file | annotate | diff | comparison | revisions
src/utils.c file | annotate | diff | comparison | revisions
test/list_tests.c file | annotate | diff | comparison | revisions
--- a/src/ucx/avl.h	Mon May 14 17:56:03 2018 +0200
+++ b/src/ucx/avl.h	Mon May 14 18:12:14 2018 +0200
@@ -125,7 +125,7 @@
  * 
  * The cmpfunc should be capable of comparing two keys within this AVL tree.
  * So if you want to use null terminated strings as keys, you could use the
- * ucx_strcmp() function here.
+ * ucx_cmp_str() function here.
  * 
  * @param cmpfunc the compare function that shall be used
  * @param allocator the UcxAllocator that shall be used
--- a/src/ucx/utils.h	Mon May 14 17:56:03 2018 +0200
+++ b/src/ucx/utils.h	Mon May 14 18:12:14 2018 +0200
@@ -144,7 +144,7 @@
  * @param data omitted
  * @return the result of strcmp(s1, s2)
  */
-int ucx_strcmp(const void *s1, const void *s2, void *data);
+int ucx_cmp_str(const void *s1, const void *s2, void *data);
 
 /**
  * Wraps the strncmp function.
--- a/src/utils.c	Mon May 14 17:56:03 2018 +0200
+++ b/src/utils.c	Mon May 14 18:12:14 2018 +0200
@@ -88,7 +88,7 @@
 
 /* COMPARE FUNCTIONS */
 
-int ucx_strcmp(const void *s1, const void *s2, void *data) {
+int ucx_cmp_str(const void *s1, const void *s2, void *data) {
     return strcmp((const char*)s1, (const char*)s2);
 }
 
--- 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