test/test_allocator.c

changeset 421
aa465fac4ef6
parent 419
b5d6cb88d05d
child 434
38ee262e8b94
--- a/test/test_allocator.c	Sun Sep 26 13:41:52 2021 +0200
+++ b/test/test_allocator.c	Sun Sep 26 14:34:49 2021 +0200
@@ -28,6 +28,7 @@
 
 #include "cx/allocator.h"
 #include "test_config.h"
+#include <errno.h>
 
 void test_default_allocator_available(void) {
     cx_allocator_class *clazz = cxDefaultAllocator->cl;
@@ -42,7 +43,7 @@
 
 void test_default_realloc(void) {
     void *test = calloc(8, 1);
-    memcpy(test, "Test", 4);
+    memcpy(test, "Test", 5);
     test = cxRealloc(cxDefaultAllocator, test, 16);
     CU_ASSERT_PTR_NOT_NULL(test)
     CU_ASSERT_STRING_EQUAL("Test", test)
@@ -51,7 +52,7 @@
 
 void test_default_reallocate(void) {
     void *test = calloc(8, 1);
-    memcpy(test, "Test", 4);
+    memcpy(test, "Test", 5);
     int rval = cxReallocate(cxDefaultAllocator, &test, 16);
     CU_ASSERT_EQUAL(rval, 0);
     CU_ASSERT_PTR_NOT_NULL(test)
@@ -61,7 +62,8 @@
 
 void test_reallocate_null(void) {
     int rval = cxReallocate(cxDefaultAllocator, NULL, 16);
-    CU_ASSERT_EQUAL(rval, EINVAL);
+    CU_ASSERT_NOT_EQUAL(rval, 0);
+    CU_ASSERT_EQUAL(errno, EINVAL);
 }
 
 void test_default_calloc(void) {
@@ -94,7 +96,7 @@
             !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() via cxReallocate", test_default_reallocate) ||
-            !CU_add_test(suite, "test of cxReallocate with NULL", test_default_reallocate) ||
+            !CU_add_test(suite, "test of cxReallocate with NULL", test_reallocate_null) ||
             !CU_add_test(suite, "test of calloc()", test_default_calloc) ||
             !CU_add_test(suite, "test of free()", test_default_free)
             ) {

mercurial