47 CU_ASSERT_PTR_NOT_NULL(test) |
47 CU_ASSERT_PTR_NOT_NULL(test) |
48 CU_ASSERT_STRING_EQUAL("Test", test) |
48 CU_ASSERT_STRING_EQUAL("Test", test) |
49 free(test); |
49 free(test); |
50 } |
50 } |
51 |
51 |
|
52 void test_default_reallocate(void) { |
|
53 void *test = calloc(8, 1); |
|
54 memcpy(test, "Test", 4); |
|
55 int rval = cxReallocate(cxDefaultAllocator, &test, 16); |
|
56 CU_ASSERT_EQUAL(rval, 0); |
|
57 CU_ASSERT_PTR_NOT_NULL(test) |
|
58 CU_ASSERT_STRING_EQUAL("Test", test) |
|
59 free(test); |
|
60 } |
|
61 |
|
62 void test_reallocate_null(void) { |
|
63 int rval = cxReallocate(cxDefaultAllocator, NULL, 16); |
|
64 CU_ASSERT_EQUAL(rval, EINVAL); |
|
65 } |
|
66 |
52 void test_default_calloc(void) { |
67 void test_default_calloc(void) { |
53 void *test = cxCalloc(cxDefaultAllocator, 8, 2); |
68 void *test = cxCalloc(cxDefaultAllocator, 8, 2); |
54 CU_ASSERT_PTR_NOT_NULL(test) |
69 CU_ASSERT_PTR_NOT_NULL(test) |
55 free(test); |
70 free(test); |
56 } |
71 } |
76 |
91 |
77 if ( |
92 if ( |
78 !CU_add_test(suite, "default allocator available", test_default_allocator_available) || |
93 !CU_add_test(suite, "default allocator available", test_default_allocator_available) || |
79 !CU_add_test(suite, "test of malloc()", test_default_malloc)|| |
94 !CU_add_test(suite, "test of malloc()", test_default_malloc)|| |
80 !CU_add_test(suite, "test of realloc()", test_default_realloc) || |
95 !CU_add_test(suite, "test of realloc()", test_default_realloc) || |
81 !CU_add_test(suite, "test of realloc()", test_default_calloc) || |
96 !CU_add_test(suite, "test of realloc() via cxReallocate", test_default_reallocate) || |
|
97 !CU_add_test(suite, "test of cxReallocate with NULL", test_default_reallocate) || |
|
98 !CU_add_test(suite, "test of calloc()", test_default_calloc) || |
82 !CU_add_test(suite, "test of free()", test_default_free) |
99 !CU_add_test(suite, "test of free()", test_default_free) |
83 ) { |
100 ) { |
84 CU_cleanup_registry(); |
101 CU_cleanup_registry(); |
85 return CU_get_error(); |
102 return CU_get_error(); |
86 } |
103 } |