change test names

Sun, 03 Oct 2021 16:02:53 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 03 Oct 2021 16:02:53 +0200
changeset 455
8168e16cd1e9
parent 454
4b3219fab71c
child 456
227c2eabbef8

change test names

test/test_config.h file | annotate | diff | comparison | revisions
test/test_list.c file | annotate | diff | comparison | revisions
test/test_tree.c file | annotate | diff | comparison | revisions
--- a/test/test_config.h	Sun Oct 03 15:40:38 2021 +0200
+++ b/test/test_config.h	Sun Oct 03 16:02:53 2021 +0200
@@ -33,4 +33,6 @@
 
 #define UCX_CU_BRM CU_BRM_NORMAL
 
+#define cu_add_test(suite, name) CU_add_test(suite, #name, name)
+
 #endif /* UCX_TEST_CONFIG_H */
--- a/test/test_list.c	Sun Oct 03 15:40:38 2021 +0200
+++ b/test/test_list.c	Sun Oct 03 16:02:53 2021 +0200
@@ -35,33 +35,6 @@
     return left == right ? 0 : (left < right ? -1 : 1);
 }
 
-void test_linked_list_create(void) {
-    cxTestingAllocatorReset();
-
-    CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
-
-    CU_ASSERT_EQUAL(list->size, 0)
-    CU_ASSERT_EQUAL(list->capacity, (size_t) -1)
-    CU_ASSERT_PTR_EQUAL(list->allocator, cxTestingAllocator)
-    CU_ASSERT_EQUAL(list->itemsize, sizeof(int))
-    CU_ASSERT_PTR_EQUAL(list->cmpfunc, cmp_int)
-
-    // assume this structure for a linked list
-    struct ll_check {
-        cx_list_s base;
-        void *begin;
-        void *end;
-    };
-
-    struct ll_check *actual = (struct ll_check *) list;
-    CU_ASSERT_PTR_NULL(actual->begin)
-    CU_ASSERT_PTR_NULL(actual->end)
-
-    cxLinkedListDestroy(list);
-
-    CU_ASSERT_TRUE(cxTestingAllocatorVerify())
-}
-
 void test_linked_list_at(void) {
     struct node {
         void *next;
@@ -154,6 +127,34 @@
     CU_ASSERT_PTR_NULL(nodes[1].prev)
 }
 
+
+void test_linked_list_create(void) {
+    cxTestingAllocatorReset();
+
+    CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
+
+    CU_ASSERT_EQUAL(list->size, 0)
+    CU_ASSERT_EQUAL(list->capacity, (size_t) -1)
+    CU_ASSERT_PTR_EQUAL(list->allocator, cxTestingAllocator)
+    CU_ASSERT_EQUAL(list->itemsize, sizeof(int))
+    CU_ASSERT_PTR_EQUAL(list->cmpfunc, cmp_int)
+
+    // assume this structure for a linked list
+    struct ll_check {
+        cx_list_s base;
+        void *begin;
+        void *end;
+    };
+
+    struct ll_check *actual = (struct ll_check *) list;
+    CU_ASSERT_PTR_NULL(actual->begin)
+    CU_ASSERT_PTR_NULL(actual->end)
+
+    cxLinkedListDestroy(list);
+
+    CU_ASSERT_TRUE(cxTestingAllocatorVerify())
+}
+
 int main() {
     CU_pSuite suite = NULL;
 
@@ -161,11 +162,14 @@
         return CU_get_error();
     }
 
-    suite = CU_add_suite("linked list suite", NULL, NULL);
+    suite = CU_add_suite("low level linked list suite", NULL, NULL);
 
-    CU_add_test(suite, "linked list: create and destroy", test_linked_list_create);
-    CU_add_test(suite, "linked list: get node at index", test_linked_list_at);
-    CU_add_test(suite, "linked list: add", test_linked_list_add);
+    cu_add_test(suite, test_linked_list_at);
+    cu_add_test(suite, test_linked_list_add);
+
+    suite = CU_add_suite("high level linked list suite", NULL, NULL);
+
+    cu_add_test(suite, test_linked_list_create);
 
     CU_basic_set_mode(UCX_CU_BRM);
 
--- a/test/test_tree.c	Sun Oct 03 15:40:38 2021 +0200
+++ b/test/test_tree.c	Sun Oct 03 16:02:53 2021 +0200
@@ -42,7 +42,7 @@
     TestNode *children_end;
 };
 
-void test_cx_tree_add_node(void) {
+void test_tree_add_sibling(void) {
     // prepare test tree
     TestNode root;
     memset(&root, 0, sizeof(TestNode));
@@ -73,7 +73,7 @@
     CU_ASSERT_PTR_EQUAL(b.next, &c)
 }
 
-void test_cx_tree_add_child_node(void) {
+void test_tree_add_child(void) {
     // prepare test tree
     TestNode root;
     memset(&root, 0, sizeof(TestNode));
@@ -153,10 +153,9 @@
 
     suite = CU_add_suite("tree suite", NULL, NULL);
 
-    CU_add_test(suite, "ll add tree node", test_cx_tree_add_node);
-    CU_add_test(suite, "ll add tree child node", test_cx_tree_add_child_node);
-    
-    
+    cu_add_test(suite, test_tree_add_sibling);
+    cu_add_test(suite, test_tree_add_child);
+
     CU_basic_set_mode(UCX_CU_BRM);
 
     int exitcode;

mercurial