test/test_allocator.c

changeset 410
76b76f0f046b
parent 397
cfc1193b1e65
child 414
81a4c3a63e65
equal deleted inserted replaced
409:5d167af0eadb 410:76b76f0f046b
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "cx/allocator.h" 29 #include "cx/allocator.h"
30 30 #include "test_config.h"
31 #include <CUnit/Basic.h>
32 31
33 void test_default_allocator_available(void) { 32 void test_default_allocator_available(void) {
34 cx_allocator_class *clazz = cxDefaultAllocator->cl; 33 cx_allocator_class *clazz = cxDefaultAllocator->cl;
35 CU_ASSERT_PTR_EQUAL(clazz, &cx_default_allocator_class) 34 CU_ASSERT_PTR_EQUAL(clazz, &cx_default_allocator_class)
36 } 35 }
67 66
68 if (CUE_SUCCESS != CU_initialize_registry()) { 67 if (CUE_SUCCESS != CU_initialize_registry()) {
69 return CU_get_error(); 68 return CU_get_error();
70 } 69 }
71 70
72 suite = CU_add_suite("stdlib allocator", NULL, NULL); 71 suite = CU_add_suite("default allocator", NULL, NULL);
73 if (NULL == suite) { 72 if (NULL == suite) {
74 CU_cleanup_registry(); 73 CU_cleanup_registry();
75 return CU_get_error(); 74 return CU_get_error();
76 } 75 }
77 76
78 if ( 77 if (
79 (NULL == CU_add_test(suite, "default allocator available", test_default_allocator_available)) || 78 !CU_add_test(suite, "default allocator available", test_default_allocator_available) ||
80 (NULL == CU_add_test(suite, "test of malloc()", test_default_malloc)) || 79 !CU_add_test(suite, "test of malloc()", test_default_malloc)||
81 (NULL == CU_add_test(suite, "test of realloc()", test_default_realloc)) || 80 !CU_add_test(suite, "test of realloc()", test_default_realloc) ||
82 (NULL == CU_add_test(suite, "test of realloc()", test_default_calloc)) || 81 !CU_add_test(suite, "test of realloc()", test_default_calloc) ||
83 (NULL == CU_add_test(suite, "test of free()", test_default_free)) 82 !CU_add_test(suite, "test of free()", test_default_free)
84 ) { 83 ) {
85 CU_cleanup_registry(); 84 CU_cleanup_registry();
86 return CU_get_error(); 85 return CU_get_error();
87 } 86 }
88 87
89 CU_basic_set_mode(CU_BRM_NORMAL); 88 CU_basic_set_mode(UCX_CU_BRM);
90 CU_basic_run_tests(); 89
90 int exitcode;
91 if (CU_basic_run_tests()) {
92 exitcode = CU_get_error();
93 } else {
94 exitcode = CU_get_number_of_failures() == 0 ? 0 : 1;
95 }
91 CU_cleanup_registry(); 96 CU_cleanup_registry();
92 97 return exitcode;
93 return CU_get_error();
94 } 98 }

mercurial