Eo: Added test to the special eina value type.

This commit is contained in:
Tom Hacohen 2013-04-24 16:45:34 +01:00
parent b9e8a0e123
commit a26ed054a9
5 changed files with 67 additions and 1 deletions

View 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\" \

View 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 }
};

View 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 */

View File

@ -39,10 +39,20 @@ _class_hi_print(const Eo_Class *klass, va_list *list)
printf("Hi Print %s\n", eo_class_name_get(klass));
}
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),

View File

@ -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);
}