+#include "config.h"
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <telepathy-glib/telepathy-glib.h>
+#include <tp-account-widgets/tpaw-string-parser.h>
+#include "empathy-string-parser.h"
#include "test-helper.h"
-#include <telepathy-glib/util.h>
-
#define DEBUG_FLAG EMPATHY_DEBUG_TESTS
-#include <libempathy/empathy-debug.h>
-
-#include <libempathy-gtk/empathy-string-parser.h>
+#include "empathy-debug.h"
static void
test_replace_match (const gchar *text,
"http://foo.com; bar", "[http://foo.com]; bar",
"http://foo.com: bar", "[http://foo.com]: bar",
"http://foo.com:bar", "[http://foo.com:bar]",
+ "http://apos'foo.com", "[http://apos'foo.com]",
+ "mailto:bar'?user@server.com", "[mailto:bar'?user@server.com]",
/* They are not links! */
"http://", "http[:/]/", /* Hm... */
"mailto:user@.com", "mailto:user@.com",
"user@.com", "user@.com",
- /* Links inside (), {}, [], <> or "" */
+ /* Links inside (), {}, [], <>, "" or '' */
/* FIXME: How to test if the ending ] is matched or not? */
"Foo (www.foo.com)", "Foo ([www.foo.com])",
"Foo {www.foo.com}", "Foo {[www.foo.com]}",
"Foo [user@server.com]", "Foo [[user@server.com]]",
"Foo <user@server.com>", "Foo <[user@server.com]>",
"Foo \"user@server.com\"", "Foo "[user@server.com]"",
+ "<a href='http://apos'foo.com'>bar</a>", "<a href='[http://apos'foo.com]'>bar</a>",
+ "Foo 'bar'?user@server.com'", "Foo '[bar'?user@server.com]'",
/* Basic smileys */
"a:)b", "a[:)]b",
":)http://foo.com", "[:)][http://foo.com]",
"a :) b http://foo.com c :( d www.test.com e", "a [:)] b [http://foo.com] c [:(] d [www.test.com] e",
+ /* '\r' should be stripped */
+ "badger\n\rmushroom", "badger\nmushroom",
+ "badger\r\nmushroom", "badger\nmushroom",
+
/* FIXME: Known issue: Brackets should be counted by the parser */
//"Foo www.bar.com/test(123)", "Foo [www.bar.com/test(123)]",
//"Foo (www.bar.com/test(123))", "Foo ([www.bar.com/test(123)])",
NULL, NULL
};
- EmpathyStringParser parsers[] =
+ TpawStringParser parsers[] =
{
- {empathy_string_match_link, test_replace_match},
+ {tpaw_string_match_link, test_replace_match},
{empathy_string_match_smiley, test_replace_match},
- {empathy_string_match_all, empathy_string_replace_escaped},
+ {tpaw_string_match_all, tpaw_string_replace_escaped},
{NULL, NULL}
};
guint i;
gboolean ok;
string = g_string_new (NULL);
- empathy_string_parser_substr (tests[i], -1, parsers, string);
+ tpaw_string_parser_substr (tests[i], -1, parsers, string);
ok = !tp_strdiff (tests[i + 1], string->str);
DEBUG ("'%s' => '%s': %s", tests[i], string->str, ok ? "OK" : "FAILED");