Thu, 13 Jan 2022 23:47:42 -0600
remove purple_str_to_time and other unused time utility functions
Testing Done:
Compiled, ran tests, and ran the program.
Reviewed at https://reviews.imfreedom.org/r/1226/
|
38057
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
1 | /* |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
2 | * purple |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
3 | * |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
6 | * source distribution. |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
7 | * |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
11 | * (at your option) any later version. |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
12 | * |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
16 | * GNU General Public License for more details. |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
17 | * |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
21 | * |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37601
diff
changeset
|
22 | */ |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
23 | #include <glib.h> |
|
15950
0f01bb61c5d3
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
24 | |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
39987
diff
changeset
|
25 | #include <purple.h> |
| 15104 | 26 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
27 | /****************************************************************************** |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
28 | * filename escape tests |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
29 | *****************************************************************************/ |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
30 | static void |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
31 | test_util_filename_escape(void) { |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
32 | g_assert_cmpstr("foo", ==, purple_escape_filename("foo")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
33 | g_assert_cmpstr("@oo", ==, purple_escape_filename("@oo")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
34 | g_assert_cmpstr("#oo", ==, purple_escape_filename("#oo")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
35 | g_assert_cmpstr("-oo", ==, purple_escape_filename("-oo")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
36 | g_assert_cmpstr("_oo", ==, purple_escape_filename("_oo")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
37 | g_assert_cmpstr(".oo", ==, purple_escape_filename(".oo")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
38 | g_assert_cmpstr("%25oo", ==, purple_escape_filename("%oo")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
39 | g_assert_cmpstr("%21oo", ==, purple_escape_filename("!oo")); |
| 15104 | 40 | } |
| 41 | ||
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
42 | static void |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
43 | test_util_filename_unescape(void) { |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
44 | g_assert_cmpstr("bar", ==, purple_unescape_filename("bar")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
45 | g_assert_cmpstr("@ar", ==, purple_unescape_filename("@ar")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
46 | g_assert_cmpstr("!ar", ==, purple_unescape_filename("!ar")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
47 | g_assert_cmpstr("!ar", ==, purple_unescape_filename("%21ar")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
48 | g_assert_cmpstr("%ar", ==, purple_unescape_filename("%25ar")); |
| 15104 | 49 | } |
| 50 | ||
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
51 | /****************************************************************************** |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
52 | * text_strip tests |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
53 | *****************************************************************************/ |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
54 | static void |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
55 | test_util_text_strip_mnemonic(void) { |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
56 | g_assert_cmpstr("", ==, purple_text_strip_mnemonic("")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
57 | g_assert_cmpstr("foo", ==, purple_text_strip_mnemonic("foo")); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
58 | g_assert_cmpstr("foo", ==, purple_text_strip_mnemonic("_foo")); |
| 15104 | 59 | |
| 60 | } | |
| 61 | ||
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
62 | /****************************************************************************** |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
63 | * email tests |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
64 | *****************************************************************************/ |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
65 | /* |
|
30442
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
66 | * Many of the valid and invalid email addresses lised below are from |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
67 | * http://fightingforalostcause.net/misc/2006/compare-email-regex.php |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
68 | */ |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
69 | const gchar *valid_emails[] = { |
|
30442
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
70 | "purple-devel@lists.sf.net", |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
71 | "l3tt3rsAndNumb3rs@domain.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
72 | "has-dash@domain.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
73 | "hasApostrophe.o'leary@domain.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
74 | "uncommonTLD@domain.museum", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
75 | "uncommonTLD@domain.travel", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
76 | "uncommonTLD@domain.mobi", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
77 | "countryCodeTLD@domain.uk", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
78 | "countryCodeTLD@domain.rw", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
79 | "lettersInDomain@911.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
80 | "underscore_inLocal@domain.net", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
81 | "IPInsteadOfDomain@127.0.0.1", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
82 | /* "IPAndPort@127.0.0.1:25", */ |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
83 | "subdomain@sub.domain.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
84 | "local@dash-inDomain.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
85 | "dot.inLocal@foo.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
86 | "a@singleLetterLocal.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
87 | "singleLetterDomain@x.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
88 | "&*=?^+{}'~@validCharsInLocal.net", |
|
31484
b7cfae50e10c
Add two valid email addresses to this list
Mark Doliner <markdoliner@pidgin.im>
parents:
31232
diff
changeset
|
89 | "foor@bar.newTLD", |
|
b7cfae50e10c
Add two valid email addresses to this list
Mark Doliner <markdoliner@pidgin.im>
parents:
31232
diff
changeset
|
90 | "HenryTheGreatWhiteCricket@live.ca", |
|
b7cfae50e10c
Add two valid email addresses to this list
Mark Doliner <markdoliner@pidgin.im>
parents:
31232
diff
changeset
|
91 | "HenryThe__WhiteCricket@hotmail.com" |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
92 | }; |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
93 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
94 | static void |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
95 | test_util_email_is_valid(void) { |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
96 | size_t i; |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
97 | |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
98 | for (i = 0; i < G_N_ELEMENTS(valid_emails); i++) |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
99 | g_assert_true(purple_email_is_valid(valid_emails[i])); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
100 | } |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
101 | |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
102 | const gchar *invalid_emails[] = { |
|
30442
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
103 | "purple-devel@@lists.sf.net", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
104 | "purple@devel@lists.sf.net", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
105 | "purple-devel@list..sf.net", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
106 | "purple-devel", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
107 | "purple-devel@", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
108 | "@lists.sf.net", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
109 | "totally bogus", |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
110 | "missingDomain@.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
111 | "@missingLocal.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
112 | "missingatSign.net", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
113 | "missingDot@com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
114 | "two@@signs.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
115 | "colonButNoPort@127.0.0.1:", |
|
36049
bffbd724134d
Fix CWE-252 coverity issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35297
diff
changeset
|
116 | "", |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
117 | /* "someone-else@127.0.0.1.26", */ |
|
30444
d871c3fd6637
Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30442
diff
changeset
|
118 | ".localStartsWithDot@domain.com", |
|
d871c3fd6637
Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30442
diff
changeset
|
119 | /* "localEndsWithDot.@domain.com", */ /* I don't think this is invalid -- Stu */ |
|
d871c3fd6637
Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30442
diff
changeset
|
120 | /* "two..consecutiveDots@domain.com", */ /* I don't think this is invalid -- Stu */ |
|
d871c3fd6637
Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30442
diff
changeset
|
121 | "domainStartsWithDash@-domain.com", |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
122 | "domainEndsWithDash@domain-.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
123 | /* "numbersInTLD@domain.c0m", */ |
|
30444
d871c3fd6637
Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30442
diff
changeset
|
124 | /* "missingTLD@domain.", */ /* This certainly isn't invalid -- Stu */ |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
125 | "! \"#$%(),/;<>[]`|@invalidCharsInLocal.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
126 | "invalidCharsInDomain@! \"#$%(),/;<>_[]`|.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
127 | /* "local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org" */ |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
128 | }; |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
129 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
130 | static void |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
131 | test_util_email_is_invalid(void) { |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
132 | size_t i; |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
133 | |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
134 | for (i = 0; i < G_N_ELEMENTS(invalid_emails); i++) |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
135 | g_assert_false(purple_email_is_valid(invalid_emails[i])); |
| 15104 | 136 | } |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
137 | |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
138 | /****************************************************************************** |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
139 | * UTF8 tests |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
140 | *****************************************************************************/ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
141 | typedef struct { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
142 | gchar *input; |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
143 | gchar *output; |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
144 | } UTF8TestData; |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
145 | |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
146 | static void |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
147 | test_util_utf8_strip_unprintables(void) { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
148 | gint i; |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
149 | UTF8TestData data[] = { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
150 | { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
151 | /* \t, \n, \r, space */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
152 | "ab \tcd\nef\r ", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
153 | "ab \tcd\nef\r ", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
154 | }, { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
155 | /* ASCII control characters (stripped) */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
156 | "\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10 aaaa " |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
157 | "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
158 | " aaaa ", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
159 | }, { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
160 | /* Basic ASCII */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
161 | "Foobar", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
162 | "Foobar", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
163 | }, { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
164 | /* 0xE000 - 0xFFFD (UTF-8 encoded) */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
165 | /* U+F1F7 */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
166 | "aaaa\xef\x87\xb7", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
167 | "aaaa\xef\x87\xb7", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
168 | }, { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
169 | /* U+FEFF (should not be stripped) */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
170 | "aaaa\xef\xbb\xbf", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
171 | "aaaa\xef\xbb\xbf", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
172 | }, { |
|
38813
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
173 | /* U+FFFE (should be stripped) */ |
|
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
174 | "aaaa\xef\xbf\xbe", |
|
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
175 | "aaaa", |
|
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
176 | }, { |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
177 | NULL, |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
178 | NULL, |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
179 | } |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
180 | }; |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
181 | |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
182 | for(i = 0; ; i++) { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
183 | gchar *result = purple_utf8_strip_unprintables(data[i].input); |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
184 | |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
185 | g_assert_cmpstr(data[i].output, ==, result); |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
186 | |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
187 | g_free(result); |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
188 | |
|
38813
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
189 | /* NULL as input is a valid test, but it's the last test, so we break |
|
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
190 | * after it. |
|
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
191 | */ |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
192 | if(data[i].input == NULL) |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
193 | break; |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
194 | } |
|
30143
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
195 | } |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
196 | |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
197 | /****************************************************************************** |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
198 | * strdup_withhtml tests |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
199 | *****************************************************************************/ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
200 | static void |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
201 | test_util_strdup_withhtml(void) { |
|
32014
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
202 | gchar *result = purple_strdup_withhtml("hi\r\nthere\n"); |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
203 | |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
204 | g_assert_cmpstr("hi<BR>there<BR>", ==, result); |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
205 | |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
206 | g_free(result); |
|
32014
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
207 | } |
|
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
208 | |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
209 | /****************************************************************************** |
| 38748 | 210 | * URI Escaping |
| 211 | *****************************************************************************/ | |
| 212 | static void | |
| 213 | test_uri_escape_for_open(void) { | |
|
38737
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
214 | /* make sure shell stuff is escaped... */ |
|
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
215 | gchar *result = purple_uri_escape_for_open("https://$(xterm)"); |
| 38748 | 216 | g_assert_cmpstr("https://%24%28xterm%29", ==, result); |
| 217 | g_free(result); | |
|
38737
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
218 | |
|
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
219 | result = purple_uri_escape_for_open("https://`xterm`"); |
| 38748 | 220 | g_assert_cmpstr("https://%60xterm%60", ==, result); |
| 221 | g_free(result); | |
|
38737
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
222 | |
|
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
223 | result = purple_uri_escape_for_open("https://$((25 + 13))"); |
| 38748 | 224 | g_assert_cmpstr("https://%24%28%2825%20+%2013%29%29", ==, result); |
| 225 | g_free(result); | |
|
38737
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
226 | |
|
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
227 | /* ...but keep brackets so that ipv6 links can be opened. */ |
|
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
228 | result = purple_uri_escape_for_open("https://[123:4567:89a::::]"); |
| 38748 | 229 | g_assert_cmpstr("https://[123:4567:89a::::]", ==, result); |
| 230 | g_free(result); | |
|
38737
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
231 | } |
|
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
232 | |
| 38748 | 233 | /****************************************************************************** |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
234 | * MANE |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
235 | *****************************************************************************/ |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
236 | gint |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
237 | main(gint argc, gchar **argv) { |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
238 | g_test_init(&argc, &argv, NULL); |
| 15104 | 239 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
240 | g_test_add_func("/util/filename/escape", |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
241 | test_util_filename_escape); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
242 | g_test_add_func("/util/filename/unescape", |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
243 | test_util_filename_unescape); |
| 15104 | 244 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
245 | g_test_add_func("/util/mnemonic/strip", |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
246 | test_util_text_strip_mnemonic); |
| 15104 | 247 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
248 | g_test_add_func("/util/email/is valid", |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
249 | test_util_email_is_valid); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
250 | g_test_add_func("/util/email/is invalid", |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
251 | test_util_email_is_invalid); |
| 15104 | 252 | |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
253 | g_test_add_func("/util/utf8/strip unprintables", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
254 | test_util_utf8_strip_unprintables); |
|
30143
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
255 | |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
256 | g_test_add_func("/util/test_strdup_withhtml", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
257 | test_util_strdup_withhtml); |
|
32014
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
258 | |
| 38748 | 259 | g_test_add_func("/util/test_uri_escape_for_open", |
| 260 | test_uri_escape_for_open); | |
|
38737
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
261 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
262 | return g_test_run(); |
| 15104 | 263 | } |