summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-11-15 15:38:40 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-11-23 10:13:52 -0800
commita8f520188a19f722d4ae6dee6246d37cb46bb975 (patch)
treeb72107d23a56ffb4f682d4ae9f141261b0741bf9 /src
parent6b26b3330e8fddf56c8a1105c7145b4c42e9f0ac (diff)
eina: add test for Eina_Iterator over pure C array.
Reviewed-by: Vitor Sousa da Silva <vitorsousa@expertisesolutions.com.br> Differential Revision: https://phab.enlightenment.org/D7285
Diffstat (limited to 'src')
-rw-r--r--src/lib/eina/eina_iterator.h3
-rw-r--r--src/tests/eina/eina_test_iterator.c18
2 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/eina/eina_iterator.h b/src/lib/eina/eina_iterator.h
index 1bed2bd33b..7f1e94cb02 100644
--- a/src/lib/eina/eina_iterator.h
+++ b/src/lib/eina/eina_iterator.h
@@ -289,6 +289,7 @@ EAPI Eina_Bool eina_iterator_unlock(Eina_Iterator *iterator) EINA_ARG_NONNULL(1)
289 * NUL-terminated C array. 289 * NUL-terminated C array.
290 * 290 *
291 * @param[in] array The NUL-terminated array 291 * @param[in] array The NUL-terminated array
292 * @return The iterator that will walk over the array.
292 * 293 *
293 * You can create it like this: 294 * You can create it like this:
294 * int array[] = {1, 2, 3, 4}; 295 * int array[] = {1, 2, 3, 4};
@@ -305,6 +306,7 @@ EAPI Eina_Iterator *eina_carray_iterator_new(void** array) EINA_ARG_NONNULL(1) E
305 * C array of specified size. 306 * C array of specified size.
306 * 307 *
307 * @param[in] array The array 308 * @param[in] array The array
309 * @return The iterator that will walk over the array.
308 * 310 *
309 * You can create it like this: 311 * You can create it like this:
310 * int array[] = {1, 2, 3, 4}; 312 * int array[] = {1, 2, 3, 4};
@@ -321,6 +323,7 @@ EAPI Eina_Iterator *eina_carray_length_iterator_new(void** array, unsigned int s
321 * NUL-terminated C array. 323 * NUL-terminated C array.
322 * 324 *
323 * @param[in] array The NUL-terminated array 325 * @param[in] array The NUL-terminated array
326 * @return The iterator that will walk over the array.
324 * 327 *
325 * You can create it like this: 328 * You can create it like this:
326 * int array[] = {1, 2, 3, 4}; 329 * int array[] = {1, 2, 3, 4};
diff --git a/src/tests/eina/eina_test_iterator.c b/src/tests/eina/eina_test_iterator.c
index c60139e9e2..14650621ca 100644
--- a/src/tests/eina/eina_test_iterator.c
+++ b/src/tests/eina/eina_test_iterator.c
@@ -612,6 +612,23 @@ EFL_START_TEST(eina_iterator_rbtree_simple)
612} 612}
613EFL_END_TEST 613EFL_END_TEST
614 614
615EFL_START_TEST(eina_iterator_carray_length)
616{
617 int array[] = { 1, 4, 9, 16 };
618 Eina_Iterator *it;
619 int i;
620 int j = 1;
621
622 it = EINA_C_ARRAY_ITERATOR_NEW(array);
623 EINA_ITERATOR_FOREACH(it, i)
624 {
625 fail_if(i != j * j);
626 j++;
627 }
628 eina_iterator_free(it);
629}
630EFL_END_TEST
631
615void 632void
616eina_test_iterator(TCase *tc) 633eina_test_iterator(TCase *tc)
617{ 634{
@@ -623,4 +640,5 @@ eina_test_iterator(TCase *tc)
623 tcase_add_test(tc, eina_iterator_rbtree_simple); 640 tcase_add_test(tc, eina_iterator_rbtree_simple);
624 tcase_add_test(tc, eina_iterator_filter_simple); 641 tcase_add_test(tc, eina_iterator_filter_simple);
625 tcase_add_test(tc, eina_iterator_filter_free); 642 tcase_add_test(tc, eina_iterator_filter_free);
643 tcase_add_test(tc, eina_iterator_carray_length);
626} 644}