diff options
author | dequis <dx@dxzone.com.ar> | 2015-11-23 14:49:09 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-11-23 14:49:09 -0300 |
commit | 9c8dbc75d416c8867be20ccf3732303163e620ce (patch) | |
tree | a714f5af6ca4a17db97981036c0f79ae5ffda7fd /tests | |
parent | c34247d0b3111f16dae1a52d831df0d61c03ee35 (diff) |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check_jabber_util.c | 20 |
1 files changed, 20 insertions, 0 deletions
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; } |