tests/test_tree.c

changeset 890
54565fd74e74
parent 871
e29c1f96646d
--- a/tests/test_tree.c	Wed Sep 18 00:02:18 2024 +0200
+++ b/tests/test_tree.c	Sat Sep 28 15:47:28 2024 +0200
@@ -55,11 +55,11 @@
     struct tree_node_file *prev;
     struct tree_node_file *children;
     struct tree_node_file *last_child;
-    char const *path;
+    const char *path;
 } tree_node_file;
 
 static void *create_tree_node_file(
-        void const *dptr,
+        const void *dptr,
         void *allocator) {
     if (allocator == NULL) allocator = cxDefaultAllocator;
 
@@ -76,9 +76,9 @@
     return node;
 }
 
-static int tree_node_file_search(void const *l, void const *r) {
-    tree_node_file const *left = l;
-    tree_node_file const *right = r;
+static int tree_node_file_search(const void *l, const void *r) {
+    const tree_node_file *left = l;
+    const tree_node_file *right = r;
     size_t len1 = strlen(left->path);
     size_t len2 = strlen(right->path);
     if (len1 <= len2) {
@@ -371,9 +371,9 @@
     }
 }
 
-static int test_tree_search_function(void const *n, void const *d) {
-    tree_node const *node = n;
-    int data = *((int const*)d);
+static int test_tree_search_function(const void *n, const void *d) {
+    const tree_node *node = n;
+    int data = *((const int *)d);
 
     if (data < node->data) return -1;
     else if (data == node->data) return 0;
@@ -601,7 +601,7 @@
 
 typedef struct test_xml_node {
     struct tree_node base;
-    char const* name;
+    const char *name;
 } test_xml_node;
 
 CX_TEST(test_tree_iterator_xml) {
@@ -649,7 +649,7 @@
     cx_tree_link(&target, &target_dependencies, tree_node_layout);
     cx_tree_link(&target_feature, &target_feature_dependencies, tree_node_layout);
 
-    char const *expected =
+    const char *expected =
             "<project><config><var></var><var></var><var></var></config>"
             "<dependency><make></make></dependency><dependency><lang></lang><make></make></dependency>"
             "<target><feature><dependencies></dependencies></feature><dependencies></dependencies></target></project>";
@@ -1067,10 +1067,10 @@
         );
         CX_TEST_ASSERT(result == 0);
         CX_TEST_ASSERT(foo != NULL);
-        char const *bar_path = "/home/foo/bar/";
+        const char *bar_path = "/home/foo/bar/";
         void *failed;
         size_t added = cx_tree_add_array(
-                bar_path, 1, sizeof(char const *),
+                bar_path, 1, sizeof(const char *),
                 tree_node_file_search,
                 create_tree_node_file, alloc,
                 &failed, &root,
@@ -1166,7 +1166,7 @@
         free(node);
         node = NULL;
         size_t added = cx_tree_add_array(
-                "/", 1, sizeof(char const *),
+                "/", 1, sizeof(const char *),
                 tree_node_file_search,
                 create_tree_node_file, NULL,
                 (void **) &node, &root,
@@ -1256,7 +1256,7 @@
     CX_TEST_DO {
         void *failed;
 
-        char const *paths[] = {
+        const char *paths[] = {
                 "/home/foo/",
                 "/home/foo/bar",
                 "/usr/lib64/",
@@ -1264,7 +1264,7 @@
         };
 
         size_t processed = cx_tree_add_array(
-                paths, 4, sizeof(char const *),
+                paths, 4, sizeof(const char *),
                 tree_node_file_search,
                 create_tree_node_file, alloc,
                 &failed, &root, tree_node_file_layout
@@ -1311,7 +1311,7 @@
     CX_TEST_DO {
         tree_node_file *failed;
 
-        char const *paths[] = {
+        const char *paths[] = {
                 "/mnt/sdcard/",
                 "/mnt/foo/",
                 "/mnt/sdcard/",
@@ -1320,7 +1320,7 @@
         };
 
         size_t processed = cx_tree_add_array(
-                paths, 5, sizeof(char const *),
+                paths, 5, sizeof(const char *),
                 tree_node_file_search,
                 create_tree_node_file, alloc,
                 (void **) &failed, &root, tree_node_file_layout
@@ -1358,13 +1358,13 @@
 }
 
 static CX_TEST_SUBROUTINE(test_tree_add_create_from_array_impl,
-                          CxAllocator *alloc, char const **paths) {
+                          CxAllocator *alloc, const char **paths) {
     tree_node_file root = {0};
     root.path = "/";
 
     void *failed;
     size_t processed = cx_tree_add_array(
-            paths, 10, sizeof(char const *),
+            paths, 10, sizeof(const char *),
             tree_node_file_search,
             create_tree_node_file, alloc,
             &failed, &root, tree_node_file_layout
@@ -1373,7 +1373,7 @@
     CX_TEST_ASSERT(failed == NULL);
     CX_TEST_ASSERT(processed == 10);
 
-    char const *exp_order[] = {
+    const char *exp_order[] = {
             "/",
             "/usr/",
             "/usr/lib/",
@@ -1426,7 +1426,7 @@
     CxAllocator *alloc = &talloc.base;
 
     CX_TEST_DO {
-        char const *paths[] = {
+        const char *paths[] = {
                 "/usr/",
                 "/home/",
                 "/usr/lib/",
@@ -1439,7 +1439,7 @@
                 "/home/foo/"
         };
 
-        char const *scrambled_paths[] = {
+        const char *scrambled_paths[] = {
                 "/usr/",
                 "/home/",
                 "/var/www/vhosts/live/",

mercurial