test/test_allocator.c

changeset 414
81a4c3a63e65
parent 410
76b76f0f046b
child 419
b5d6cb88d05d
     1.1 --- a/test/test_allocator.c	Sun Feb 14 15:37:12 2021 +0100
     1.2 +++ b/test/test_allocator.c	Mon Mar 01 22:19:06 2021 +0100
     1.3 @@ -49,6 +49,21 @@
     1.4      free(test);
     1.5  }
     1.6  
     1.7 +void test_default_reallocate(void) {
     1.8 +    void *test = calloc(8, 1);
     1.9 +    memcpy(test, "Test", 4);
    1.10 +    int rval = cxReallocate(cxDefaultAllocator, &test, 16);
    1.11 +    CU_ASSERT_EQUAL(rval, 0);
    1.12 +    CU_ASSERT_PTR_NOT_NULL(test)
    1.13 +    CU_ASSERT_STRING_EQUAL("Test", test)
    1.14 +    free(test);
    1.15 +}
    1.16 +
    1.17 +void test_reallocate_null(void) {
    1.18 +    int rval = cxReallocate(cxDefaultAllocator, NULL, 16);
    1.19 +    CU_ASSERT_EQUAL(rval, EINVAL);
    1.20 +}
    1.21 +
    1.22  void test_default_calloc(void) {
    1.23      void *test = cxCalloc(cxDefaultAllocator, 8, 2);
    1.24      CU_ASSERT_PTR_NOT_NULL(test)
    1.25 @@ -78,7 +93,9 @@
    1.26              !CU_add_test(suite, "default allocator available", test_default_allocator_available) ||
    1.27              !CU_add_test(suite, "test of malloc()", test_default_malloc)||
    1.28              !CU_add_test(suite, "test of realloc()", test_default_realloc) ||
    1.29 -            !CU_add_test(suite, "test of realloc()", test_default_calloc) ||
    1.30 +            !CU_add_test(suite, "test of realloc() via cxReallocate", test_default_reallocate) ||
    1.31 +            !CU_add_test(suite, "test of cxReallocate with NULL", test_default_reallocate) ||
    1.32 +            !CU_add_test(suite, "test of calloc()", test_default_calloc) ||
    1.33              !CU_add_test(suite, "test of free()", test_default_free)
    1.34              ) {
    1.35          CU_cleanup_registry();

mercurial