fix reallocate_null test not used and wrong

Sun, 26 Sep 2021 14:34:49 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 26 Sep 2021 14:34:49 +0200
changeset 421
aa465fac4ef6
parent 420
8eb6faa2edba
child 422
afd87df80b13

fix reallocate_null test not used and wrong

test/test_allocator.c file | annotate | diff | comparison | revisions
--- 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