summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-01-08 14:48:36 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-01-08 14:48:36 +0100
commit1db763054cba0bd0ad7349c50cd5cbd84dfc7887 (patch)
tree89868f34054d2fb0d2cb0a68c3e3fc0da28af896
parente485552e848357cbd86787fff1ad2d0dc70473a2 (diff)
downloadefl-1db763054cba0bd0ad7349c50cd5cbd84dfc7887.tar.gz
eo2: add tests for method call error msgs
-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.h1
-rw-r--r--src/tests/eo/suite/eo_test_call_errors.c73
-rw-r--r--src/tests/eo/suite/eo_test_class_simple.c3
-rw-r--r--src/tests/eo/suite/eo_test_class_simple.h2
6 files changed, 81 insertions, 0 deletions
diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am
index 4933381a5c..60df0f7303 100644
--- a/src/Makefile_Eo.am
+++ b/src/Makefile_Eo.am
@@ -88,6 +88,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
diff --git a/src/tests/eo/suite/eo_suite.c b/src/tests/eo/suite/eo_suite.c
index 9d040d32cc..db303cfebb 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[] = {
{ "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 }
};
diff --git a/src/tests/eo/suite/eo_suite.h b/src/tests/eo/suite/eo_suite.h
index c26db968be..4a3c3b0f21 100644
--- a/src/tests/eo/suite/eo_suite.h
+++ b/src/tests/eo/suite/eo_suite.h
@@ -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 */
diff --git a/src/tests/eo/suite/eo_test_call_errors.c b/src/tests/eo/suite/eo_test_call_errors.c
new file mode 100644
index 0000000000..76a60ffc53
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_call_errors.c
@@ -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);
+}
diff --git a/src/tests/eo/suite/eo_test_class_simple.c b/src/tests/eo/suite/eo_test_class_simple.c
index d6fc49d233..89cd14e073 100644
--- a/src/tests/eo/suite/eo_test_class_simple.c
+++ b/src/tests/eo/suite/eo_test_class_simple.c
@@ -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
};
diff --git a/src/tests/eo/suite/eo_test_class_simple.h b/src/tests/eo/suite/eo_test_class_simple.h
index 03bbebdf43..7d774b761f 100644
--- a/src/tests/eo/suite/eo_test_class_simple.h
+++ b/src/tests/eo/suite/eo_test_class_simple.h
@@ -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))