test/test_allocator.c

changeset 434
38ee262e8b94
parent 421
aa465fac4ef6
child 443
d6d8712e15bc
equal deleted inserted replaced
433:f1e4c6dabfb4 434:38ee262e8b94
58 CU_ASSERT_PTR_NOT_NULL(test) 58 CU_ASSERT_PTR_NOT_NULL(test)
59 CU_ASSERT_STRING_EQUAL("Test", test) 59 CU_ASSERT_STRING_EQUAL("Test", test)
60 free(test); 60 free(test);
61 } 61 }
62 62
63 void test_reallocate_null(void) {
64 int rval = cxReallocate(cxDefaultAllocator, NULL, 16);
65 CU_ASSERT_NOT_EQUAL(rval, 0);
66 CU_ASSERT_EQUAL(errno, EINVAL);
67 }
68
69 void test_default_calloc(void) { 63 void test_default_calloc(void) {
70 void *test = cxCalloc(cxDefaultAllocator, 8, 2); 64 void *test = cxCalloc(cxDefaultAllocator, 8, 2);
71 CU_ASSERT_PTR_NOT_NULL(test) 65 CU_ASSERT_PTR_NOT_NULL(test)
72 free(test); 66 free(test);
73 } 67 }
94 if ( 88 if (
95 !CU_add_test(suite, "default allocator available", test_default_allocator_available) || 89 !CU_add_test(suite, "default allocator available", test_default_allocator_available) ||
96 !CU_add_test(suite, "test of malloc()", test_default_malloc)|| 90 !CU_add_test(suite, "test of malloc()", test_default_malloc)||
97 !CU_add_test(suite, "test of realloc()", test_default_realloc) || 91 !CU_add_test(suite, "test of realloc()", test_default_realloc) ||
98 !CU_add_test(suite, "test of realloc() via cxReallocate", test_default_reallocate) || 92 !CU_add_test(suite, "test of realloc() via cxReallocate", test_default_reallocate) ||
99 !CU_add_test(suite, "test of cxReallocate with NULL", test_reallocate_null) ||
100 !CU_add_test(suite, "test of calloc()", test_default_calloc) || 93 !CU_add_test(suite, "test of calloc()", test_default_calloc) ||
101 !CU_add_test(suite, "test of free()", test_default_free) 94 !CU_add_test(suite, "test of free()", test_default_free)
102 ) { 95 ) {
103 CU_cleanup_registry(); 96 CU_cleanup_registry();
104 return CU_get_error(); 97 return CU_get_error();

mercurial