summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2013-04-24 16:45:34 +0100
committerTom Hacohen <tom@stosb.com>2013-04-24 16:45:41 +0100
commita26ed054a963572a01a8d4b73aae78f99f78bf8e (patch)
tree312a592f043fff6df4424fceccba74a5aef6fd8c /src
parentb9e8a0e123b9c950d8dc611f1a01a182078ed8d2 (diff)
Eo: Added test to the special eina value type.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile_Eo.am1
-rw-r--r--src/tests/eo/suite/eo_suite.c1
-rw-r--r--src/tests/eo/suite/eo_suite.h2
-rw-r--r--src/tests/eo/suite/eo_test_class_simple.c10
-rw-r--r--src/tests/eo/suite/eo_test_value.c54
5 files changed, 67 insertions, 1 deletions
diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am
index 1e200f3..e955632 100644
--- a/src/Makefile_Eo.am
+++ b/src/Makefile_Eo.am
@@ -84,6 +84,7 @@ tests/eo/suite/eo_suite.c \
84tests/eo/suite/eo_suite.h \ 84tests/eo/suite/eo_suite.h \
85tests/eo/suite/eo_test_class_errors.c \ 85tests/eo/suite/eo_test_class_errors.c \
86tests/eo/suite/eo_test_general.c \ 86tests/eo/suite/eo_test_general.c \
87tests/eo/suite/eo_test_value.c \
87tests/eo/suite/eo_test_init.c 88tests/eo/suite/eo_test_init.c
88tests_eo_eo_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ 89tests_eo_eo_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
89-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eo\" \ 90-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eo\" \
diff --git a/src/tests/eo/suite/eo_suite.c b/src/tests/eo/suite/eo_suite.c
index 5194b32..9d040d3 100644
--- a/src/tests/eo/suite/eo_suite.c
+++ b/src/tests/eo/suite/eo_suite.c
@@ -20,6 +20,7 @@ static const Eo_Test_Case etc[] = {
20 { "Eo init", eo_test_init }, 20 { "Eo init", eo_test_init },
21 { "Eo general", eo_test_general }, 21 { "Eo general", eo_test_general },
22 { "Eo class errors", eo_test_class_errors }, 22 { "Eo class errors", eo_test_class_errors },
23 { "Eo eina value", eo_test_value },
23 { NULL, NULL } 24 { NULL, NULL }
24}; 25};
25 26
diff --git a/src/tests/eo/suite/eo_suite.h b/src/tests/eo/suite/eo_suite.h
index 9d79f42..c26db96 100644
--- a/src/tests/eo/suite/eo_suite.h
+++ b/src/tests/eo/suite/eo_suite.h
@@ -6,6 +6,6 @@
6void eo_test_init(TCase *tc); 6void eo_test_init(TCase *tc);
7void eo_test_general(TCase *tc); 7void eo_test_general(TCase *tc);
8void eo_test_class_errors(TCase *tc); 8void eo_test_class_errors(TCase *tc);
9 9void eo_test_value(TCase *tc);
10 10
11#endif /* _EO_SUITE_H */ 11#endif /* _EO_SUITE_H */
diff --git a/src/tests/eo/suite/eo_test_class_simple.c b/src/tests/eo/suite/eo_test_class_simple.c
index e21c54f..f691bda 100644
--- a/src/tests/eo/suite/eo_test_class_simple.c
+++ b/src/tests/eo/suite/eo_test_class_simple.c
@@ -40,9 +40,19 @@ _class_hi_print(const Eo_Class *klass, va_list *list)
40} 40}
41 41
42static void 42static void
43_dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
44{
45 Eo_Dbg_Info *root = (Eo_Dbg_Info *) va_arg(*list, Eo_Dbg_Info *);
46 eo_do_super(eo_obj, MY_CLASS, eo_dbg_info_get(root));
47 Eo_Dbg_Info *group = EO_DBG_INFO_LIST_APPEND(root, "Test list");
48 EO_DBG_INFO_APPEND(group, "Test", EINA_VALUE_TYPE_INT, 8);
49}
50
51static void
43_class_constructor(Eo_Class *klass) 52_class_constructor(Eo_Class *klass)
44{ 53{
45 const Eo_Op_Func_Description func_desc[] = { 54 const Eo_Op_Func_Description func_desc[] = {
55 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DBG_INFO_GET), _dbg_info_get),
46 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), 56 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
47 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print), 57 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print),
48 EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT), _class_hi_print), 58 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
index 0000000..71f2a00
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_value.c
@@ -0,0 +1,54 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <stdio.h>
6
7#include "Eo.h"
8#include "eo_suite.h"
9#include "eo_test_class_simple.h"
10
11START_TEST(eo_value)
12{
13 eo_init();
14 char *str, *str2;
15 Eina_Value_List eo_list;
16
17 Eina_Value val2, eo_val;
18 void *tmpp = NULL;
19 Eo_Dbg_Info *eo_dbg_info, *tmp_dbg_info;
20 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
21
22 eo_dbg_info = EO_DBG_INFO_LIST_APPEND(NULL, "Root");
23 fail_if(!eo_do(obj, eo_dbg_info_get(eo_dbg_info)));
24 fail_if(!eo_dbg_info);
25 ck_assert_str_eq(eo_dbg_info->name, "Root");
26 str = eina_value_to_string(&eo_dbg_info->value);
27 ck_assert_str_eq(str, "[[8]]");
28
29 eina_value_copy(&eo_dbg_info->value, &val2);
30 str2 = eina_value_to_string(&val2);
31 ck_assert_str_eq(str, str2);
32
33 eina_value_get(&val2, &eo_val);
34 eina_value_pget(&eo_val, &tmpp);
35 fail_if(!tmpp);
36 eina_value_free(&val2);
37
38 eina_value_setup(&val2, EINA_VALUE_TYPE_INT);
39 fail_if(eina_value_convert(&eo_dbg_info->value, &val2));
40 eina_value_free(&val2);
41
42 free(str);
43 free(str2);
44 eo_dbg_info_free(eo_dbg_info);
45 eo_unref(obj);
46
47 eo_shutdown();
48}
49END_TEST
50
51void eo_test_value(TCase *tc)
52{
53 tcase_add_test(tc, eo_value);
54}