protocols/ircv3/tests/test_ircv3_formatting.c

Thu, 11 Apr 2024 21:39:52 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 11 Apr 2024 21:39:52 -0500
changeset 42694
c5d992e0ee08
parent 42652
225762d4e206
permissions
-rw-r--r--

Remove the remaining event loop API as it is no longer used

Testing Done:
Called in the world's most fearsome fighting team.

Reviewed at https://reviews.imfreedom.org/r/3092/

42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include <glib.h>
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 #include <purple.h>
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "../purpleircv3formatting.h"
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 /******************************************************************************
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 * Strip Tests
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 *****************************************************************************/
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 test_ircv3_formatting_strip(const char *input, const char *expected) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 char *actual = NULL;
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 actual = purple_ircv3_formatting_strip(input);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 g_assert_cmpstr(actual, ==, expected);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 g_clear_pointer(&actual, g_free);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 test_ircv3_formatting_strip_null(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 test_ircv3_formatting_strip(NULL, NULL);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 test_ircv3_formatting_strip_empty(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 test_ircv3_formatting_strip("", "");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 test_ircv3_formatting_strip_color_comma(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 test_ircv3_formatting_strip("\003,", ",");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 test_ircv3_formatting_strip_color_foreground_comma(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 test_ircv3_formatting_strip("\0033,", ",");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 test_ircv3_formatting_strip_color_full(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 test_ircv3_formatting_strip("\0033,9wee", "wee");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 test_ircv3_formatting_strip_color_foreground_3_digit(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 test_ircv3_formatting_strip("\003314", "4");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 test_ircv3_formatting_strip_color_background_3_digit(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 test_ircv3_formatting_strip("\0031,234", "4");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 test_ircv3_formatting_strip_hex_color(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 test_ircv3_formatting_strip("\004FF00FFwoo!", "woo!");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 test_ircv3_formatting_strip_hex_color_full(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 test_ircv3_formatting_strip("\004FF00FF,00FF00woo!", "woo!");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 test_ircv3_formatting_strip_hex_color_comma(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 test_ircv3_formatting_strip("\004,", ",");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 test_ircv3_formatting_strip_hex_color_foreground_comma(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 test_ircv3_formatting_strip("\004FEFEFE,", ",");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 test_ircv3_formatting_strip_hex_color_foreground_7_characters(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 test_ircv3_formatting_strip("\004FEFEFEF", "F");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 test_ircv3_formatting_strip_hex_color_background_7_characters(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 test_ircv3_formatting_strip("\004FEFEFE,2222223", "3");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 test_ircv3_formatting_strip_bold(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 test_ircv3_formatting_strip("this is \002bold\002!", "this is bold!");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 test_ircv3_formatting_strip_italic(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 test_ircv3_formatting_strip("what do you \035mean\035?!",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 "what do you mean?!");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 test_ircv3_formatting_strip_monospace(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 test_ircv3_formatting_strip("\021i++;\021", "i++;");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 test_ircv3_formatting_strip_reset(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 test_ircv3_formatting_strip("end of formatting\017", "end of formatting");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 test_ircv3_formatting_strip_reverse(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 test_ircv3_formatting_strip("re\026ver\026se", "reverse");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 test_ircv3_formatting_strip_strikethrough(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 test_ircv3_formatting_strip("\036I could be wrong\036",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 "I could be wrong");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 test_ircv3_formatting_strip_underline(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 test_ircv3_formatting_strip("You can't handle the \037truth\037!",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 "You can't handle the truth!");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 test_ircv3_formatting_strip_spec_example1(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 test_ircv3_formatting_strip(
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 "I love \0033IRC! \003It is the \0037best protocol ever!",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 "I love IRC! It is the best protocol ever!");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 test_ircv3_formatting_strip_spec_example2(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 test_ircv3_formatting_strip(
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 "This is a \035\00313,9cool \003message",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 "This is a cool message");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 test_ircv3_formatting_strip_spec_example3(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 test_ircv3_formatting_strip(
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 "IRC \002is \0034,12so \003great\017!",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 "IRC is so great!");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 static void
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 test_ircv3_formatting_strip_spec_example4(void) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 test_ircv3_formatting_strip(
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 "Rules: Don't spam 5\00313,8,6\003,7,8, and especially not \0029\002\035!",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 "Rules: Don't spam 5,6,7,8, and especially not 9!");
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 }
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 /******************************************************************************
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 * Main
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 *****************************************************************************/
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 int
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 main(int argc, char *argv[]) {
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 g_test_init(&argc, &argv, NULL);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 g_test_add_func("/ircv3/formatting/strip/null",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 test_ircv3_formatting_strip_null);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 g_test_add_func("/ircv3/formatting/strip/empty",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 test_ircv3_formatting_strip_empty);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 g_test_add_func("/ircv3/formatting/strip/color-comma",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 test_ircv3_formatting_strip_color_comma);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 g_test_add_func("/ircv3/formatting/strip/color-full",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 test_ircv3_formatting_strip_color_full);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 g_test_add_func("/ircv3/formatting/strip/color-foreground-comma",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 test_ircv3_formatting_strip_color_foreground_comma);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 g_test_add_func("/ircv3/formatting/strip/color-foreground-3-digit",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 test_ircv3_formatting_strip_color_foreground_3_digit);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 g_test_add_func("/ircv3/formatting/strip/color-background-3-digit",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 test_ircv3_formatting_strip_color_background_3_digit);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 g_test_add_func("/ircv3/formatting/strip/hex-color",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 test_ircv3_formatting_strip_hex_color);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 g_test_add_func("/ircv3/formatting/strip/hex-color-full",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 test_ircv3_formatting_strip_hex_color_full);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 g_test_add_func("/ircv3/formatting/strip/hex-color-comma",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 test_ircv3_formatting_strip_hex_color_comma);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 g_test_add_func("/ircv3/formatting/strip/hex-color-foreground-comma",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 test_ircv3_formatting_strip_hex_color_foreground_comma);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 g_test_add_func("/ircv3/formatting/strip/hex-color-foreground-7-characters",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 test_ircv3_formatting_strip_hex_color_foreground_7_characters);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 g_test_add_func("/ircv3/formatting/strip/hex-color-background-7-characters",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 test_ircv3_formatting_strip_hex_color_background_7_characters);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 g_test_add_func("/ircv3/formatting/strip/bold",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 test_ircv3_formatting_strip_bold);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 g_test_add_func("/ircv3/formatting/strip/italic",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 test_ircv3_formatting_strip_italic);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 g_test_add_func("/ircv3/formatting/strip/monospace",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 test_ircv3_formatting_strip_monospace);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 g_test_add_func("/ircv3/formatting/strip/reset",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 test_ircv3_formatting_strip_reset);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 g_test_add_func("/ircv3/formatting/strip/reverse",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 test_ircv3_formatting_strip_reverse);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 g_test_add_func("/ircv3/formatting/strip/strikethrough",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 test_ircv3_formatting_strip_strikethrough);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 g_test_add_func("/ircv3/formatting/strip/underline",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 test_ircv3_formatting_strip_underline);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 /* These tests are based on the examples here
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 * https://modern.ircdocs.horse/formatting.html#examples
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 */
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 g_test_add_func("/ircv3/formatting/strip/spec-example1",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 test_ircv3_formatting_strip_spec_example1);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 g_test_add_func("/ircv3/formatting/strip/spec-example2",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 test_ircv3_formatting_strip_spec_example2);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 g_test_add_func("/ircv3/formatting/strip/spec-example3",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 test_ircv3_formatting_strip_spec_example3);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 g_test_add_func("/ircv3/formatting/strip/spec-example4",
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 test_ircv3_formatting_strip_spec_example4);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 return g_test_run();
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 }

mercurial