pidgin: 4d3247a3: Ensure UTF-8 strdown is mostly working c...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Wed Jul 15 22:25:45 EDT 2009
-----------------------------------------------------------------
Revision: 4d3247a3525876e8e2a852d7d91a42339ece6b4a
Ancestor: b6af9a8cf6b4f3824e7cc3cb85bc8c1677155304
Author: darkrain42 at pidgin.im
Date: 2009-07-15T22:31:10
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4d3247a3525876e8e2a852d7d91a42339ece6b4a
Modified files:
libpurple/tests/test_jabber_jutil.c
ChangeLog:
Ensure UTF-8 strdown is mostly working correctly.
I'm concerned by this from the g_utf8_strdown manpage:
"Converts all Unicode characters in the string that have a case to lowercase. The exact manner that this is done depends on the current locale, and may result in the number of characters in the string changing."
Further tests that exercise both of those possibilities (ugh, locale-dependence) are extremely welcome.
-------------- next part --------------
============================================================
--- libpurple/tests/test_jabber_jutil.c acdaf7d1a5d5f8b57f5b90fed9555cc607e4a1e3
+++ libpurple/tests/test_jabber_jutil.c a984824a1d7adcd6eaeeaa246b91a5ded5d17d39
@@ -80,6 +80,17 @@ END_TEST
jabber_id_free(jid); \
}
+#define assert_jid_parts(expect_node, expect_domain, str) { \
+ JabberID *jid = jabber_id_new(str); \
+ fail_if(jid == NULL, "JID '%s' is valid but jabber_id_new() rejected it", str); \
+ fail_if(jid->node == NULL, "JID '%s' is valid but jabber_id_new() didn't return a node", str); \
+ fail_if(jid->domain == NULL, "JID '%s' is valid but jabber_id_new() didn't return a domain", str); \
+ fail_if(jid->resource != NULL, "JID '%s' doesn't contain a resource", str); \
+ assert_string_equal(expect_node, jid->node); \
+ assert_string_equal(expect_domain, jid->domain); \
+ jabber_id_free(jid); \
+}
+
START_TEST(test_jabber_id_new)
{
assert_valid_jid("gmail.com");
@@ -117,6 +128,12 @@ START_TEST(test_jabber_id_new)
assert_invalid_jid("mark.doliner at gmail\\stuff.org");
assert_invalid_jid("paul@[::1]124");
assert_invalid_jid("paul at 2[::1]124/as");
+
+ /* Ensure that jabber_id_new is properly lowercasing node and domains */
+ assert_jid_parts("paul", "darkrain42.org", "PaUL at darkrain42.org");
+ assert_jid_parts("paul", "darkrain42.org", "paul at DaRkRaIn42.org");
+ assert_jid_parts("?", "darkrain42.org", "?@darkrain42.org");
+ assert_jid_parts("paul", "?arkrain42.org", "paul@?arkrain42.org");
}
END_TEST
More information about the Commits
mailing list