diff -r 0f4aa9fc75d9 -r 81a4c3a63e65 test/test_allocator.c --- a/test/test_allocator.c Sun Feb 14 15:37:12 2021 +0100 +++ b/test/test_allocator.c Mon Mar 01 22:19:06 2021 +0100 @@ -49,6 +49,21 @@ free(test); } +void test_default_reallocate(void) { + void *test = calloc(8, 1); + memcpy(test, "Test", 4); + int rval = cxReallocate(cxDefaultAllocator, &test, 16); + CU_ASSERT_EQUAL(rval, 0); + CU_ASSERT_PTR_NOT_NULL(test) + CU_ASSERT_STRING_EQUAL("Test", test) + free(test); +} + +void test_reallocate_null(void) { + int rval = cxReallocate(cxDefaultAllocator, NULL, 16); + CU_ASSERT_EQUAL(rval, EINVAL); +} + void test_default_calloc(void) { void *test = cxCalloc(cxDefaultAllocator, 8, 2); CU_ASSERT_PTR_NOT_NULL(test) @@ -78,7 +93,9 @@ !CU_add_test(suite, "default allocator available", test_default_allocator_available) || !CU_add_test(suite, "test of malloc()", test_default_malloc)|| !CU_add_test(suite, "test of realloc()", test_default_realloc) || - !CU_add_test(suite, "test of realloc()", test_default_calloc) || + !CU_add_test(suite, "test of realloc() via cxReallocate", test_default_reallocate) || + !CU_add_test(suite, "test of cxReallocate with NULL", test_default_reallocate) || + !CU_add_test(suite, "test of calloc()", test_default_calloc) || !CU_add_test(suite, "test of free()", test_default_free) ) { CU_cleanup_registry();