summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2012-10-05 14:49:17 +0900
committerAkira TAGOH <akira@tagoh.org>2012-10-05 14:49:17 +0900
commitade8ccaa16a6acb91816e48ca467a125b5c16141 (patch)
treeee702ede0406e992ffbe423430437332e7600db6 /tests
parent0a1d171e6d3c22f0829db0464e82bf3dccc07bb8 (diff)
another try to clean up glib dependencies
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/main.c61
-rw-r--r--tests/main.h15
3 files changed, 24 insertions, 53 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4330ea8..53c4044 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,7 +8,6 @@ INCLUDES = \
-DTEST_DATADIR="\"$(abs_top_builddir)/data\"" \
-DTEST_MODDIR="\"$(abs_top_builddir)/liblangtag/extensions/.libs\"" \
-D__LANGTAG_COMPILATION \
- $(GLIB_CFLAGS) \
$(CHECK_CFLAGS) \
$(NULL)
DEPS = \
diff --git a/tests/main.c b/tests/main.c
index 3528e32..ce05af3 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -18,80 +18,53 @@
#include <stdlib.h>
#include <unistd.h>
#include <check.h>
-#include <glib-object.h>
+#include "langtag.h"
+#include "lt-messages.h"
#include "main.h"
extern Suite *tester_suite(void);
-static GLogFunc old_logger = NULL;
-static GError *error = NULL;
-G_LOCK_DEFINE_STATIC(err);
+static lt_message_func_t old_logger = NULL;
+static lt_error_t *error = NULL;
/*
* Private functions
*/
static void
-logger(const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer user_data)
+logger(lt_message_type_t type,
+ lt_message_flags_t flags,
+ lt_message_category_t category,
+ const char *message,
+ lt_pointer_t user_data)
{
- gchar *prev = NULL;
-
- G_LOCK (err);
-
- if (error) {
- prev = g_strdup_printf("\n %s", error->message);
- g_error_free(error);
- error = NULL;
- }
- g_set_error(&error, TESTER_ERROR, log_level,
- "%s%s", message,
- (prev ? prev : ""));
- g_free(prev);
-
- G_UNLOCK (err);
+ lt_error_set(&error, type, message);
}
static void
init(int argc,
char **argv)
{
- old_logger = g_log_set_default_handler(logger, NULL);
+ old_logger = lt_message_set_default_handler(logger, NULL);
}
static void
fini(void)
{
+ tester_pop_error();
if (old_logger)
- g_log_set_default_handler(old_logger, NULL);
+ lt_message_set_default_handler(old_logger, NULL);
}
/*
* Public functions
*/
-GQuark
-tester_get_error_quark(void)
-{
- GQuark quark = 0;
-
- if (!quark)
- quark = g_quark_from_static_string("tester-error");
-
- return quark;
-}
-
-gchar *
+void
tester_pop_error(void)
{
- gchar *retval = NULL;
-
- if (error) {
- retval = g_strdup(error->message);
- g_clear_error(&error);
+ if (lt_error_is_set(error, LT_ERR_ANY)) {
+ lt_error_print(error, LT_ERR_ANY);
+ lt_error_clear(error);
}
-
- return retval;
}
int
diff --git a/tests/main.h b/tests/main.h
index 1b9753a..7ac0e86 100644
--- a/tests/main.h
+++ b/tests/main.h
@@ -15,9 +15,9 @@
#define __TEST_MAIN_H__
#include <check.h>
-#include <glib.h>
+#include <liblangtag/langtag.h>
-G_BEGIN_DECLS
+LT_BEGIN_DECLS
#define TESTER_ERROR tester_get_error_quark()
#define TDEF(fn) START_TEST (test_ ## fn)
@@ -26,12 +26,11 @@ G_BEGIN_DECLS
#define TNUL(obj) fail_unless((obj) != NULL, "Failed to create an object")
-void setup (void);
-void teardown (void);
-Suite *tester_suite (void);
-GQuark tester_get_error_quark(void);
-gchar *tester_pop_error (void) G_GNUC_MALLOC;
+void setup (void);
+void teardown (void);
+Suite *tester_suite (void);
+void tester_pop_error(void);
-G_END_DECLS
+LT_END_DECLS
#endif /* __TEST_MAIN_H__ */