From 9c8dbc75d416c8867be20ccf3732303163e620ce Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 23 Nov 2015 14:49:09 -0300 Subject: hipchat: 'chat add hipchat "channel name"' now tries to guess the JID It's basically prepending the organization id, appending the default MUC host from the success packet, and generating a slug based on the name for the middle part, which is replacing a few characters with underscores and doing a unicode aware lowercasing. Includes tests, which are useless other than validating the initial implementation with the test vectors that i already tested manually. Guaranteed to detect zero breakages in the future. Good test code. --- tests/check_jabber_util.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/check_jabber_util.c b/tests/check_jabber_util.c index 1a574ec2..1ffea011 100644 --- a/tests/check_jabber_util.c +++ b/tests/check_jabber_util.c @@ -104,6 +104,25 @@ static void check_compareJID(int l) fail_if(jabber_compare_jid("", "bugtest@google.com/A")); } +static void check_hipchat_slug(int l) +{ + int i; + + const char *tests[] = { + "test !\"#$%&\'()*+,-./0123456789:;<=>?@ABC", "test_!#$%\()*+,-.0123456789;=?abc", + "test XYZ[\\]^_`abc", "test_xyz[\\]^_`abc", + "test {|}~¡¢£¤¥¦§¨©ª«¬\xad®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ", "test_{|}~¡¢£¤¥¦§¨©ª«¬\xad®¯°±²³´µ¶·¸¹º»¼½¾¿àáâãäåæ", + "test IJ ij I ı I ı", "test_ij_ij_i_ı_i_ı", + NULL, + }; + + for (i = 0; tests[i]; i += 2) { + char *new = hipchat_make_channel_slug(tests[i]); + fail_unless(!strcmp(tests[i + 1], new)); + g_free(new); + } +} + Suite *jabber_util_suite(void) { Suite *s = suite_create("jabber/util"); @@ -120,5 +139,6 @@ Suite *jabber_util_suite(void) suite_add_tcase(s, tc_core); tcase_add_test(tc_core, check_buddy_add); tcase_add_test(tc_core, check_compareJID); + tcase_add_test(tc_core, check_hipchat_slug); return s; } -- cgit v1.2.3