Mercurial > pidgin.yaz
changeset 27636:090dc513552f
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.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 15 Jul 2009 22:31:10 +0000 |
parents | 97eb110550ad |
children | aac25c66a843 |
files | libpurple/tests/test_jabber_jutil.c |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/tests/test_jabber_jutil.c Wed Jul 15 18:27:37 2009 +0000 +++ b/libpurple/tests/test_jabber_jutil.c Wed Jul 15 22:31:10 2009 +0000 @@ -80,6 +80,17 @@ 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 @@ assert_invalid_jid("mark.doliner@gmail\\stuff.org"); assert_invalid_jid("paul@[::1]124"); assert_invalid_jid("paul@2[::1]124/as"); + + /* Ensure that jabber_id_new is properly lowercasing node and domains */ + assert_jid_parts("paul", "darkrain42.org", "PaUL@darkrain42.org"); + assert_jid_parts("paul", "darkrain42.org", "paul@DaRkRaIn42.org"); + assert_jid_parts("ꙥ", "darkrain42.org", "Ꙥ@darkrain42.org"); + assert_jid_parts("paul", "өarkrain42.org", "paul@Өarkrain42.org"); } END_TEST