eo2: add tests for method call error msgs

This commit is contained in:
Jérémy Zurcher 2014-01-08 14:48:36 +01:00 committed by Tom Hacohen
parent d23b9ffd23
commit 2fb5a54610
6 changed files with 81 additions and 0 deletions

View File

@ -96,6 +96,7 @@ tests/eo/suite/eo_suite.h \
tests/eo/suite/eo_error_msgs.h \
tests/eo/suite/eo_error_msgs.c \
tests/eo/suite/eo_test_class_errors.c \
tests/eo/suite/eo_test_call_errors.c \
tests/eo/suite/eo_test_general.c \
tests/eo/suite/eo_test_value.c \
tests/eo/suite/eo_test_init.c

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 call errors", eo_test_call_errors },
{ "Eo eina value", eo_test_value },
{ NULL, NULL }
};

View File

@ -6,6 +6,7 @@
void eo_test_init(TCase *tc);
void eo_test_general(TCase *tc);
void eo_test_class_errors(TCase *tc);
void eo_test_call_errors(TCase *tc);
void eo_test_value(TCase *tc);
#endif /* _EO_SUITE_H */

View File

@ -0,0 +1,73 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include "Eo.h"
#include "eo_suite.h"
#include "eo_error_msgs.h"
#include "eo_test_class_simple.h"
static struct log_ctx ctx;
START_TEST(eo_pure_virtual_fct_call)
{
eo_init();
eina_log_print_cb_set(eo_test_print_cb, &ctx);
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
fail_if(!obj);
TEST_EO_ERROR("_eo2_call_resolve", "in %s:%d: you called a pure virtual func '%s' (%d).");
eo2_do(obj, simple_pure_virtual());
fail_unless(ctx.did);
eo_unref(obj);
eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
eo_shutdown();
}
END_TEST
START_TEST(eo_api_not_implemented_call)
{
eo_init();
eina_log_print_cb_set(eo_test_print_cb, &ctx);
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
fail_if(!obj);
TEST_EO_ERROR("_eo2_api_op_id_get", "in %s:%d: unable to resolve %s api func %p.");
eo2_do(obj, simple_no_implementation());
fail_unless(ctx.did);
eo_unref(obj);
eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
eo_shutdown();
}
END_TEST
START_TEST(eo_op_not_found_in_super)
{
eo_init();
eina_log_print_cb_set(eo_test_print_cb, &ctx);
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
fail_if(!obj);
TEST_EO_ERROR("_eo2_call_resolve", "in %s:%d: func '%s' (%d) could not be resolved for class '%s' for super of '%s'.");
eo2_do_super(obj, SIMPLE_CLASS, simple_a_set(10));
fail_unless(ctx.did);
eo_unref(obj);
eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
eo_shutdown();
}
END_TEST
void eo_test_call_errors(TCase *tc)
{
tcase_add_test(tc, eo_pure_virtual_fct_call);
tcase_add_test(tc, eo_api_not_implemented_call);
tcase_add_test(tc, eo_op_not_found_in_super);
}

View File

@ -73,6 +73,8 @@ EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a);
EO2_FUNC_BODY(simple_a_get, int, 0);
EO2_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE);
EO2_FUNC_BODY(simple_class_hi_print, Eina_Bool, EINA_FALSE);
EO2_VOID_FUNC_BODY(simple_pure_virtual);
EO2_VOID_FUNC_BODY(simple_no_implementation);
static Eo2_Op_Description op_descs[] = {
EO2_OP_FUNC_OVERRIDE(eo2_dbg_info_get, _dbg_info_get),
@ -81,6 +83,7 @@ static Eo2_Op_Description op_descs[] = {
EO2_OP_FUNC(simple_a_print, _a_print, "Print property a"),
EO2_OP_CLASS_FUNC(simple_class_hi_print, _class_hi_print, "Print property a"),
EO2_OP_FUNC(simple_recursive, _recursive, "Recursive function"),
EO2_OP_FUNC(simple_pure_virtual, NULL, "Pure Virtual function"),
EO2_OP_SENTINEL
};

View File

@ -11,6 +11,8 @@ EAPI int simple_a_get(void);
EAPI Eina_Bool simple_a_print(void);
EAPI Eina_Bool simple_class_hi_print(void);
EAPI void simple_recursive(int n);
EAPI void simple_pure_virtual(void);
EAPI void simple_no_implementation(void);
extern const Eo_Event_Description _EV_A_CHANGED;
#define EV_A_CHANGED (&(_EV_A_CHANGED))