Mercurial > pidgin
comparison libpurple/tests/test_util.c @ 30578:0accc8adb18a
merge of '2f6318bd834113559a405ec68cdb178f2180b680'
and '64e02b98551e11e093e4649f1516f3aceaa321e2'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 26 Sep 2010 20:16:15 +0000 |
parents | b8782b02330d |
children | e5101d9cbaaa |
comparison
equal
deleted
inserted
replaced
30577:7b761c8601f7 | 30578:0accc8adb18a |
---|---|
64 assert_string_equal_free("foo", purple_text_strip_mnemonic("_foo")); | 64 assert_string_equal_free("foo", purple_text_strip_mnemonic("_foo")); |
65 | 65 |
66 } | 66 } |
67 END_TEST | 67 END_TEST |
68 | 68 |
69 /* | |
70 * Many of the valid and invalid email addresses lised below are from | |
71 * http://fightingforalostcause.net/misc/2006/compare-email-regex.php | |
72 */ | |
73 const char *valid_emails[] = { | |
74 "purple-devel@lists.sf.net", | |
75 "l3tt3rsAndNumb3rs@domain.com", | |
76 "has-dash@domain.com", | |
77 "hasApostrophe.o'leary@domain.org", | |
78 "uncommonTLD@domain.museum", | |
79 "uncommonTLD@domain.travel", | |
80 "uncommonTLD@domain.mobi", | |
81 "countryCodeTLD@domain.uk", | |
82 "countryCodeTLD@domain.rw", | |
83 "lettersInDomain@911.com", | |
84 "underscore_inLocal@domain.net", | |
85 "IPInsteadOfDomain@127.0.0.1", | |
86 /* "IPAndPort@127.0.0.1:25", */ | |
87 "subdomain@sub.domain.com", | |
88 "local@dash-inDomain.com", | |
89 "dot.inLocal@foo.com", | |
90 "a@singleLetterLocal.org", | |
91 "singleLetterDomain@x.org", | |
92 "&*=?^+{}'~@validCharsInLocal.net", | |
93 "foor@bar.newTLD" | |
94 }; | |
95 | |
96 const char *invalid_emails[] = { | |
97 "purple-devel@@lists.sf.net", | |
98 "purple@devel@lists.sf.net", | |
99 "purple-devel@list..sf.net", | |
100 "purple-devel", | |
101 "purple-devel@", | |
102 "@lists.sf.net", | |
103 "totally bogus", | |
104 "missingDomain@.com", | |
105 "@missingLocal.org", | |
106 "missingatSign.net", | |
107 "missingDot@com", | |
108 "two@@signs.com", | |
109 "colonButNoPort@127.0.0.1:", | |
110 "" | |
111 /* "someone-else@127.0.0.1.26", */ | |
112 ".localStartsWithDot@domain.com", | |
113 /* "localEndsWithDot.@domain.com", */ /* I don't think this is invalid -- Stu */ | |
114 /* "two..consecutiveDots@domain.com", */ /* I don't think this is invalid -- Stu */ | |
115 "domainStartsWithDash@-domain.com", | |
116 "domainEndsWithDash@domain-.com", | |
117 /* "numbersInTLD@domain.c0m", */ | |
118 /* "missingTLD@domain.", */ /* This certainly isn't invalid -- Stu */ | |
119 "! \"#$%(),/;<>[]`|@invalidCharsInLocal.org", | |
120 "invalidCharsInDomain@! \"#$%(),/;<>_[]`|.org", | |
121 /* "local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org" */ | |
122 }; | |
123 | |
69 START_TEST(test_util_email_is_valid) | 124 START_TEST(test_util_email_is_valid) |
70 { | 125 { |
71 fail_unless(purple_email_is_valid("purple-devel@lists.sf.net")); | 126 size_t i; |
72 fail_if(purple_email_is_valid("purple-devel@@lists.sf.net")); | 127 |
73 fail_if(purple_email_is_valid("purple@devel@lists.sf.net")); | 128 for (i = 0; i < G_N_ELEMENTS(valid_emails); i++) |
74 fail_if(purple_email_is_valid("purple-devel@list..sf.net")); | 129 fail_unless(purple_email_is_valid(valid_emails[i]), "Email address was: %s", valid_emails[i]); |
75 fail_if(purple_email_is_valid("purple-devel")); | 130 |
76 fail_if(purple_email_is_valid("purple-devel@")); | 131 for (i = 0; i < G_N_ELEMENTS(invalid_emails); i++) |
77 fail_if(purple_email_is_valid("@lists.sf.net")); | 132 fail_if(purple_email_is_valid(invalid_emails[i]), "Email address was: %s", invalid_emails[i]); |
78 fail_if(purple_email_is_valid("")); | |
79 fail_if(purple_email_is_valid("totally bogus")); | |
80 } | 133 } |
81 END_TEST | 134 END_TEST |
82 | 135 |
83 START_TEST(test_util_ipv6_is_valid) | 136 START_TEST(test_util_ipv6_is_valid) |
84 { | 137 { |