test/array_tests.c

branch
feature/array
changeset 350
82a88d938108
parent 344
320b962afaf9
child 353
135ce35d5108
equal deleted inserted replaced
349:05957b1d10a5 350:82a88d938108
159 159
160 ucx_array_free(&array); 160 ucx_array_free(&array);
161 } 161 }
162 162
163 UCX_TEST(test_ucx_array_equals) { 163 UCX_TEST(test_ucx_array_equals) {
164 UcxArray a1 = ucx_array_new(16, sizeof(int)); 164 UcxArray a1 = ucx_array_new(16, sizeof(int32_t));
165 UcxArray a2 = ucx_array_new(16, sizeof(int)); 165 UcxArray a2 = ucx_array_new(16, sizeof(int32_t));
166 UcxArray a3 = ucx_array_new(16, sizeof(long int)); 166 UcxArray a3 = ucx_array_new(16, sizeof(int64_t));
167 UcxArray a4 = ucx_array_new(16, sizeof(int)); 167 UcxArray a4 = ucx_array_new(16, sizeof(int32_t));
168 168
169 int *intelems; 169 int32_t *intelems;
170 long int *longintelems; 170 int64_t *longintelems;
171 171
172 a1.size = 5; 172 a1.size = 5;
173 intelems = a1.data; 173 intelems = a1.data;
174 intelems[0] = 47; 174 intelems[0] = 47;
175 intelems[1] = 11; 175 intelems[1] = 11;
198 intelems[3] = 8; 198 intelems[3] = 8;
199 intelems[4] = 15; 199 intelems[4] = 15;
200 200
201 UCX_TEST_BEGIN 201 UCX_TEST_BEGIN
202 202
203 UCX_TEST_ASSERT(ucx_array_equals(a1, a2, ucx_cmp_int, NULL), "failed"); 203 UCX_TEST_ASSERT(ucx_array_equals(a1, a2, ucx_cmp_int32, NULL), "failed");
204 UCX_TEST_ASSERT(!ucx_array_equals(a1, a4, ucx_cmp_int, NULL), "failed"); 204 UCX_TEST_ASSERT(!ucx_array_equals(a1, a4, ucx_cmp_int32, NULL), "failed");
205 UCX_TEST_ASSERT(!ucx_array_equals(a4, a1, ucx_cmp_int, NULL), "failed"); 205 UCX_TEST_ASSERT(!ucx_array_equals(a4, a1, ucx_cmp_int32, NULL), "failed");
206 UCX_TEST_ASSERT(!ucx_array_equals(a1, a3, ucx_cmp_int, NULL), 206 UCX_TEST_ASSERT(!ucx_array_equals(a1, a3, ucx_cmp_int64, NULL),
207 "comparing arrays of different element size shall fail"); 207 "comparing arrays of different element size shall fail");
208 UCX_TEST_ASSERT(!ucx_array_equals(a3, a1, ucx_cmp_int, NULL), 208 UCX_TEST_ASSERT(!ucx_array_equals(a3, a1, ucx_cmp_int64, NULL),
209 "comparing arrays of different element size shall fail"); 209 "comparing arrays of different element size shall fail");
210 210
211 UCX_TEST_ASSERT(ucx_array_equals(a1, a2, NULL, NULL), 211 UCX_TEST_ASSERT(ucx_array_equals(a1, a2, NULL, NULL),
212 "compare using memcmp() failed"); 212 "compare using memcmp() failed");
213 UCX_TEST_ASSERT(!ucx_array_equals(a1, a4, NULL, NULL), 213 UCX_TEST_ASSERT(!ucx_array_equals(a1, a4, NULL, NULL),

mercurial