summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ();