summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@free.fr>2019-09-14 10:54:05 -0700
committerCedric Bail <cedric.bail@free.fr>2019-09-19 14:37:41 -0700
commit9382bfc0bc1c6a5fb3aafce18094016b110036c0 (patch)
treed829f299356af2136ed3144887cb40b2f0dc884f /src/tests
parentbf12fe241ec04c81129faf9ccfa7438fa9a23062 (diff)
eina: add eina_mempool_iterator_new to slowly iterate every allocated pointer in a mempool.
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D9941
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/eina/eina_test_mempool.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/tests/eina/eina_test_mempool.c b/src/tests/eina/eina_test_mempool.c
index 78656cea53..c36bab1717 100644
--- a/src/tests/eina/eina_test_mempool.c
+++ b/src/tests/eina/eina_test_mempool.c
@@ -28,10 +28,12 @@ static void
28_eina_mempool_test(Eina_Mempool *mp, 28_eina_mempool_test(Eina_Mempool *mp,
29 Eina_Bool with_realloc, Eina_Bool with_gc, Eina_Bool accurate_from) 29 Eina_Bool with_realloc, Eina_Bool with_gc, Eina_Bool accurate_from)
30{ 30{
31 Eina_Iterator *it;
31 int *tbl[512]; 32 int *tbl[512];
33 int *ptr;
32 int i; 34 int i;
33 35
34 fail_if(!mp); 36 fail_if(!mp);
35 37
36 for (i = 0; i < 512; ++i) 38 for (i = 0; i < 512; ++i)
37 { 39 {
@@ -52,6 +54,20 @@ _eina_mempool_test(Eina_Mempool *mp,
52 fail_if(eina_mempool_from(mp, tbl[i]) != EINA_FALSE); 54 fail_if(eina_mempool_from(mp, tbl[i]) != EINA_FALSE);
53 } 55 }
54 56
57 it = eina_mempool_iterator_new(mp);
58 EINA_ITERATOR_FOREACH(it, ptr)
59 {
60 ck_assert_int_gt(*ptr, 255);
61 *ptr = 0;
62 }
63 eina_iterator_free(it);
64
65 if (it) // Only check if the mempool support iterator
66 {
67 for (; i < 512; ++i)
68 ck_assert_int_eq(*tbl[i], 0);
69 }
70
55 if (with_realloc) 71 if (with_realloc)
56 fail_if(eina_mempool_realloc(mp, tbl[500], 25) == NULL); 72 fail_if(eina_mempool_realloc(mp, tbl[500], 25) == NULL);
57 else 73 else