[empathy] Add parser tests
- From: Xavier Claessens <xclaesse src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [empathy] Add parser tests
- Date: Thu, 26 Nov 2009 09:20:32 +0000 (UTC)
commit 8ab216aca28acaa857b4b7faa606cd3af26b6cd9
Author: Xavier Claessens <xclaesse gmail com>
Date: Tue Nov 24 14:32:00 2009 +0100
Add parser tests
tests/.gitignore | 1 +
tests/Makefile.am | 6 +++-
tests/empathy-parser-test.c | 66 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 1 deletions(-)
---
diff --git a/tests/.gitignore b/tests/.gitignore
index 73a1924..f3af9c7 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -5,4 +5,5 @@ empathy-irc-network-test
empathy-irc-network-manager-test
empathy-chatroom-test
empathy-chatroom-manager-test
+empathy-parser-test
test-report.xml
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 25e3994..9367615 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -27,7 +27,8 @@ TEST_PROGS = \
empathy-irc-network-test \
empathy-irc-network-manager-test \
empathy-chatroom-test \
- empathy-chatroom-manager-test
+ empathy-chatroom-manager-test \
+ empathy-parser-test
empathy_utils_test_SOURCES = empathy-utils-test.c \
test-helper.c test-helper.h
@@ -50,6 +51,9 @@ empathy_chatroom_test_SOURCES = empathy-chatroom-test.c \
empathy_chatroom_manager_test_SOURCES = empathy-chatroom-manager-test.c \
test-helper.c test-helper.h
+empathy_parser_test_SOURCES = empathy-parser-test.c \
+ test-helper.c test-helper.h
+
check_PROGRAMS = $(TEST_PROGS)
TESTS_ENVIRONMENT = EMPATHY_SRCDIR= abs_top_srcdir@ \
diff --git a/tests/empathy-parser-test.c b/tests/empathy-parser-test.c
new file mode 100644
index 0000000..e180725
--- /dev/null
+++ b/tests/empathy-parser-test.c
@@ -0,0 +1,66 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "test-helper.h"
+
+#define DEBUG_FLAG EMPATHY_DEBUG_TESTS
+#include <libempathy/empathy-debug.h>
+
+#include <libempathy-gtk/empathy-ui-utils.h>
+
+static void
+test_replace_link (GString *string,
+ const gchar *text,
+ gssize len,
+ gpointer user_data)
+{
+ g_string_append_c (string, '[');
+ g_string_append_len (string, text, len);
+ g_string_append_c (string, ']');
+}
+
+static void
+test_parsers (void)
+{
+ guint i;
+ gchar *tests[] =
+ {
+ "http://foo.com", "[http://foo.com]",
+ NULL, NULL
+ };
+ EmpathyStringParser parsers[] =
+ {
+ {empathy_string_match_link, test_replace_link},
+ {NULL, NULL}
+ };
+
+ for (i = 0; tests[i] != NULL; i += 2)
+ {
+ GString *string;
+
+ string = g_string_new (NULL);
+ empathy_string_parser_substr (string, tests[i], -1, parsers);
+
+ DEBUG ("'%s' => '%s'", tests[i], string->str);
+ g_assert_cmpstr (tests[i + 1], ==, string->str);
+
+ g_string_free (string, TRUE);
+ }
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ int result;
+
+ test_init (argc, argv);
+
+ g_test_add_func ("/parsers", test_parsers);
+
+ result = g_test_run ();
+ test_deinit ();
+
+ return result;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]