Automated merge

Tue, 28 Sep 2021 18:09:25 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 28 Sep 2021 18:09:25 +0200
changeset 445
26ae21face39
parent 441
7d5a06e32aa8 (current diff)
parent 444
cb944fa1852a (diff)
child 446
668757098b73

Automated merge

     1.1 --- a/src/cx/tree.h	Tue Sep 28 18:09:14 2021 +0200
     1.2 +++ b/src/cx/tree.h	Tue Sep 28 18:09:25 2021 +0200
     1.3 @@ -36,7 +36,7 @@
     1.4  #ifdef __cplusplus
     1.5  extern "C" {
     1.6  #endif
     1.7 -
     1.8 + 
     1.9  void* cx_tree_last(void *node, ptrdiff_t loc_next);
    1.10      
    1.11  int cx_tree_add_node(void *node, ptrdiff_t loc_parent, ptrdiff_t loc_prev, ptrdiff_t loc_next, void *new_node);
     2.1 --- a/test/test_allocator.c	Tue Sep 28 18:09:14 2021 +0200
     2.2 +++ b/test/test_allocator.c	Tue Sep 28 18:09:25 2021 +0200
     2.3 @@ -80,22 +80,13 @@
     2.4      }
     2.5  
     2.6      suite = CU_add_suite("default allocator", NULL, NULL);
     2.7 -    if (NULL == suite) {
     2.8 -        CU_cleanup_registry();
     2.9 -        return CU_get_error();
    2.10 -    }
    2.11  
    2.12 -    if (
    2.13 -            !CU_add_test(suite, "default allocator available", test_default_allocator_available) ||
    2.14 -            !CU_add_test(suite, "test of malloc()", test_default_malloc)||
    2.15 -            !CU_add_test(suite, "test of realloc()", test_default_realloc) ||
    2.16 -            !CU_add_test(suite, "test of realloc() via cxReallocate", test_default_reallocate) ||
    2.17 -            !CU_add_test(suite, "test of calloc()", test_default_calloc) ||
    2.18 -            !CU_add_test(suite, "test of free()", test_default_free)
    2.19 -            ) {
    2.20 -        CU_cleanup_registry();
    2.21 -        return CU_get_error();
    2.22 -    }
    2.23 +    CU_add_test(suite, "default allocator available", test_default_allocator_available);
    2.24 +    CU_add_test(suite, "test of malloc()", test_default_malloc);
    2.25 +    CU_add_test(suite, "test of realloc()", test_default_realloc);
    2.26 +    CU_add_test(suite, "test of realloc() via cxReallocate", test_default_reallocate);
    2.27 +    CU_add_test(suite, "test of calloc()", test_default_calloc);
    2.28 +    CU_add_test(suite, "test of free()", test_default_free);
    2.29  
    2.30      CU_basic_set_mode(UCX_CU_BRM);
    2.31  
     3.1 --- a/test/test_list.c	Tue Sep 28 18:09:14 2021 +0200
     3.2 +++ b/test/test_list.c	Tue Sep 28 18:09:25 2021 +0200
     3.3 @@ -100,41 +100,83 @@
     3.4      CU_ASSERT_PTR_EQUAL(&b, cx_linked_list_at(&d, 3, loc_prev, 1));
     3.5  }
     3.6  
     3.7 +void test_linked_list_add(void) {
     3.8 +    struct node {
     3.9 +        void *prev;
    3.10 +        void *next;
    3.11 +        int value;
    3.12 +    };
    3.13 +    
    3.14 +    struct node nodes[4];
    3.15 +    
    3.16 +    // test with begin, end / prev, next
    3.17 +    memset(nodes, 0, 4*sizeof(struct node));
    3.18 +    void *begin = NULL;
    3.19 +    void *end = NULL;
    3.20 +    
    3.21 +    ptrdiff_t loc_prev = offsetof(struct node, prev);
    3.22 +    ptrdiff_t loc_next = offsetof(struct node, next);
    3.23 +    
    3.24 +    int ret;
    3.25 +    ret = cx_linked_list_add(&begin, &end, loc_prev, loc_next, &nodes[0]);
    3.26 +    CU_ASSERT_EQUAL(ret, 0);
    3.27 +    CU_ASSERT_PTR_EQUAL(begin, &nodes[0]);
    3.28 +    CU_ASSERT_PTR_EQUAL(end, &nodes[0]);
    3.29 +    CU_ASSERT_PTR_EQUAL(nodes[0].prev, NULL);
    3.30 +    CU_ASSERT_PTR_EQUAL(nodes[0].next, NULL);
    3.31 +    
    3.32 +    ret = cx_linked_list_add(&begin, &end, loc_prev, loc_next, &nodes[1]);
    3.33 +    CU_ASSERT_EQUAL(ret, 0);
    3.34 +    CU_ASSERT_PTR_EQUAL(begin, &nodes[0]);
    3.35 +    CU_ASSERT_PTR_EQUAL(end, &nodes[1]);
    3.36 +    CU_ASSERT_PTR_EQUAL(nodes[0].next, &nodes[1]);
    3.37 +    CU_ASSERT_PTR_EQUAL(nodes[1].prev, &nodes[0]);
    3.38 +    
    3.39 +    // test with begin only / prev, next
    3.40 +    memset(nodes, 0, 4*sizeof(struct node));
    3.41 +    begin = NULL;
    3.42 +    end = NULL;
    3.43 +    
    3.44 +    ret = cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[0]);
    3.45 +    CU_ASSERT_EQUAL(ret, 0);
    3.46 +    CU_ASSERT_PTR_EQUAL(begin, &nodes[0]);
    3.47 +    ret = cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[1]);
    3.48 +    CU_ASSERT_EQUAL(ret, 0);
    3.49 +    CU_ASSERT_PTR_EQUAL(begin, &nodes[0]);
    3.50 +    CU_ASSERT_PTR_EQUAL(nodes[0].next, &nodes[1]);
    3.51 +    CU_ASSERT_PTR_EQUAL(nodes[1].prev, &nodes[0]);
    3.52 +    
    3.53 +    ret = cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[2]);
    3.54 +    CU_ASSERT_PTR_EQUAL(nodes[1].next, &nodes[2]);
    3.55 +    CU_ASSERT_PTR_EQUAL(nodes[2].prev, &nodes[1]);
    3.56 +    
    3.57 +    // test with begin, end / next
    3.58 +    memset(nodes, 0, 4*sizeof(struct node));
    3.59 +    begin = NULL;
    3.60 +    end = NULL;
    3.61 +    
    3.62 +    ret = cx_linked_list_add(&begin, &end, -1, loc_next, &nodes[0]);
    3.63 +    CU_ASSERT_EQUAL(ret, 0);
    3.64 +    CU_ASSERT_PTR_EQUAL(begin, &nodes[0]);
    3.65 +    CU_ASSERT_PTR_EQUAL(end, &nodes[0]);
    3.66 +    ret = cx_linked_list_add(&begin, &end, -1, loc_next, &nodes[1]);
    3.67 +    CU_ASSERT_PTR_EQUAL(end, &nodes[1]);
    3.68 +    CU_ASSERT_PTR_EQUAL(nodes[0].next, &nodes[1]);
    3.69 +    CU_ASSERT_PTR_EQUAL(nodes[1].prev, NULL);
    3.70 +}
    3.71 +
    3.72  int main() {
    3.73      CU_pSuite suite = NULL;
    3.74 -
    3.75 +    
    3.76      if (CUE_SUCCESS != CU_initialize_registry()) {
    3.77          return CU_get_error();
    3.78      }
    3.79  
    3.80      suite = CU_add_suite("linked list suite", NULL, NULL);
    3.81 -    if (NULL == suite) {
    3.82 -        CU_cleanup_registry();
    3.83 -        return CU_get_error();
    3.84 -    }
    3.85 -
    3.86 -    if (
    3.87 -            !CU_add_test(suite, "linked list: create and destroy", test_linked_list_create) ||
    3.88 -            !CU_add_test(suite, "linked list: get node at index", test_linked_list_at)
    3.89 -            ) {
    3.90 -        CU_cleanup_registry();
    3.91 -        return CU_get_error();
    3.92 -    }
    3.93 -
    3.94 -    suite = CU_add_suite("array suite", NULL, NULL);
    3.95 -    if (NULL == suite) {
    3.96 -        CU_cleanup_registry();
    3.97 -        return CU_get_error();
    3.98 -    }
    3.99 -
   3.100 -    /*
   3.101 -    if (
   3.102 -            !CU_add_test(suite, "array...", test_array...)
   3.103 -            ) {
   3.104 -        CU_cleanup_registry();
   3.105 -        return CU_get_error();
   3.106 -    }
   3.107 -    */
   3.108 +    
   3.109 +    CU_add_test(suite, "linked list: create and destroy", test_linked_list_create);
   3.110 +    CU_add_test(suite, "linked list: get node at index", test_linked_list_at);
   3.111 +    CU_add_test(suite, "linked list: add", test_linked_list_add);
   3.112  
   3.113      CU_basic_set_mode(UCX_CU_BRM);
   3.114  
     4.1 --- a/test/test_tree.c	Tue Sep 28 18:09:14 2021 +0200
     4.2 +++ b/test/test_tree.c	Tue Sep 28 18:09:25 2021 +0200
     4.3 @@ -167,23 +167,9 @@
     4.4      }
     4.5  
     4.6      suite = CU_add_suite("tree suite", NULL, NULL);
     4.7 -    if (NULL == suite) {
     4.8 -        CU_cleanup_registry();
     4.9 -        return CU_get_error();
    4.10 -    }
    4.11  
    4.12 -    if (
    4.13 -            !CU_add_test(suite, "ll add tree node", test_cx_tree_add_node)
    4.14 -            ) {
    4.15 -        CU_cleanup_registry();
    4.16 -        return CU_get_error();
    4.17 -    }
    4.18 -    if (
    4.19 -            !CU_add_test(suite, "ll add tree child node", test_cx_tree_add_child_node)
    4.20 -            ) {
    4.21 -        CU_cleanup_registry();
    4.22 -        return CU_get_error();
    4.23 -    }
    4.24 +    CU_add_test(suite, "ll add tree node", test_cx_tree_add_node);
    4.25 +    CU_add_test(suite, "ll add tree child node", test_cx_tree_add_child_node);
    4.26      
    4.27      
    4.28      CU_basic_set_mode(UCX_CU_BRM);

mercurial