1.1 --- a/test/array_tests.c Thu Jul 04 21:31:45 2019 +0200 1.2 +++ b/test/array_tests.c Thu Jul 04 22:23:15 2019 +0200 1.3 @@ -151,19 +151,17 @@ 1.4 1.5 UCX_TEST_BEGIN 1.6 1.7 - UCX_TEST_ASSERT(ucx_array_equals(a1, a2, ucx_cmp_int, NULL) == 0, "failed"); 1.8 - UCX_TEST_ASSERT(ucx_array_equals(a1, a4, ucx_cmp_int, NULL) > 0, "failed"); 1.9 - UCX_TEST_ASSERT(ucx_array_equals(a4, a1, ucx_cmp_int, NULL) < 0, "failed"); 1.10 - UCX_TEST_ASSERT(ucx_array_equals(a1, a3, ucx_cmp_int, NULL) < 0, 1.11 - "comparing arrays of different element size failed"); 1.12 - UCX_TEST_ASSERT(ucx_array_equals(a3, a1, ucx_cmp_int, NULL) > 0, 1.13 - "comparing arrays of different element size failed"); 1.14 + UCX_TEST_ASSERT(ucx_array_equals(a1, a2, ucx_cmp_int, NULL), "failed"); 1.15 + UCX_TEST_ASSERT(!ucx_array_equals(a1, a4, ucx_cmp_int, NULL), "failed"); 1.16 + UCX_TEST_ASSERT(!ucx_array_equals(a4, a1, ucx_cmp_int, NULL), "failed"); 1.17 + UCX_TEST_ASSERT(!ucx_array_equals(a1, a3, ucx_cmp_int, NULL), 1.18 + "comparing arrays of different element size shall fail"); 1.19 + UCX_TEST_ASSERT(!ucx_array_equals(a3, a1, ucx_cmp_int, NULL), 1.20 + "comparing arrays of different element size shall fail"); 1.21 1.22 - UCX_TEST_ASSERT(ucx_array_equals(a1, a2, NULL, NULL) == 0, 1.23 + UCX_TEST_ASSERT(ucx_array_equals(a1, a2, NULL, NULL), 1.24 "compare using memcmp() failed"); 1.25 - UCX_TEST_ASSERT(ucx_array_equals(a1, a4, NULL, NULL) > 0, 1.26 - "compare using memcmp() failed"); 1.27 - UCX_TEST_ASSERT(ucx_array_equals(a4, a1, NULL, NULL) < 0, 1.28 + UCX_TEST_ASSERT(!ucx_array_equals(a1, a4, NULL, NULL), 1.29 "compare using memcmp() failed"); 1.30 1.31 UCX_TEST_END 1.32 @@ -337,11 +335,11 @@ 1.33 UCX_TEST_BEGIN 1.34 1.35 UCX_TEST_ASSERT(array.data != copy.data, "no true copy"); 1.36 - UCX_TEST_ASSERT(ucx_array_equals(array, copy, ucx_cmp_int, NULL), "failed"); 1.37 UCX_TEST_ASSERT(array.size == copy.size, "size mismatch"); 1.38 UCX_TEST_ASSERT(array.capacity == copy.capacity, "capacity mismatch"); 1.39 UCX_TEST_ASSERT(array.elemsize == copy.elemsize, "element size mismatch"); 1.40 UCX_TEST_ASSERT(array.allocator == copy.allocator, "allocator mismatch"); 1.41 + UCX_TEST_ASSERT(ucx_array_equals(array, copy, ucx_cmp_int, NULL), "failed"); 1.42 1.43 UCX_TEST_END 1.44 1.45 @@ -369,10 +367,22 @@ 1.46 1.47 UCX_TEST_BEGIN 1.48 void* original_ptr = array.data; 1.49 - UCX_TEST_ASSERT(!ucx_array_sort(array, ucx_cmp_int, NULL), "failed"); 1.50 - UCX_TEST_ASSERT(!ucx_array_equals(array, expected, NULL, NULL), "failed"); 1.51 + ucx_array_sort(array, ucx_cmp_int, NULL); 1.52 + UCX_TEST_ASSERT(ucx_array_equals(array, expected, NULL, NULL), "failed"); 1.53 UCX_TEST_ASSERT(array.size == 5, "size corrupted"); 1.54 UCX_TEST_ASSERT(array.data == original_ptr, "shall not reallocate"); 1.55 + 1.56 + ucx_array_reserve(&array, 32); 1.57 + ucx_array_reserve(&expected, 32); 1.58 + array.size = expected.size = 32; 1.59 + for (size_t i = 0 ; i < 32 ; i++) { 1.60 + ucx_array_at_int(array, i) = ((i%2==0)?-1:1) * ((int) i); 1.61 + ucx_array_at_int(expected, i) = (-30+2*i) - (i > 15 ? 1 : 0); 1.62 + } 1.63 + 1.64 + ucx_array_sort(array, ucx_cmp_int, NULL); 1.65 + UCX_TEST_ASSERT(ucx_array_equals(array, expected, NULL, NULL), 1.66 + "failed for bigger arrays"); 1.67 UCX_TEST_END 1.68 1.69 ucx_array_free(&expected);