Fri, 16 Oct 2020 02:27:21 -0500
Pull the purple_markup_* api out of util.[ch] to purplemarkup.[ch]. No code was changed just moved it from one file to the other.
Testing Done:
Compile and unit tests.
Reviewed at https://reviews.imfreedom.org/r/171/
|
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 | /****************************************************************************** |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
139 | * str_to_time tests |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
140 | *****************************************************************************/ |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
141 | static void |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
142 | test_util_str_to_time(void) { |
|
35181
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
143 | struct tm tm; |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
144 | glong tz_off; |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
145 | const gchar *rest; |
|
35181
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
146 | time_t timestamp; |
|
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
147 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
148 | g_assert_cmpint(377182200, ==, purple_str_to_time("19811214T12:50:00", TRUE, NULL, NULL, NULL)); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
149 | g_assert_cmpint(1175919261, ==, purple_str_to_time("20070407T04:14:21", TRUE, NULL, NULL, NULL)); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
150 | g_assert_cmpint(1282941722, ==, purple_str_to_time("2010-08-27.204202", TRUE, NULL, NULL, NULL)); |
|
35181
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
151 | |
|
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
152 | timestamp = purple_str_to_time("2010-08-27.134202-0700PDT", FALSE, &tm, &tz_off, &rest); |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
153 | g_assert_cmpint(1282941722, ==, timestamp); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
154 | g_assert_cmpint((-7 * 60 * 60), ==, tz_off); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
155 | g_assert_cmpstr("PDT", ==, rest); |
|
16065
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
156 | } |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
157 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
158 | /****************************************************************************** |
|
38619
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
159 | * str_to_date_time tests |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
160 | *****************************************************************************/ |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
161 | static void |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
162 | test_util_str_to_date_time(void) |
|
20293
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
163 | { |
|
38619
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
164 | GDateTime *dt; |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
165 | |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
166 | dt = purple_str_to_date_time("19811214T12:50:00", TRUE); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
167 | g_assert_cmpint(377182200, ==, g_date_time_to_unix(dt)); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
168 | g_assert_cmpint(0, ==, g_date_time_get_utc_offset(dt)); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
169 | g_date_time_unref(dt); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
170 | |
|
38624
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
171 | dt = purple_str_to_date_time("20070407T04:14:21.1234", TRUE); |
|
38619
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
172 | g_assert_cmpint(1175919261, ==, g_date_time_to_unix(dt)); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
173 | g_assert_cmpint(0, ==, g_date_time_get_utc_offset(dt)); |
|
38624
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
174 | g_assert_cmpint(123400, ==, g_date_time_get_microsecond(dt)); |
|
38619
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
175 | g_date_time_unref(dt); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
176 | |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
177 | dt = purple_str_to_date_time("2010-08-27.204202", TRUE); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
178 | g_assert_cmpint(1282941722, ==, g_date_time_to_unix(dt)); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
179 | g_assert_cmpint(0, ==, g_date_time_get_utc_offset(dt)); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
180 | g_date_time_unref(dt); |
|
29227
3e9734bf4422
Fix a corner case where purple_markup_html_to_xhtml generated malformed XHTML.
Paul Aurich <darkrain42@pidgin.im>
parents:
27727
diff
changeset
|
181 | |
|
38624
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
182 | dt = purple_str_to_date_time("2010-08-27.204202.123456", TRUE); |
|
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
183 | g_assert_cmpint(1282941722, ==, g_date_time_to_unix(dt)); |
|
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
184 | g_assert_cmpint(0, ==, g_date_time_get_utc_offset(dt)); |
|
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
185 | g_assert_cmpint(123456, ==, g_date_time_get_microsecond(dt)); |
|
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
186 | g_date_time_unref(dt); |
|
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
187 | |
|
38619
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
188 | dt = purple_str_to_date_time("2010-08-27.134202-0700PDT", FALSE); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
189 | g_assert_cmpint(1282941722, ==, g_date_time_to_unix(dt)); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
190 | g_assert_cmpint((-7LL * 60 * 60 * G_USEC_PER_SEC), ==, g_date_time_get_utc_offset(dt)); |
|
38624
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
191 | |
|
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
192 | dt = purple_str_to_date_time("2010-08-27.134202.1234-0700PDT", FALSE); |
|
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
193 | g_assert_cmpint(1282941722, ==, g_date_time_to_unix(dt)); |
|
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
194 | g_assert_cmpint(123400, ==, g_date_time_get_microsecond(dt)); |
|
dcd42461c1a8
Fix parsing of date time microseconds.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38619
diff
changeset
|
195 | g_assert_cmpint((-7LL * 60 * 60 * G_USEC_PER_SEC), ==, g_date_time_get_utc_offset(dt)); |
|
38619
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
196 | } |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
197 | |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
198 | /****************************************************************************** |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
199 | * UTF8 tests |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
200 | *****************************************************************************/ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
201 | typedef struct { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
202 | gchar *input; |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
203 | gchar *output; |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
204 | } UTF8TestData; |
|
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 | static void |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
207 | test_util_utf8_strip_unprintables(void) { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
208 | gint i; |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
209 | UTF8TestData data[] = { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
210 | { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
211 | /* \t, \n, \r, space */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
212 | "ab \tcd\nef\r ", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
213 | "ab \tcd\nef\r ", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
214 | }, { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
215 | /* ASCII control characters (stripped) */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
216 | "\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
|
217 | "\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
|
218 | " aaaa ", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
219 | }, { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
220 | /* Basic ASCII */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
221 | "Foobar", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
222 | "Foobar", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
223 | }, { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
224 | /* 0xE000 - 0xFFFD (UTF-8 encoded) */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
225 | /* U+F1F7 */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
226 | "aaaa\xef\x87\xb7", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
227 | "aaaa\xef\x87\xb7", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
228 | }, { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
229 | /* U+FEFF (should not be stripped) */ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
230 | "aaaa\xef\xbb\xbf", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
231 | "aaaa\xef\xbb\xbf", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
232 | }, { |
|
38813
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
233 | /* U+FFFE (should be stripped) */ |
|
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
234 | "aaaa\xef\xbf\xbe", |
|
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
235 | "aaaa", |
|
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
236 | }, { |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
237 | NULL, |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
238 | NULL, |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
239 | } |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
240 | }; |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
241 | |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
242 | for(i = 0; ; i++) { |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
243 | 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
|
244 | |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
245 | g_assert_cmpstr(data[i].output, ==, result); |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
246 | |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
247 | g_free(result); |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
248 | |
|
38813
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
249 | /* 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
|
250 | * after it. |
|
9506fb3fe6a2
Remove #if 0's from libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
38748
diff
changeset
|
251 | */ |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
252 | if(data[i].input == NULL) |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
253 | break; |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
254 | } |
|
30143
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
255 | } |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
256 | |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
257 | /****************************************************************************** |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
258 | * strdup_withhtml tests |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
259 | *****************************************************************************/ |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
260 | static void |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
261 | test_util_strdup_withhtml(void) { |
|
32014
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
262 | 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
|
263 | |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
264 | g_assert_cmpstr("hi<BR>there<BR>", ==, result); |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
265 | |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
266 | g_free(result); |
|
32014
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
267 | } |
|
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
268 | |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
269 | /****************************************************************************** |
| 38748 | 270 | * URI Escaping |
| 271 | *****************************************************************************/ | |
| 272 | static void | |
| 273 | 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
|
274 | /* 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
|
275 | gchar *result = purple_uri_escape_for_open("https://$(xterm)"); |
| 38748 | 276 | g_assert_cmpstr("https://%24%28xterm%29", ==, result); |
| 277 | g_free(result); | |
|
38737
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
278 | |
|
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
279 | result = purple_uri_escape_for_open("https://`xterm`"); |
| 38748 | 280 | g_assert_cmpstr("https://%60xterm%60", ==, result); |
| 281 | g_free(result); | |
|
38737
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
282 | |
|
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
283 | result = purple_uri_escape_for_open("https://$((25 + 13))"); |
| 38748 | 284 | g_assert_cmpstr("https://%24%28%2825%20+%2013%29%29", ==, result); |
| 285 | g_free(result); | |
|
38737
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
286 | |
|
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
287 | /* ...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
|
288 | result = purple_uri_escape_for_open("https://[123:4567:89a::::]"); |
| 38748 | 289 | g_assert_cmpstr("https://[123:4567:89a::::]", ==, result); |
| 290 | g_free(result); | |
|
38737
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
291 | } |
|
d85c241e3183
Add unit tests for xdg-open URI escaping
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
35181
diff
changeset
|
292 | |
| 38748 | 293 | /****************************************************************************** |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
294 | * MANE |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
295 | *****************************************************************************/ |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
296 | gint |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
297 | main(gint argc, gchar **argv) { |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
298 | g_test_init(&argc, &argv, NULL); |
| 15104 | 299 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
300 | g_test_add_func("/util/filename/escape", |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
301 | test_util_filename_escape); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
302 | g_test_add_func("/util/filename/unescape", |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
303 | test_util_filename_unescape); |
| 15104 | 304 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
305 | g_test_add_func("/util/mnemonic/strip", |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
306 | test_util_text_strip_mnemonic); |
| 15104 | 307 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
308 | g_test_add_func("/util/email/is valid", |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
309 | test_util_email_is_valid); |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
310 | g_test_add_func("/util/email/is invalid", |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
311 | test_util_email_is_invalid); |
| 15104 | 312 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
313 | g_test_add_func("/util/str to time", |
|
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
314 | test_util_str_to_time); |
|
16065
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
315 | |
|
38619
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
316 | g_test_add_func("/util/str to date time", |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
317 | test_util_str_to_date_time); |
|
2121337626ee
Add purple_str_to_date_time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38341
diff
changeset
|
318 | |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
319 | g_test_add_func("/util/utf8/strip unprintables", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
320 | 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
|
321 | |
|
37601
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
322 | g_test_add_func("/util/test_strdup_withhtml", |
|
bf18c71d8508
Finish up the util unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
37600
diff
changeset
|
323 | test_util_strdup_withhtml); |
|
32014
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
324 | |
| 38748 | 325 | g_test_add_func("/util/test_uri_escape_for_open", |
| 326 | 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
|
327 | |
|
37600
fce4d896285e
Add a bunch of util tests
Gary Kramlich <grim@reaperworld.com>
parents:
36049
diff
changeset
|
328 | return g_test_run(); |
| 15104 | 329 | } |