Changeset 9c8dbc7 for tests


Ignore:
Timestamp:
2015-11-23T17:49:09Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
ad9ac5d
Parents:
c34247d
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/check_jabber_util.c

    rc34247d r9c8dbc7  
    105105}
    106106
     107static void check_hipchat_slug(int l)
     108{
     109        int i;
     110
     111        const char *tests[] = {
     112                "test !\"#$%&\'()*+,-./0123456789:;<=>?@ABC", "test_!#$%\()*+,-.0123456789;=?abc",
     113                "test XYZ[\\]^_`abc", "test_xyz[\\]^_`abc",
     114                "test {|}~¡¢£¤¥¦§¨©ª«¬\xad®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ", "test_{|}~¡¢£¤¥¦§¨©ª«¬\xad®¯°±²³´µ¶·¸¹º»¼½¾¿àáâãäåæ",
     115                "test IJ ij I ı I ı", "test_ij_ij_i_ı_i_ı",
     116                NULL,
     117        };
     118
     119        for (i = 0; tests[i]; i += 2) {
     120                char *new = hipchat_make_channel_slug(tests[i]);
     121                fail_unless(!strcmp(tests[i + 1], new));
     122                g_free(new);
     123        }
     124}
     125
    107126Suite *jabber_util_suite(void)
    108127{
     
    121140        tcase_add_test(tc_core, check_buddy_add);
    122141        tcase_add_test(tc_core, check_compareJID);
     142        tcase_add_test(tc_core, check_hipchat_slug);
    123143        return s;
    124144}
Note: See TracChangeset for help on using the changeset viewer.