cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=a8f520188a19f722d4ae6dee6246d37cb46bb975

commit a8f520188a19f722d4ae6dee6246d37cb46bb975
Author: Cedric BAIL <[email protected]>
Date:   Thu Nov 15 15:38:40 2018 -0800

    eina: add test for Eina_Iterator over pure C array.
    
    Reviewed-by: Vitor Sousa da Silva <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D7285
---
 src/lib/eina/eina_iterator.h        |  3 +++
 src/tests/eina/eina_test_iterator.c | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)

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)
  * NUL-terminated C array.
  *
  * @param[in] array The NUL-terminated array
+ * @return The iterator that will walk over the array.
  *
  * You can create it like this:
  * int array[] = {1, 2, 3, 4};
@@ -305,6 +306,7 @@ EAPI Eina_Iterator *eina_carray_iterator_new(void** array) 
EINA_ARG_NONNULL(1) E
  * C array of specified size.
  *
  * @param[in] array The array
+ * @return The iterator that will walk over the array.
  *
  * You can create it like this:
  * int array[] = {1, 2, 3, 4};
@@ -321,6 +323,7 @@ EAPI Eina_Iterator *eina_carray_length_iterator_new(void** 
array, unsigned int s
  * NUL-terminated C array.
  *
  * @param[in] array The NUL-terminated array
+ * @return The iterator that will walk over the array.
  *
  * You can create it like this:
  * 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)
 }
 EFL_END_TEST
 
+EFL_START_TEST(eina_iterator_carray_length)
+{
+   int array[] = { 1, 4, 9, 16 };
+   Eina_Iterator *it;
+   int i;
+   int j = 1;
+
+   it = EINA_C_ARRAY_ITERATOR_NEW(array);
+   EINA_ITERATOR_FOREACH(it, i)
+     {
+        fail_if(i != j * j);
+        j++;
+     }
+   eina_iterator_free(it);
+}
+EFL_END_TEST
+
 void
 eina_test_iterator(TCase *tc)
 {
@@ -623,4 +640,5 @@ eina_test_iterator(TCase *tc)
    tcase_add_test(tc, eina_iterator_rbtree_simple);
    tcase_add_test(tc, eina_iterator_filter_simple);
    tcase_add_test(tc, eina_iterator_filter_free);
+   tcase_add_test(tc, eina_iterator_carray_length);
 }

-- 


Reply via email to