pidgin: d085ca75: Add tests for jabber_id_new(). Please a...
markdoliner at pidgin.im
markdoliner at pidgin.im
Fri Jul 10 01:30:22 EDT 2009
-----------------------------------------------------------------
Revision: d085ca752d14732bff39952bc3ba8a415a76d274
Ancestor: 87ba031ce46c56c3373f9607f3e3e6aa07eb9857
Author: markdoliner at pidgin.im
Date: 2009-07-10T05:26:41
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d085ca752d14732bff39952bc3ba8a415a76d274
Modified files:
libpurple/tests/test_jabber_jutil.c
ChangeLog:
Add tests for jabber_id_new(). Please add to this! JIDs with accented
characters and stuff would be great.
-------------- next part --------------
============================================================
--- libpurple/tests/test_jabber_jutil.c 358a91160795b2df7719b7202fd837c5d0b28d61
+++ libpurple/tests/test_jabber_jutil.c 4a8b89fd59446bfb1b16c1660121034c5abf6c7c
@@ -68,6 +68,38 @@ END_TEST
}
END_TEST
+#define assert_valid_jid(str) { \
+ JabberID *jid = jabber_id_new(str); \
+ fail_if(jid == NULL, "JID '%s' is valid but jabber_id_new() rejected it", str); \
+ jabber_id_free(jid); \
+}
+
+#define assert_invalid_jid(str) { \
+ JabberID *jid = jabber_id_new(str); \
+ fail_if(jid != NULL, "JID '%s' is invalid but jabber_id_new() allowed it", str); \
+ jabber_id_free(jid); \
+}
+
+START_TEST(test_jabber_id_new)
+{
+ assert_valid_jid("gmail.com");
+ assert_valid_jid("gmail.com/Test");
+ assert_valid_jid("gmail.com/Test@");
+ assert_valid_jid("gmail.com/Test at alkjaweflkj");
+ assert_valid_jid("mark.doliner at gmail.com");
+ assert_valid_jid("mark.doliner at gmail.com/Test12345");
+ assert_valid_jid("mark.doliner at gmail.com/Test at 12345");
+ assert_valid_jid("mark.doliner at gmail.com/Te/st at 12@//345");
+
+ assert_invalid_jid("@@gmail.com");
+ assert_invalid_jid("mark.doliner@@gmail.com/Test12345");
+ assert_invalid_jid("mark at doliner@gmail.com/Test12345");
+ assert_invalid_jid("@gmail.com/Test at 12345");
+ assert_invalid_jid("/Test at 12345");
+ assert_invalid_jid("mark.doliner@");
+}
+END_TEST
+
Suite *
jabber_jutil_suite(void)
{
@@ -82,10 +114,11 @@ jabber_jutil_suite(void)
tcase_add_test(tc, test_get_bare_jid);
suite_add_tcase(s, tc);
- tc = tcase_create("Nodeprep validate");
+ tc = tcase_create("JID validate");
tcase_add_test(tc, test_nodeprep_validate);
tcase_add_test(tc, test_nodeprep_validate_illegal_chars);
tcase_add_test(tc, test_nodeprep_validate_too_long);
+ tcase_add_test(tc, test_jabber_id_new);
suite_add_tcase(s, tc);
return s;
More information about the Commits
mailing list