]> git.0d.be Git - empathy.git/blobdiff - tests/empathy-parser-test.c
Updated Galician translations
[empathy.git] / tests / empathy-parser-test.c
index 001882863501e9dd734646c8a630d769b5bd5834..5713d967c7302cd498265f889c04d8924ecc32c1 100644 (file)
@@ -9,7 +9,7 @@
 #define DEBUG_FLAG EMPATHY_DEBUG_TESTS
 #include <libempathy/empathy-debug.h>
 
-#include <libempathy-gtk/empathy-ui-utils.h>
+#include <libempathy-gtk/empathy-string-parser.h>
 
 static void
 test_replace_match (const gchar *text,
@@ -24,17 +24,6 @@ test_replace_match (const gchar *text,
   g_string_append_c (string, ']');
 }
 
-static void
-test_replace_verbatim (const gchar *text,
-                       gssize len,
-                       gpointer match_data,
-                       gpointer user_data)
-{
-  GString *string = user_data;
-
-  g_string_append_len (string, text, len);
-}
-
 static void
 test_parsers (void)
 {
@@ -70,25 +59,29 @@ test_parsers (void)
       "Foo (www.foo.com)", "Foo ([www.foo.com])",
       "Foo {www.foo.com}", "Foo {[www.foo.com]}",
       "Foo [www.foo.com]", "Foo [[www.foo.com]]",
-      "Foo <www.foo.com>", "Foo <[www.foo.com]>",
-      "Foo \"www.foo.com\"", "Foo \"[www.foo.com]\"",
+      "Foo <www.foo.com>", "Foo &lt;[www.foo.com]&gt;",
+      "Foo \"www.foo.com\"", "Foo &quot;[www.foo.com]&quot;",
       "Foo (www.foo.com/bar(123)baz)", "Foo ([www.foo.com/bar(123)baz])",
-      "<a href=\"http://foo.com\">bar</a>", "<a href=\"[http://foo.com]\">bar</a>",
+      "<a href=\"http://foo.com\">bar</a>", "&lt;a href=&quot;[http://foo.com]&quot;&gt;bar&lt;/a&gt;",
       "Foo (user@server.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>", "Foo <[user@server.com]>",
-      "Foo \"user@server.com\"", "Foo \"[user@server.com]\"",
+      "Foo <user@server.com>", "Foo &lt;[user@server.com]&gt;",
+      "Foo \"user@server.com\"", "Foo &quot;[user@server.com]&quot;",
 
       /* Basic smileys */
       "a:)b", "a[:)]b",
       ">:)", "[>:)]",
-      ">:(", ">[:(]",
+      ">:(", "&gt;[:(]",
 
       /* Smileys and links mixed */
       ":)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)])",
@@ -102,11 +95,10 @@ test_parsers (void)
     {
       {empathy_string_match_link, test_replace_match},
       {empathy_string_match_smiley, test_replace_match},
-      {empathy_string_match_all, test_replace_verbatim},
+      {empathy_string_match_all, empathy_string_replace_escaped},
       {NULL, NULL}
     };
   guint i;
-  gboolean failed = FALSE;
 
   DEBUG ("Started");
   for (i = 0; tests[i] != NULL; i += 2)
@@ -119,13 +111,10 @@ test_parsers (void)
 
       ok = !tp_strdiff (tests[i + 1], string->str);
       DEBUG ("'%s' => '%s': %s", tests[i], string->str, ok ? "OK" : "FAILED");
-      if (!ok)
-        failed = TRUE;
+      g_assert (ok);
 
       g_string_free (string, TRUE);
     }
-
-  g_assert (!failed);
 }
 
 int