test/test_allocator.c

changeset 397
cfc1193b1e65
parent 396
3539dd99ab92
child 410
76b76f0f046b
     1.1 --- a/test/test_allocator.c	Sun Feb 07 17:17:46 2021 +0100
     1.2 +++ b/test/test_allocator.c	Sun Feb 07 18:08:21 2021 +0100
     1.3 @@ -31,36 +31,33 @@
     1.4  #include <CUnit/Basic.h>
     1.5  
     1.6  void test_default_allocator_available(void) {
     1.7 -    cx_allocator_class* clazz = cxDefaultAllocator->cl;
     1.8 -    CU_ASSERT_PTR_EQUAL(clazz->malloc, cx_malloc_stdlib)
     1.9 -    CU_ASSERT_PTR_EQUAL(clazz->realloc, cx_realloc_stdlib)
    1.10 -    CU_ASSERT_PTR_EQUAL(clazz->calloc, cx_calloc_stdlib)
    1.11 -    CU_ASSERT_PTR_EQUAL(clazz->free, cx_free_stdlib)
    1.12 +    cx_allocator_class *clazz = cxDefaultAllocator->cl;
    1.13 +    CU_ASSERT_PTR_EQUAL(clazz, &cx_default_allocator_class)
    1.14  }
    1.15  
    1.16  void test_default_malloc(void) {
    1.17 -    void* test = cxMalloc(cxDefaultAllocator, 16);
    1.18 +    void *test = cxMalloc(cxDefaultAllocator, 16);
    1.19      CU_ASSERT_PTR_NOT_NULL(test);
    1.20      free(test);
    1.21  }
    1.22  
    1.23  void test_default_realloc(void) {
    1.24 -    void* test = calloc(8, 1);
    1.25 +    void *test = calloc(8, 1);
    1.26      memcpy(test, "Test", 4);
    1.27      test = cxRealloc(cxDefaultAllocator, test, 16);
    1.28 -    CU_ASSERT_PTR_NOT_NULL(test);
    1.29 +    CU_ASSERT_PTR_NOT_NULL(test)
    1.30      CU_ASSERT_STRING_EQUAL("Test", test)
    1.31      free(test);
    1.32  }
    1.33  
    1.34  void test_default_calloc(void) {
    1.35 -    void* test = cxCalloc(cxDefaultAllocator, 8, 2);
    1.36 -    CU_ASSERT_PTR_NOT_NULL(test);
    1.37 +    void *test = cxCalloc(cxDefaultAllocator, 8, 2);
    1.38 +    CU_ASSERT_PTR_NOT_NULL(test)
    1.39      free(test);
    1.40  }
    1.41  
    1.42  void test_default_free(void) {
    1.43 -    void* test = malloc(16);
    1.44 +    void *test = malloc(16);
    1.45      cxFree(cxDefaultAllocator, test);
    1.46      CU_PASS("Testing standard free is not possible.")
    1.47  }
    1.48 @@ -84,7 +81,7 @@
    1.49              (NULL == CU_add_test(suite, "test of realloc()", test_default_realloc)) ||
    1.50              (NULL == CU_add_test(suite, "test of realloc()", test_default_calloc)) ||
    1.51              (NULL == CU_add_test(suite, "test of free()", test_default_free))
    1.52 -        ) {
    1.53 +            ) {
    1.54          CU_cleanup_registry();
    1.55          return CU_get_error();
    1.56      }

mercurial