summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkabeer khan <kabeer.khan@samsung.com>2014-09-22 14:16:00 +0200
committerCedric BAIL <cedric@osg.samsung.com>2014-09-22 14:59:27 +0200
commit3ad485b8e04f779868385efcf0956e961bd3e9e2 (patch)
tree086bfd8a21d9de7cc7d7db11e4fdc22ea90043d8
parentd4f92b987fb42d844008a86a0825a0eef8c98548 (diff)
eina: add test cases for Eina_Trash
Summary: New test case for Eina_Trash was added Signed-off-by: kabeer khan <kabeer.khan@samsung.com> Reviewers: raster, cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1460 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/Makefile_Eina.am1
-rw-r--r--src/tests/eina/eina_suite.c1
-rw-r--r--src/tests/eina/eina_suite.h1
-rw-r--r--src/tests/eina/eina_test_trash.c79
4 files changed, 82 insertions, 0 deletions
diff --git a/src/Makefile_Eina.am b/src/Makefile_Eina.am
index ada2761..fe12abb 100644
--- a/src/Makefile_Eina.am
+++ b/src/Makefile_Eina.am
@@ -268,6 +268,7 @@ tests/eina/eina_test_value.c \
268tests/eina/eina_test_cow.c \ 268tests/eina/eina_test_cow.c \
269tests/eina/eina_test_barrier.c \ 269tests/eina/eina_test_barrier.c \
270tests/eina/eina_test_tmpstr.c \ 270tests/eina/eina_test_tmpstr.c \
271tests/eina/eina_test_trash.c \
271tests/eina/eina_test_lock.c 272tests/eina/eina_test_lock.c
272# tests/eina/eina_test_model.c 273# tests/eina/eina_test_model.c
273 274
diff --git a/src/tests/eina/eina_suite.c b/src/tests/eina/eina_suite.c
index 8ed038a..ae849a2 100644
--- a/src/tests/eina/eina_suite.c
+++ b/src/tests/eina/eina_suite.c
@@ -75,6 +75,7 @@ static const Eina_Test_Case etc[] = {
75 { "Tmp String", eina_test_tmpstr }, 75 { "Tmp String", eina_test_tmpstr },
76 { "Locking", eina_test_locking }, 76 { "Locking", eina_test_locking },
77 { "ABI", eina_test_abi }, 77 { "ABI", eina_test_abi },
78 { "Trash", eina_test_trash },
78 { NULL, NULL } 79 { NULL, NULL }
79}; 80};
80 81
diff --git a/src/tests/eina/eina_suite.h b/src/tests/eina/eina_suite.h
index 4a3648a..bc81a7c 100644
--- a/src/tests/eina/eina_suite.h
+++ b/src/tests/eina/eina_suite.h
@@ -62,5 +62,6 @@ void eina_test_barrier(TCase *tc);
62void eina_test_tmpstr(TCase *tc); 62void eina_test_tmpstr(TCase *tc);
63void eina_test_locking(TCase *tc); 63void eina_test_locking(TCase *tc);
64void eina_test_abi(TCase *tc); 64void eina_test_abi(TCase *tc);
65void eina_test_trash(TCase *tc);
65 66
66#endif /* EINA_SUITE_H_ */ 67#endif /* EINA_SUITE_H_ */
diff --git a/src/tests/eina/eina_test_trash.c b/src/tests/eina/eina_test_trash.c
new file mode 100644
index 0000000..b56d4af
--- /dev/null
+++ b/src/tests/eina/eina_test_trash.c
@@ -0,0 +1,79 @@
1/* EINA - EFL data type library
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library;
15 * if not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifdef HAVE_CONFIG_H
19# include "config.h"
20#endif
21
22#include "eina_suite.h"
23#include "Eina.h"
24
25START_TEST(trash_simple)
26{
27 Eina_Trash *trash;
28 unsigned int i;
29 Eina_Array *array;
30 int inp_int = 9;
31 int inp_char = inp_int + '0';
32 void *data;
33
34 eina_init();
35
36 trash = calloc(1, sizeof(Eina_Trash));
37 fail_if(trash == NULL);
38 eina_trash_init(&trash);
39
40 for (i = 1; i < 51; ++i)
41 {
42 array = eina_array_new(1);
43 fail_if(!array);
44 eina_array_push(array, &inp_int);
45 eina_trash_push(&trash, array);
46 array = eina_array_new(1);
47 fail_if(!array);
48 eina_array_push(array, &inp_char);
49 eina_trash_push(&trash, array);
50 }
51
52 data = eina_trash_pop(&trash);
53 fail_if(!data);
54 fail_if(*((char *)eina_array_data_get(data, 0)) != inp_char);
55 data = eina_trash_pop(&trash);
56 fail_if(!data);
57 fail_if(*((int *)eina_array_data_get(data, 0)) != inp_int);
58 free(data);
59
60 i = 0;
61 EINA_TRASH_CLEAN(&trash, data)
62 {
63 fail_if(!data);
64 free(data);
65 ++i;
66 }
67
68 fail_if(i != 98);
69
70 eina_shutdown();
71}
72END_TEST
73
74void
75eina_test_trash(TCase *tc)
76{
77 tcase_add_test(tc, trash_simple);
78}
79