cedric pushed a commit to branch master.

commit 21505d1edf4217f57fceecca8b09a228afb88413
Author: Vladislav Brovko <[email protected]>
Date:   Mon Mar 11 10:44:52 2013 +0900

    eina: Eina_Tmpstr test for eina_tmpstr_add, eina_tmpstr_del.
    
    Signed-off-by: Cedric BAIL <[email protected]>
---
 src/Makefile_Eina.am              |  3 +-
 src/tests/eina/eina_suite.c       |  1 +
 src/tests/eina/eina_suite.h       |  1 +
 src/tests/eina/eina_test_tmpstr.c | 67 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/src/Makefile_Eina.am b/src/Makefile_Eina.am
index 80b6b68..df51312 100644
--- a/src/Makefile_Eina.am
+++ b/src/Makefile_Eina.am
@@ -263,7 +263,8 @@ tests/eina/eina_test_quadtree.c \
 tests/eina/eina_test_simple_xml_parser.c \
 tests/eina/eina_test_value.c \
 tests/eina/eina_test_cow.c \
-tests/eina/eina_test_barrier.c
+tests/eina/eina_test_barrier.c \
+tests/eina/eina_test_tmpstr.c
 # tests/eina/eina_test_model.c
 
 tests_eina_eina_suite_CPPFLAGS = \
diff --git a/src/tests/eina/eina_suite.c b/src/tests/eina/eina_suite.c
index 93c6b40..310e982 100644
--- a/src/tests/eina/eina_suite.c
+++ b/src/tests/eina/eina_suite.c
@@ -72,6 +72,7 @@ static const Eina_Test_Case etc[] = {
    // Disabling Eina_Model test
    //   { "Model", eina_test_model },
    { "Barrier", eina_test_barrier },
+   { "Tmp String", eina_test_tmpstr },
    { NULL, NULL }
 };
 
diff --git a/src/tests/eina/eina_suite.h b/src/tests/eina/eina_suite.h
index bdef0d5..85a32cf 100644
--- a/src/tests/eina/eina_suite.h
+++ b/src/tests/eina/eina_suite.h
@@ -59,5 +59,6 @@ void eina_test_value(TCase *tc);
 void eina_test_model(TCase *tc);
 void eina_test_cow(TCase *tc);
 void eina_test_barrier(TCase *tc);
+void eina_test_tmpstr(TCase *tc);
 
 #endif /* EINA_SUITE_H_ */
diff --git a/src/tests/eina/eina_test_tmpstr.c 
b/src/tests/eina/eina_test_tmpstr.c
new file mode 100644
index 0000000..ba3d3e7
--- /dev/null
+++ b/src/tests/eina/eina_test_tmpstr.c
@@ -0,0 +1,67 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2013 Vlad Brovko
+ *
+ * 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"
+#include "eina_tmpstr.h"
+
+START_TEST(tmpstr_simple)
+{
+   eina_init();
+
+   const int cnt_tmp_strings = 10;
+   const int max_str_len = 255;
+   char buf[max_str_len + 1];
+   Eina_Tmpstr *tmp_strings[cnt_tmp_strings];
+
+   // Add several tmp strings
+   for (int i = 0; i != cnt_tmp_strings; ++i)
+     {
+        snprintf(buf, max_str_len, "Tmp string %d", (i + 1));
+        tmp_strings[i] = eina_tmpstr_add(buf);
+
+        fail_if(strcmp(buf, tmp_strings[i]));
+     }
+
+   // Delete these tmp strings
+   for (int i = 0; i != cnt_tmp_strings; ++i)
+     {
+        snprintf(buf, max_str_len, "Tmp string %d", (cnt_tmp_strings - i - 1 + 
1));
+
+        fail_if(strcmp(buf, tmp_strings[cnt_tmp_strings - i - 1]));
+
+        eina_tmpstr_del(tmp_strings[cnt_tmp_strings - i - 1]);
+        tmp_strings[cnt_tmp_strings - i - 1] = 0;
+     }
+
+   // Delete non tmp string (should do nothing)
+   eina_tmpstr_del("Some non tmp string");
+
+   eina_shutdown();
+}
+END_TEST
+
+void
+eina_test_tmpstr(TCase *tc)
+{
+   tcase_add_test(tc, tmpstr_simple);
+}

-- 

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev

Reply via email to