# HG changeset patch # User Mike Becker # Date 1633269773 -7200 # Node ID 8168e16cd1e953cc24ab6a552a6f02209458c438 # Parent 4b3219fab71c3125cd4f2667c317637efa267471 change test names diff -r 4b3219fab71c -r 8168e16cd1e9 test/test_config.h --- 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 */ diff -r 4b3219fab71c -r 8168e16cd1e9 test/test_list.c --- 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); diff -r 4b3219fab71c -r 8168e16cd1e9 test/test_tree.c --- 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;