aboutsummaryrefslogtreecommitdiffstats
path: root/tests/empathy-parser-test.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-11-24 21:32:00 +0800
committerXavier Claessens <xclaesse@gmail.com>2009-11-25 01:29:45 +0800
commit8ab216aca28acaa857b4b7faa606cd3af26b6cd9 (patch)
treeb383866483197aa8ee2c2d8c4accc759e89d84f8 /tests/empathy-parser-test.c
parent2fc34dbe48ff603b99b6e56ce4ea94d6a3a8c450 (diff)
downloadgsoc2013-empathy-8ab216aca28acaa857b4b7faa606cd3af26b6cd9.tar
gsoc2013-empathy-8ab216aca28acaa857b4b7faa606cd3af26b6cd9.tar.gz
gsoc2013-empathy-8ab216aca28acaa857b4b7faa606cd3af26b6cd9.tar.bz2
gsoc2013-empathy-8ab216aca28acaa857b4b7faa606cd3af26b6cd9.tar.lz
gsoc2013-empathy-8ab216aca28acaa857b4b7faa606cd3af26b6cd9.tar.xz
gsoc2013-empathy-8ab216aca28acaa857b4b7faa606cd3af26b6cd9.tar.zst
gsoc2013-empathy-8ab216aca28acaa857b4b7faa606cd3af26b6cd9.zip
Add parser tests
Diffstat (limited to 'tests/empathy-parser-test.c')
-rw-r--r--tests/empathy-parser-test.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/empathy-parser-test.c b/tests/empathy-parser-test.c
new file mode 100644
index 000000000..e1807251d
--- /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;
+}