Eo: Added test to the special eina value type.
authorTom Hacohen <tom@stosb.com>
Wed, 24 Apr 2013 15:45:34 +0000 (16:45 +0100)
committerTom Hacohen <tom@stosb.com>
Wed, 24 Apr 2013 15:45:41 +0000 (16:45 +0100)
src/Makefile_Eo.am
src/tests/eo/suite/eo_suite.c
src/tests/eo/suite/eo_suite.h
src/tests/eo/suite/eo_test_class_simple.c
src/tests/eo/suite/eo_test_value.c [new file with mode: 0644]

index 1e200f3..e955632 100644 (file)
@@ -84,6 +84,7 @@ tests/eo/suite/eo_suite.c \
 tests/eo/suite/eo_suite.h \
 tests/eo/suite/eo_test_class_errors.c \
 tests/eo/suite/eo_test_general.c \
+tests/eo/suite/eo_test_value.c \
 tests/eo/suite/eo_test_init.c
 tests_eo_eo_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
 -DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eo\" \
index 5194b32..9d040d3 100644 (file)
@@ -20,6 +20,7 @@ static const Eo_Test_Case etc[] = {
   { "Eo init", eo_test_init },
   { "Eo general", eo_test_general },
   { "Eo class errors", eo_test_class_errors },
+  { "Eo eina value", eo_test_value },
   { NULL, NULL }
 };
 
index 9d79f42..c26db96 100644 (file)
@@ -6,6 +6,6 @@
 void eo_test_init(TCase *tc);
 void eo_test_general(TCase *tc);
 void eo_test_class_errors(TCase *tc);
-
+void eo_test_value(TCase *tc);
 
 #endif /* _EO_SUITE_H */
index e21c54f..f691bda 100644 (file)
@@ -40,9 +40,19 @@ _class_hi_print(const Eo_Class *klass, va_list *list)
 }
 
 static void
+_dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
+{
+   Eo_Dbg_Info *root = (Eo_Dbg_Info *) va_arg(*list, Eo_Dbg_Info *);
+   eo_do_super(eo_obj, MY_CLASS, eo_dbg_info_get(root));
+   Eo_Dbg_Info *group = EO_DBG_INFO_LIST_APPEND(root, "Test list");
+   EO_DBG_INFO_APPEND(group, "Test", EINA_VALUE_TYPE_INT, 8);
+}
+
+static void
 _class_constructor(Eo_Class *klass)
 {
    const Eo_Op_Func_Description func_desc[] = {
+        EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DBG_INFO_GET), _dbg_info_get),
         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print),
         EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT), _class_hi_print),
diff --git a/src/tests/eo/suite/eo_test_value.c b/src/tests/eo/suite/eo_test_value.c
new file mode 100644 (file)
index 0000000..71f2a00
--- /dev/null
@@ -0,0 +1,54 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include "Eo.h"
+#include "eo_suite.h"
+#include "eo_test_class_simple.h"
+
+START_TEST(eo_value)
+{
+   eo_init();
+   char *str, *str2;
+   Eina_Value_List eo_list;
+
+   Eina_Value val2, eo_val;
+   void *tmpp = NULL;
+   Eo_Dbg_Info *eo_dbg_info, *tmp_dbg_info;
+   Eo *obj = eo_add(SIMPLE_CLASS, NULL);
+
+   eo_dbg_info = EO_DBG_INFO_LIST_APPEND(NULL, "Root");
+   fail_if(!eo_do(obj, eo_dbg_info_get(eo_dbg_info)));
+   fail_if(!eo_dbg_info);
+   ck_assert_str_eq(eo_dbg_info->name, "Root");
+   str = eina_value_to_string(&eo_dbg_info->value);
+   ck_assert_str_eq(str, "[[8]]");
+
+   eina_value_copy(&eo_dbg_info->value, &val2);
+   str2 = eina_value_to_string(&val2);
+   ck_assert_str_eq(str, str2);
+
+   eina_value_get(&val2, &eo_val);
+   eina_value_pget(&eo_val, &tmpp);
+   fail_if(!tmpp);
+   eina_value_free(&val2);
+
+   eina_value_setup(&val2, EINA_VALUE_TYPE_INT);
+   fail_if(eina_value_convert(&eo_dbg_info->value, &val2));
+   eina_value_free(&val2);
+
+   free(str);
+   free(str2);
+   eo_dbg_info_free(eo_dbg_info);
+   eo_unref(obj);
+
+   eo_shutdown();
+}
+END_TEST
+
+void eo_test_value(TCase *tc)
+{
+   tcase_add_test(tc, eo_value);
+}