tests/test_list.c

changeset 850
b2bc48c2b251
parent 834
04c53b3c8378
child 853
d4baf4dd55c3
equal deleted inserted replaced
849:edb9f875b7f9 850:b2bc48c2b251
1205 roll_out_test_combos(iterator, { 1205 roll_out_test_combos(iterator, {
1206 const size_t len = 50; 1206 const size_t len = 50;
1207 int *testdata = int_test_data_added_to_list(list, isptrlist, len); 1207 int *testdata = int_test_data_added_to_list(list, isptrlist, len);
1208 1208
1209 CxIterator iter = cxListIterator(list); 1209 CxIterator iter = cxListIterator(list);
1210 CX_TEST_ASSERT(iter.elem_size == list->item_size);
1211 CX_TEST_ASSERT(iter.elem_count == list->size);
1210 size_t i = 0; 1212 size_t i = 0;
1211 cx_foreach(int*, x, iter) { 1213 cx_foreach(int*, x, iter) {
1212 CX_TEST_ASSERT(i == iter.index); 1214 CX_TEST_ASSERT(i == iter.index);
1213 CX_TEST_ASSERT(*x == testdata[iter.index]); 1215 CX_TEST_ASSERT(*x == testdata[iter.index]);
1214 i++; 1216 i++;
1221 i--; 1223 i--;
1222 } 1224 }
1223 CX_TEST_ASSERT(i == 0); 1225 CX_TEST_ASSERT(i == 0);
1224 i = len / 2; 1226 i = len / 2;
1225 CxMutIterator mut_iter = cxListMutIteratorAt(list, i); 1227 CxMutIterator mut_iter = cxListMutIteratorAt(list, i);
1228 CX_TEST_ASSERT(mut_iter.elem_size == list->item_size);
1229 CX_TEST_ASSERT(mut_iter.elem_count == list->size);
1226 size_t j = 0; 1230 size_t j = 0;
1227 cx_foreach(int*, x, mut_iter) { 1231 cx_foreach(int*, x, mut_iter) {
1228 CX_TEST_ASSERT(mut_iter.index == len / 2 + j / 2); 1232 CX_TEST_ASSERT(mut_iter.index == len / 2 + j / 2);
1229 CX_TEST_ASSERT(*x == testdata[i]); 1233 CX_TEST_ASSERT(*x == testdata[i]);
1230 if (i % 2 == 1) cxIteratorFlagRemoval(mut_iter); 1234 if (i % 2 == 1) cxIteratorFlagRemoval(mut_iter);

mercurial