test/test_allocator.c

changeset 410
76b76f0f046b
parent 397
cfc1193b1e65
child 414
81a4c3a63e65
     1.1 --- a/test/test_allocator.c	Sun Feb 14 11:30:19 2021 +0100
     1.2 +++ b/test/test_allocator.c	Sun Feb 14 11:30:47 2021 +0100
     1.3 @@ -27,8 +27,7 @@
     1.4   */
     1.5  
     1.6  #include "cx/allocator.h"
     1.7 -
     1.8 -#include <CUnit/Basic.h>
     1.9 +#include "test_config.h"
    1.10  
    1.11  void test_default_allocator_available(void) {
    1.12      cx_allocator_class *clazz = cxDefaultAllocator->cl;
    1.13 @@ -69,26 +68,31 @@
    1.14          return CU_get_error();
    1.15      }
    1.16  
    1.17 -    suite = CU_add_suite("stdlib allocator", NULL, NULL);
    1.18 +    suite = CU_add_suite("default allocator", NULL, NULL);
    1.19      if (NULL == suite) {
    1.20          CU_cleanup_registry();
    1.21          return CU_get_error();
    1.22      }
    1.23  
    1.24      if (
    1.25 -            (NULL == CU_add_test(suite, "default allocator available", test_default_allocator_available)) ||
    1.26 -            (NULL == CU_add_test(suite, "test of malloc()", test_default_malloc)) ||
    1.27 -            (NULL == CU_add_test(suite, "test of realloc()", test_default_realloc)) ||
    1.28 -            (NULL == CU_add_test(suite, "test of realloc()", test_default_calloc)) ||
    1.29 -            (NULL == CU_add_test(suite, "test of free()", test_default_free))
    1.30 +            !CU_add_test(suite, "default allocator available", test_default_allocator_available) ||
    1.31 +            !CU_add_test(suite, "test of malloc()", test_default_malloc)||
    1.32 +            !CU_add_test(suite, "test of realloc()", test_default_realloc) ||
    1.33 +            !CU_add_test(suite, "test of realloc()", test_default_calloc) ||
    1.34 +            !CU_add_test(suite, "test of free()", test_default_free)
    1.35              ) {
    1.36          CU_cleanup_registry();
    1.37          return CU_get_error();
    1.38      }
    1.39  
    1.40 -    CU_basic_set_mode(CU_BRM_NORMAL);
    1.41 -    CU_basic_run_tests();
    1.42 +    CU_basic_set_mode(UCX_CU_BRM);
    1.43 +
    1.44 +    int exitcode;
    1.45 +    if (CU_basic_run_tests()) {
    1.46 +        exitcode = CU_get_error();
    1.47 +    } else {
    1.48 +        exitcode = CU_get_number_of_failures() == 0 ? 0 : 1;
    1.49 +    }
    1.50      CU_cleanup_registry();
    1.51 -
    1.52 -    return CU_get_error();
    1.53 +    return exitcode;
    1.54  }

mercurial