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
     1.1 --- a/test/test_allocator.c	Sun Sep 26 13:41:52 2021 +0200
     1.2 +++ b/test/test_allocator.c	Sun Sep 26 14:34:49 2021 +0200
     1.3 @@ -28,6 +28,7 @@
     1.4  
     1.5  #include "cx/allocator.h"
     1.6  #include "test_config.h"
     1.7 +#include <errno.h>
     1.8  
     1.9  void test_default_allocator_available(void) {
    1.10      cx_allocator_class *clazz = cxDefaultAllocator->cl;
    1.11 @@ -42,7 +43,7 @@
    1.12  
    1.13  void test_default_realloc(void) {
    1.14      void *test = calloc(8, 1);
    1.15 -    memcpy(test, "Test", 4);
    1.16 +    memcpy(test, "Test", 5);
    1.17      test = cxRealloc(cxDefaultAllocator, test, 16);
    1.18      CU_ASSERT_PTR_NOT_NULL(test)
    1.19      CU_ASSERT_STRING_EQUAL("Test", test)
    1.20 @@ -51,7 +52,7 @@
    1.21  
    1.22  void test_default_reallocate(void) {
    1.23      void *test = calloc(8, 1);
    1.24 -    memcpy(test, "Test", 4);
    1.25 +    memcpy(test, "Test", 5);
    1.26      int rval = cxReallocate(cxDefaultAllocator, &test, 16);
    1.27      CU_ASSERT_EQUAL(rval, 0);
    1.28      CU_ASSERT_PTR_NOT_NULL(test)
    1.29 @@ -61,7 +62,8 @@
    1.30  
    1.31  void test_reallocate_null(void) {
    1.32      int rval = cxReallocate(cxDefaultAllocator, NULL, 16);
    1.33 -    CU_ASSERT_EQUAL(rval, EINVAL);
    1.34 +    CU_ASSERT_NOT_EQUAL(rval, 0);
    1.35 +    CU_ASSERT_EQUAL(errno, EINVAL);
    1.36  }
    1.37  
    1.38  void test_default_calloc(void) {
    1.39 @@ -94,7 +96,7 @@
    1.40              !CU_add_test(suite, "test of malloc()", test_default_malloc)||
    1.41              !CU_add_test(suite, "test of realloc()", test_default_realloc) ||
    1.42              !CU_add_test(suite, "test of realloc() via cxReallocate", test_default_reallocate) ||
    1.43 -            !CU_add_test(suite, "test of cxReallocate with NULL", test_default_reallocate) ||
    1.44 +            !CU_add_test(suite, "test of cxReallocate with NULL", test_reallocate_null) ||
    1.45              !CU_add_test(suite, "test of calloc()", test_default_calloc) ||
    1.46              !CU_add_test(suite, "test of free()", test_default_free)
    1.47              ) {

mercurial