summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-01-08 14:10:39 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-01-08 14:10:39 +0100
commite485552e848357cbd86787fff1ad2d0dc70473a2 (patch)
treee21dfa1d4c26fc1a1b4f338a077db8fce839405a
parent9aa69058e9148841bdf89ec1fb513b72d4dc12ea (diff)
downloadefl-e485552e848357cbd86787fff1ad2d0dc70473a2.tar.gz
eo2: tests: extract mgs checks into eo_error_msgs.c|h
-rw-r--r--src/Makefile_Eo.am2
-rw-r--r--src/tests/eo/suite/eo_error_msgs.c53
-rw-r--r--src/tests/eo/suite/eo_error_msgs.h30
-rw-r--r--src/tests/eo/suite/eo_test_class_errors.c83
4 files changed, 93 insertions, 75 deletions
diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am
index 018eacc6e7..4933381a5c 100644
--- a/src/Makefile_Eo.am
+++ b/src/Makefile_Eo.am
@@ -85,6 +85,8 @@ tests/eo/suite/eo_test_class_simple.c \
tests/eo/suite/eo_test_class_simple.h \
tests/eo/suite/eo_suite.c \
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_general.c \
tests/eo/suite/eo_test_value.c \
diff --git a/src/tests/eo/suite/eo_error_msgs.c b/src/tests/eo/suite/eo_error_msgs.c
new file mode 100644
index 0000000000..ae5b5d0ddc
--- /dev/null
+++ b/src/tests/eo/suite/eo_error_msgs.c
@@ -0,0 +1,53 @@
+#include "eo_error_msgs.h"
+
+void
+eo_test_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED)
+{
+ struct log_ctx *myctx = data;
+
+ if (level > _EINA_LOG_MAX)
+ return;
+
+ ck_assert_int_eq(level, myctx->expected_level);
+ if (myctx->msg)
+ ck_assert_str_eq(myctx->msg, fmt);
+ ck_assert_str_eq(myctx->fnc, fnc);
+ myctx->did = EINA_TRUE;
+
+#ifdef SHOW_LOG
+ eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args);
+#else
+ (void)d;
+ (void)file;
+ (void)line;
+#endif
+}
+
+void
+eo_test_safety_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED)
+{
+ struct log_ctx *myctx = data;
+ va_list cp_args;
+ const char *str;
+
+ if (level > _EINA_LOG_MAX)
+ return;
+
+ va_copy(cp_args, args);
+ str = va_arg(cp_args, const char *);
+ va_end(cp_args);
+
+ ck_assert_int_eq(level, myctx->expected_level);
+ ck_assert_str_eq(fmt, "%s");
+ ck_assert_str_eq(myctx->msg, str);
+ ck_assert_str_eq(myctx->fnc, fnc);
+ myctx->did = EINA_TRUE;
+
+#ifdef SHOW_LOG
+ eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args);
+#else
+ (void)d;
+ (void)file;
+ (void)line;
+#endif
+}
diff --git a/src/tests/eo/suite/eo_error_msgs.h b/src/tests/eo/suite/eo_error_msgs.h
new file mode 100644
index 0000000000..c3690fd345
--- /dev/null
+++ b/src/tests/eo/suite/eo_error_msgs.h
@@ -0,0 +1,30 @@
+#ifndef _EO_ERROR_MSGS_H
+#define _EO_ERROR_MSGS_H
+
+#include "Eo.h"
+#include "eo_suite.h"
+
+/* The Max level to consider when working with the print cb. */
+#define _EINA_LOG_MAX 2
+/* #define SHOW_LOG 1 */
+
+struct log_ctx {
+ const char *msg;
+ const char *fnc;
+ Eina_Bool did;
+ int expected_level;
+};
+
+void
+eo_test_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED);
+
+void
+eo_test_safety_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED);
+
+#define TEST_EO_ERROR(fn, _msg) \
+ ctx.msg = _msg; \
+ ctx.fnc = fn; \
+ ctx.did = EINA_FALSE; \
+ ctx.expected_level = EINA_LOG_LEVEL_ERR
+
+#endif /* _EO_ERROR_MSGS_H */
diff --git a/src/tests/eo/suite/eo_test_class_errors.c b/src/tests/eo/suite/eo_test_class_errors.c
index abc839eacd..24a07f47e9 100644
--- a/src/tests/eo/suite/eo_test_class_errors.c
+++ b/src/tests/eo/suite/eo_test_class_errors.c
@@ -6,82 +6,15 @@
#include "Eo.h"
#include "eo_suite.h"
+#include "eo_error_msgs.h"
#include "eo_test_class_simple.h"
-/* The Max level to consider when working with the print cb. */
-#define _EINA_LOG_MAX 2
-
-struct log_ctx {
- const char *msg;
- const char *fnc;
- Eina_Bool did;
- int expected_level;
-};
-
static struct log_ctx ctx;
-static void
-_eo_test_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED)
-{
- struct log_ctx *myctx = data;
-
- if (level > _EINA_LOG_MAX)
- return;
-
- ck_assert_int_eq(level, myctx->expected_level);
- if (myctx->msg)
- ck_assert_str_eq(myctx->msg, fmt);
- ck_assert_str_eq(myctx->fnc, fnc);
- myctx->did = EINA_TRUE;
-
-#ifdef SHOW_LOG
- eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args);
-#else
- (void)d;
- (void)file;
- (void)line;
-#endif
-}
-
-static void
-_eo_test_safety_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED)
-{
- struct log_ctx *myctx = data;
- va_list cp_args;
- const char *str;
-
- if (level > _EINA_LOG_MAX)
- return;
-
- va_copy(cp_args, args);
- str = va_arg(cp_args, const char *);
- va_end(cp_args);
-
- ck_assert_int_eq(level, myctx->expected_level);
- ck_assert_str_eq(fmt, "%s");
- ck_assert_str_eq(myctx->msg, str);
- ck_assert_str_eq(myctx->fnc, fnc);
- myctx->did = EINA_TRUE;
-
-#ifdef SHOW_LOG
- eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args);
-#else
- (void)d;
- (void)file;
- (void)line;
-#endif
-}
-
-#define TEST_EO_ERROR(fn, _msg) \
- ctx.msg = _msg; \
- ctx.fnc = fn; \
- ctx.did = EINA_FALSE; \
- ctx.expected_level = EINA_LOG_LEVEL_ERR
-
START_TEST(eo_inherit_errors)
{
eo_init();
- eina_log_print_cb_set(_eo_test_print_cb, &ctx);
+ eina_log_print_cb_set(eo_test_print_cb, &ctx);
const Eo_Class *klass;
const Eo_Class *klass_mixin;
@@ -148,7 +81,7 @@ END_TEST
START_TEST(eo_inconsistent_mro)
{
eo_init();
- eina_log_print_cb_set(_eo_test_print_cb, &ctx);
+ eina_log_print_cb_set(eo_test_print_cb, &ctx);
const Eo_Class *klass;
const Eo_Class *klass_mixin;
@@ -230,7 +163,7 @@ static void _stub_class_constructor(Eo_Class *klass EINA_UNUSED) {}
START_TEST(eo_bad_interface)
{
eo_init();
- eina_log_print_cb_set(_eo_test_safety_print_cb, &ctx);
+ eina_log_print_cb_set(eo_test_safety_print_cb, &ctx);
const Eo_Class *klass;
@@ -279,7 +212,7 @@ void null_fct (void) {}
START_TEST(eo_null_api)
{
eo_init();
- eina_log_print_cb_set(_eo_test_print_cb, &ctx);
+ eina_log_print_cb_set(eo_test_print_cb, &ctx);
const Eo_Class *klass;
@@ -312,7 +245,7 @@ END_TEST
START_TEST(eo_wrong_override)
{
eo_init();
- eina_log_print_cb_set(_eo_test_print_cb, &ctx);
+ eina_log_print_cb_set(eo_test_print_cb, &ctx);
const Eo_Class *klass;
@@ -345,7 +278,7 @@ END_TEST
START_TEST(eo_api_redefined)
{
eo_init();
- eina_log_print_cb_set(_eo_test_print_cb, &ctx);
+ eina_log_print_cb_set(eo_test_print_cb, &ctx);
const Eo_Class *klass;
@@ -379,7 +312,7 @@ END_TEST
START_TEST(eo_dich_func_override)
{
eo_init();
- eina_log_print_cb_set(_eo_test_print_cb, &ctx);
+ eina_log_print_cb_set(eo_test_print_cb, &ctx);
const Eo_Class *klass;