Wed, 13 May 2009 20:29:03 +0000
Support custom smileys in MUCs (when all participants support BoB and a maximum
of 10 participants are in the chat).
Always announce support for BoB, since disable custom smileys will still turn
off fetching them, and BoB can be used for other purposes further on.
|
15950
0f01bb61c5d3
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15435
diff
changeset
|
1 | #include <string.h> |
|
0f01bb61c5d3
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15435
diff
changeset
|
2 | |
| 15155 | 3 | #include "tests.h" |
|
15953
dfb69139ddf9
Update #includes to match changes in jabber
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15950
diff
changeset
|
4 | #include "../account.h" |
|
dfb69139ddf9
Update #includes to match changes in jabber
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15950
diff
changeset
|
5 | #include "../conversation.h" |
|
dfb69139ddf9
Update #includes to match changes in jabber
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15950
diff
changeset
|
6 | #include "../xmlnode.h" |
| 15155 | 7 | #include "../protocols/jabber/jutil.h" |
| 8 | ||
| 9 | START_TEST(test_get_resource) | |
| 10 | { | |
| 11 | assert_string_equal_free("baz", jabber_get_resource("foo@bar/baz")); | |
| 12 | assert_string_equal_free("baz", jabber_get_resource("bar/baz")); | |
| 13 | assert_string_equal_free("baz/bat", jabber_get_resource("foo@bar/baz/bat")); | |
| 14 | assert_string_equal_free("baz/bat", jabber_get_resource("bar/baz/bat")); | |
| 15 | } | |
| 16 | END_TEST | |
| 17 | ||
| 18 | START_TEST(test_get_resource_no_resource) | |
| 19 | { | |
| 20 | ||
| 21 | fail_unless(NULL == jabber_get_resource("foo@bar")); | |
| 22 | fail_unless(NULL == jabber_get_resource("bar")); | |
| 23 | } | |
| 24 | END_TEST | |
| 25 | ||
| 26 | START_TEST(test_get_bare_jid) | |
| 27 | { | |
| 28 | assert_string_equal_free("foo@bar", jabber_get_bare_jid("foo@bar")); | |
| 29 | assert_string_equal_free("foo@bar", jabber_get_bare_jid("foo@bar/baz")); | |
| 30 | assert_string_equal_free("bar", jabber_get_bare_jid("bar")); | |
| 31 | assert_string_equal_free("bar", jabber_get_bare_jid("bar/baz")); | |
| 32 | } | |
| 33 | END_TEST | |
| 34 | ||
| 35 | START_TEST(test_nodeprep_validate) | |
| 36 | { | |
|
15950
0f01bb61c5d3
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15435
diff
changeset
|
37 | char *longnode; |
|
0f01bb61c5d3
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15435
diff
changeset
|
38 | |
| 15155 | 39 | fail_unless(jabber_nodeprep_validate(NULL)); |
| 40 | fail_unless(jabber_nodeprep_validate("foo")); | |
| 41 | fail_unless(jabber_nodeprep_validate("%d")); | |
| 42 | fail_unless(jabber_nodeprep_validate("y\\z")); | |
| 43 | ||
|
15950
0f01bb61c5d3
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15435
diff
changeset
|
44 | longnode = g_strnfill(1023, 'a'); |
| 15155 | 45 | fail_unless(jabber_nodeprep_validate(longnode)); |
| 46 | g_free(longnode); | |
| 47 | } | |
| 48 | END_TEST | |
| 49 | ||
| 50 | START_TEST(test_nodeprep_validate_illegal_chars) | |
| 51 | { | |
| 52 | fail_if(jabber_nodeprep_validate("don't")); | |
| 53 | fail_if(jabber_nodeprep_validate("m@ke")); | |
| 54 | fail_if(jabber_nodeprep_validate("\"me\"")); | |
| 55 | fail_if(jabber_nodeprep_validate("&ngry")); | |
| 56 | fail_if(jabber_nodeprep_validate("c:")); | |
| 57 | fail_if(jabber_nodeprep_validate("a/b")); | |
| 58 | fail_if(jabber_nodeprep_validate("4>2")); | |
| 59 | fail_if(jabber_nodeprep_validate("4<7")); | |
| 60 | } | |
| 61 | END_TEST | |
| 62 | ||
| 63 | START_TEST(test_nodeprep_validate_too_long) | |
| 64 | { | |
| 65 | char *longnode = g_strnfill(1024, 'a'); | |
| 66 | fail_if(jabber_nodeprep_validate(longnode)); | |
| 67 | g_free(longnode); | |
| 68 | } | |
| 69 | END_TEST | |
| 70 | ||
| 71 | Suite * | |
| 72 | jabber_jutil_suite(void) | |
| 73 | { | |
| 74 | Suite *s = suite_create("Jabber Utility Functions"); | |
| 75 | ||
| 76 | TCase *tc = tcase_create("Get Resource"); | |
| 77 | tcase_add_test(tc, test_get_resource); | |
| 78 | tcase_add_test(tc, test_get_resource_no_resource); | |
| 79 | suite_add_tcase(s, tc); | |
| 80 | ||
| 81 | tc = tcase_create("Get Bare JID"); | |
| 82 | tcase_add_test(tc, test_get_bare_jid); | |
| 83 | suite_add_tcase(s, tc); | |
| 84 | ||
| 85 | tc = tcase_create("Nodeprep validate"); | |
| 86 | tcase_add_test(tc, test_nodeprep_validate); | |
| 87 | tcase_add_test(tc, test_nodeprep_validate_illegal_chars); | |
| 88 | tcase_add_test(tc, test_nodeprep_validate_too_long); | |
| 89 | suite_add_tcase(s, tc); | |
| 90 | ||
| 91 | return s; | |
| 92 | } |