eina: add test cases for Eina_Trash
authorkabeer khan <kabeer.khan@samsung.com>
Mon, 22 Sep 2014 12:16:00 +0000 (14:16 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Mon, 22 Sep 2014 12:59:27 +0000 (14:59 +0200)
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>
src/Makefile_Eina.am
src/tests/eina/eina_suite.c
src/tests/eina/eina_suite.h
src/tests/eina/eina_test_trash.c [new file with mode: 0644]

index ada2761..fe12abb 100644 (file)
@@ -268,6 +268,7 @@ tests/eina/eina_test_value.c \
 tests/eina/eina_test_cow.c \
 tests/eina/eina_test_barrier.c \
 tests/eina/eina_test_tmpstr.c \
+tests/eina/eina_test_trash.c \
 tests/eina/eina_test_lock.c
 # tests/eina/eina_test_model.c
 
index 8ed038a..ae849a2 100644 (file)
@@ -75,6 +75,7 @@ static const Eina_Test_Case etc[] = {
    { "Tmp String", eina_test_tmpstr },
    { "Locking", eina_test_locking },
    { "ABI", eina_test_abi },
+   { "Trash", eina_test_trash },
    { NULL, NULL }
 };
 
index 4a3648a..bc81a7c 100644 (file)
@@ -62,5 +62,6 @@ void eina_test_barrier(TCase *tc);
 void eina_test_tmpstr(TCase *tc);
 void eina_test_locking(TCase *tc);
 void eina_test_abi(TCase *tc);
+void eina_test_trash(TCase *tc);
 
 #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 (file)
index 0000000..b56d4af
--- /dev/null
@@ -0,0 +1,79 @@
+/* EINA - EFL data type library
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library;
+ * if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "eina_suite.h"
+#include "Eina.h"
+
+START_TEST(trash_simple)
+{
+   Eina_Trash *trash;
+   unsigned int i;
+   Eina_Array *array;
+   int inp_int = 9;
+   int inp_char = inp_int + '0';
+   void *data;
+   eina_init();
+   
+   trash = calloc(1, sizeof(Eina_Trash));
+   fail_if(trash == NULL);     
+   eina_trash_init(&trash);
+
+   for (i = 1; i < 51; ++i)
+     {
+        array = eina_array_new(1);
+        fail_if(!array);
+        eina_array_push(array, &inp_int);
+        eina_trash_push(&trash, array);
+        array = eina_array_new(1);
+        fail_if(!array);
+        eina_array_push(array, &inp_char);
+        eina_trash_push(&trash, array);
+     }
+
+   data = eina_trash_pop(&trash);
+   fail_if(!data);
+   fail_if(*((char *)eina_array_data_get(data, 0)) != inp_char);
+   data = eina_trash_pop(&trash);
+   fail_if(!data);
+   fail_if(*((int *)eina_array_data_get(data, 0)) != inp_int); 
+   free(data);
+  
+   i = 0;
+   EINA_TRASH_CLEAN(&trash, data)
+     {
+        fail_if(!data);
+        free(data);
+        ++i;
+     }
+
+   fail_if(i != 98);
+   eina_shutdown();
+}
+END_TEST
+
+void
+eina_test_trash(TCase *tc)
+{
+   tcase_add_test(tc, trash_simple);
+}
+