summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2011-11-28 11:16:15 +0100
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2011-11-29 12:51:04 +0100
commit9905ee72891d4e16898f70d37a5bf4da65b438ec (patch)
treef10a99aa9ffc81e111120fef04498b30c5ecbd0a
parentf4900b0325ef211a0cef27620f436daeb6ecf6d3 (diff)
Add a test for filtering non-character unicode codepoints
-rw-r--r--tests/wocky-xmpp-reader-test.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/wocky-xmpp-reader-test.c b/tests/wocky-xmpp-reader-test.c
index 8d91e32..fd592e4 100644
--- a/tests/wocky-xmpp-reader-test.c
+++ b/tests/wocky-xmpp-reader-test.c
@@ -92,6 +92,16 @@
" <body>" WHITESPACE_ONLY_BODY "</body>" \
" </message>"
+#define NON_CHARACTER_CODEPOINTS_REPLACEMENT "�🙈�"
+
+#define MESSAGE_WITH_NON_CHARACTER_CODEPOINTS \
+" <message to='morse@thamesvalley.police.uk' " \
+" from='lewis@thamesvalley.police.uk'> " \
+" <body>\xef\xb7\xaf🙈\xef\xb7\xaf</body>" \
+" </message>"
+
+
+
static void
test_stream_no_stanzas (void)
{
@@ -340,6 +350,7 @@ test_body (
body = wocky_node_get_child (wocky_stanza_get_top_node (stanza), "body");
g_assert (body != NULL);
+ g_assert (g_utf8_validate (body->content, -1, NULL));
g_assert_cmpstr (body->content, ==, expected_body_text);
g_object_unref (stanza);
@@ -360,6 +371,14 @@ test_whitespace_only (void)
test_body (MESSAGE_WITH_WHITESPACE_ONLY_BODY, WHITESPACE_ONLY_BODY);
}
+/* Test that a message body consisting entirely of whitespace isn't ignored */
+static void
+test_non_character_codepoints (void)
+{
+ test_body (MESSAGE_WITH_NON_CHARACTER_CODEPOINTS,
+ NON_CHARACTER_CODEPOINTS_REPLACEMENT);
+}
+
int
main (int argc,
char **argv)
@@ -379,6 +398,8 @@ main (int argc,
g_test_add_func ("/xmpp-reader/invalid-namespace", test_invalid_namespace);
g_test_add_func ("/xmpp-reader/whitespace-padding", test_whitespace_padding);
g_test_add_func ("/xmpp-reader/whitespace-only", test_whitespace_only);
+ g_test_add_func ("/xmpp-reader/utf-non-character-codepoints",
+ test_non_character_codepoints);
result = g_test_run ();
test_deinit ();