summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2010-07-26 22:12:59 -0400
committerMatthias Clasen <mclasen@redhat.com>2010-07-30 19:51:18 -0400
commitc972d4df64299b335012b7af2b902589d191f8e0 (patch)
treedd760ef07594bc205222ca1e41c8999a3751f160 /tests
parenta804e22ed047514d7f267a8e991eca82bc5eaf57 (diff)
Move markup escape tests to test framework
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/markup-escape-test.c132
2 files changed, 0 insertions, 135 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bde34d6c7..49496b24b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -96,7 +96,6 @@ test_programs = \
mainloop-test \
mapping-test \
markup-collect \
- markup-escape-test \
module-test \
onceinit \
asyncqueue-test \
@@ -145,7 +144,6 @@ list_test_LDADD = $(progs_ldadd)
mainloop_test_LDADD = $(thread_ldadd)
markup_test_LDADD = $(progs_ldadd)
mapping_test_LDADD = $(progs_ldadd)
-markup_escape_test_LDADD = $(progs_ldadd)
module_test_LDADD = $(module_ldadd) $(module_test_exp)
module_test_LDFLAGS = $(G_MODULE_LDFLAGS)
onceinit_LDADD = $(thread_ldadd)
@@ -167,7 +165,6 @@ type_test_LDADD = $(progs_ldadd)
unicode_encoding_LDADD = $(progs_ldadd)
unicode_caseconv_LDADD = $(progs_ldadd)
unicode_collate_LDADD = $(progs_ldadd)
-markup_collect_LDADD = $(progs_ldadd)
noinst_LTLIBRARIES = libmoduletestplugin_a.la libmoduletestplugin_b.la
diff --git a/tests/markup-escape-test.c b/tests/markup-escape-test.c
deleted file mode 100644
index 27341623b..000000000
--- a/tests/markup-escape-test.c
+++ /dev/null
@@ -1,132 +0,0 @@
-#undef G_DISABLE_ASSERT
-#undef G_LOG_DOMAIN
-
-#include <stdarg.h>
-#include <string.h>
-#include <glib.h>
-
-static void test_format (const gchar *format,
- const gchar *expected, ...) G_GNUC_PRINTF (1, 3);
-
-static gboolean error = FALSE;
-
-static void
-test (const gchar *original,
- const gchar *expected)
-{
- gchar *result = g_markup_escape_text (original, -1);
-
- if (strcmp (result, expected) != 0)
- {
- g_printerr ("g_markup_escape_text(): expected '%s', got '%s'\n",
- expected, result);
- error = TRUE;
- }
-
- g_free (result);
-}
-
-static void
-test_unichar (gunichar c,
- gboolean entity)
-{
- gint len;
- gchar outbuf[7], expected[12];
-
- len = g_unichar_to_utf8 (c, outbuf);
- outbuf[len] = 0;
-
- if (entity)
- g_snprintf (expected, 12, "&#x%x;", c);
- else
- strcpy (expected, outbuf);
-
- test (outbuf, expected);
-}
-
-static void
-test_format (const gchar *format,
- const gchar *expected,
- ...)
-{
- gchar *result;
-
- va_list args;
-
- va_start (args, expected);
- result = g_markup_vprintf_escaped (format, args);
- va_end (args);
-
- if (strcmp (result, expected) != 0)
- {
- g_printerr ("g_markup_printf_escaped(): expected '%s', got '%s'\n",
- expected, result);
- error = TRUE;
- }
-
- g_free (result);
-}
-
-int main (int argc, char **argv)
-{
- /* Tests for g_markup_escape_text() */
- test ("&", "&amp;");
- test ("<", "&lt;");
- test (">", "&gt;");
- test ("'", "&apos;");
- test ("\"", "&quot;");
-
- test ("", "");
- test ("A", "A");
- test ("A&", "A&amp;");
- test ("&A", "&amp;A");
- test ("A&A", "A&amp;A");
- test ("&&A", "&amp;&amp;A");
- test ("A&&", "A&amp;&amp;");
- test ("A&&A", "A&amp;&amp;A");
- test ("A&A&A", "A&amp;A&amp;A");
- test ("A&#23;A", "A&amp;#23;A");
- test ("A&#xa;A", "A&amp;#xa;A");
- test_unichar (0x1, TRUE);
- test_unichar (0x8, TRUE);
- test_unichar (0x9, FALSE);
- test_unichar (0xa, FALSE);
- test_unichar (0xb, TRUE);
- test_unichar (0xc, TRUE);
- test_unichar (0xd, FALSE);
- test_unichar (0xe, TRUE);
- test_unichar (0x1f, TRUE);
- test_unichar (0x20, FALSE);
- test_unichar (0x7e, FALSE);
- test_unichar (0x7f, TRUE);
- test_unichar (0x84, TRUE);
- test_unichar (0x85, FALSE);
- test_unichar (0x86, TRUE);
- test_unichar (0x9f, TRUE);
- test_unichar (0xa0, FALSE);
-
- /* Tests for g_markup_printf_escaped() */
- test_format ("A", "A");
- test_format ("A%s", "A&amp;", "&");
- test_format ("%sA", "&amp;A", "&");
- test_format ("A%sA", "A&amp;A", "&");
- test_format ("%s%sA", "&amp;&amp;A", "&", "&");
- test_format ("A%s%s", "A&amp;&amp;", "&", "&");
- test_format ("A%s%sA", "A&amp;&amp;A", "&", "&");
- test_format ("A%sA%sA", "A&amp;A&amp;A", "&", "&");
-
- test_format ("%s", "&lt;B&gt;&amp;",
- "<B>&");
- test_format ("%c%c", "&lt;&amp;",
- '<', '&');
- test_format (".%c.%c.", ".&lt;.&amp;.",
- '<', '&');
- test_format ("%s", "",
- "");
- test_format ("%-5s", "A ",
- "A");
- test_format ("%2$s%1$s", "B.A.",
- "A.", "B.");
-
- return error ? 1 : 0;
-}