]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * msgbuf_unparse1.c: Test msgbuf under various conditions | |
3 | * Copyright 2017 Simon Arlott | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | |
18 | * USA | |
19 | */ | |
20 | #include <stdio.h> | |
21 | #include <string.h> | |
22 | #include <stdlib.h> | |
23 | #include <unistd.h> | |
24 | #include "tap/basic.h" | |
25 | ||
26 | #include "stdinc.h" | |
27 | #include "ircd_defs.h" | |
28 | #include "msgbuf.h" | |
29 | #include "client.h" | |
30 | ||
31 | #define MSG "%s:%d (%s)", __FILE__, __LINE__, __FUNCTION__ | |
32 | ||
33 | struct Client me; | |
34 | static const char text[] = | |
35 | "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba" | |
36 | "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
37 | "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba" | |
38 | "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
39 | "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba" | |
40 | "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
41 | "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba" | |
42 | "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
43 | "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba" | |
44 | "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
45 | ; | |
46 | ||
47 | #define MKTEXT(n) &text[sizeof(text) - ((n) + 1)] | |
48 | ||
49 | /* must be much larger than the intended maximum output tags/data size */ | |
50 | #define OUTPUT_BUFSIZE (EXT_BUFSIZE * 4) | |
51 | ||
52 | static void basic_tags1(void) | |
53 | { | |
54 | const struct MsgBuf msgbuf = { | |
55 | .n_tags = 1, | |
56 | .tags = { | |
57 | { .key = "tag", .value = "value", .capmask = 1 }, | |
58 | }, | |
59 | ||
60 | .cmd = "PRIVMSG", | |
61 | .origin = "origin", | |
62 | .target = "#test", | |
63 | ||
64 | .n_para = 3, | |
65 | .para = { "test", "test", "test test" }, | |
66 | }; | |
67 | char output[OUTPUT_BUFSIZE]; | |
68 | ||
69 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
70 | is_string("@tag=value :origin PRIVMSG #test test test :test test", output, MSG); | |
71 | } | |
72 | } | |
73 | ||
74 | static void basic_tags2(void) | |
75 | { | |
76 | const struct MsgBuf msgbuf = { | |
77 | .n_tags = 2, | |
78 | .tags = { | |
79 | { .key = "tag1", .value = "value1", .capmask = 1 }, | |
80 | { .key = "tag2", .value = "value2", .capmask = 1 }, | |
81 | }, | |
82 | ||
83 | .cmd = "PRIVMSG", | |
84 | .origin = "origin", | |
85 | .target = "#test", | |
86 | ||
87 | .n_para = 3, | |
88 | .para = { "test", "test", "test test" }, | |
89 | }; | |
90 | char output[OUTPUT_BUFSIZE]; | |
91 | ||
92 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
93 | is_string("@tag1=value1;tag2=value2 :origin PRIVMSG #test test test :test test", output, MSG); | |
94 | } | |
95 | } | |
96 | ||
97 | static void basic_tags15(void) | |
98 | { | |
99 | const struct MsgBuf msgbuf = { | |
100 | .n_tags = 15, | |
101 | .tags = { | |
102 | { .key = "tag1", .value = "value1", .capmask = 1 }, | |
103 | { .key = "tag2", .value = "value2", .capmask = 1 }, | |
104 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
105 | { .key = "tag4", .value = "value4", .capmask = 1 }, | |
106 | { .key = "tag5", .value = "value5", .capmask = 1 }, | |
107 | { .key = "tag6", .value = "value6", .capmask = 1 }, | |
108 | { .key = "tag7", .value = "value7", .capmask = 1 }, | |
109 | { .key = "tag8", .value = "value8", .capmask = 1 }, | |
110 | { .key = "tag9", .value = "value9", .capmask = 1 }, | |
111 | { .key = "tag10", .value = "value10", .capmask = 1 }, | |
112 | { .key = "tag11", .value = "value11", .capmask = 1 }, | |
113 | { .key = "tag12", .value = "value12", .capmask = 1 }, | |
114 | { .key = "tag13", .value = "value13", .capmask = 1 }, | |
115 | { .key = "tag14", .value = "value14", .capmask = 1 }, | |
116 | { .key = "tag15", .value = "value15", .capmask = 1 }, | |
117 | }, | |
118 | ||
119 | .cmd = "PRIVMSG", | |
120 | .origin = "origin", | |
121 | .target = "#test", | |
122 | ||
123 | .n_para = 3, | |
124 | .para = { "test", "test", "test test" }, | |
125 | }; | |
126 | char output[OUTPUT_BUFSIZE]; | |
127 | ||
128 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
129 | is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag5=value5;tag6=value6;tag7=value7;tag8=value8;tag9=value9;tag10=value10;tag11=value11;tag12=value12;tag13=value13;tag14=value14;tag15=value15 :origin PRIVMSG #test test test :test test", output, MSG); | |
130 | } | |
131 | } | |
132 | ||
133 | static void basic_tags15_capmask1(void) | |
134 | { | |
135 | const struct MsgBuf msgbuf = { | |
136 | .n_tags = 15, | |
137 | .tags = { | |
138 | { .key = "tag1", .value = "value1", .capmask = 0x1 }, | |
139 | { .key = "tag2", .value = "value2", .capmask = 0x3 }, | |
140 | { .key = "tag3", .value = "value3", .capmask = 0xffffffff }, | |
141 | { .key = "tag4", .value = "value4", .capmask = 0xffff }, | |
142 | { .key = "tag5", .value = "value5", .capmask = 0x0 }, | |
143 | { .key = "tag6", .value = "value6", .capmask = 0x3e9 }, | |
144 | { .key = "tag7", .value = "value7", .capmask = 0x2 }, | |
145 | { .key = "tag8", .value = "value8", .capmask = 0x65 }, | |
146 | { .key = "tag9", .value = "value9", .capmask = 0x5 }, | |
147 | { .key = "tag10", .value = "value10", .capmask = 0x7fffffff }, | |
148 | { .key = "tag11", .value = "value11", .capmask = 0x80000001 }, | |
149 | { .key = "tag12", .value = "value12", .capmask = 0xf }, | |
150 | { .key = "tag13", .value = "value13", .capmask = 0x6 }, | |
151 | { .key = "tag14", .value = "value14", .capmask = 0x4 }, | |
152 | { .key = "tag15", .value = "value15", .capmask = 0x7 }, | |
153 | }, | |
154 | ||
155 | .cmd = "PRIVMSG", | |
156 | .origin = "origin", | |
157 | .target = "#test", | |
158 | ||
159 | .n_para = 3, | |
160 | .para = { "test", "test", "test test" }, | |
161 | }; | |
162 | char output[OUTPUT_BUFSIZE]; | |
163 | ||
164 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
165 | is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag6=value6;tag8=value8;tag9=value9;tag10=value10;tag11=value11;tag12=value12;tag15=value15 :origin PRIVMSG #test test test :test test", output, MSG); | |
166 | } | |
167 | } | |
168 | ||
169 | static void basic_tags15_capmask2(void) | |
170 | { | |
171 | const struct MsgBuf msgbuf = { | |
172 | .n_tags = 15, | |
173 | .tags = { | |
174 | { .key = "tag1", .value = "value1", .capmask = 0x1 }, | |
175 | { .key = "tag2", .value = "value2", .capmask = 0x3 }, | |
176 | { .key = "tag3", .value = "value3", .capmask = 0xffffffff }, | |
177 | { .key = "tag4", .value = "value4", .capmask = 0xffff }, | |
178 | { .key = "tag5", .value = "value5", .capmask = 0x0 }, | |
179 | { .key = "tag6", .value = "value6", .capmask = 0x3e9 }, | |
180 | { .key = "tag7", .value = "value7", .capmask = 0x2 }, | |
181 | { .key = "tag8", .value = "value8", .capmask = 0x65 }, | |
182 | { .key = "tag9", .value = "value9", .capmask = 0x5 }, | |
183 | { .key = "tag10", .value = "value10", .capmask = 0x7fffffff }, | |
184 | { .key = "tag11", .value = "value11", .capmask = 0x80000001 }, | |
185 | { .key = "tag12", .value = "value12", .capmask = 0xf }, | |
186 | { .key = "tag13", .value = "value13", .capmask = 0x6 }, | |
187 | { .key = "tag14", .value = "value14", .capmask = 0x4 }, | |
188 | { .key = "tag15", .value = "value15", .capmask = 0x7 }, | |
189 | }, | |
190 | ||
191 | .cmd = "PRIVMSG", | |
192 | .origin = "origin", | |
193 | .target = "#test", | |
194 | ||
195 | .n_para = 3, | |
196 | .para = { "test", "test", "test test" }, | |
197 | }; | |
198 | char output[OUTPUT_BUFSIZE]; | |
199 | ||
200 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 0x24), MSG)) { | |
201 | is_string("@tag3=value3;tag4=value4;tag6=value6;tag8=value8;tag9=value9;tag10=value10;tag12=value12;tag13=value13;tag14=value14;tag15=value15 :origin PRIVMSG #test test test :test test", output, MSG); | |
202 | } | |
203 | } | |
204 | ||
205 | static void no_tags(void) | |
206 | { | |
207 | const struct MsgBuf msgbuf = { | |
208 | .n_tags = 0, | |
209 | .tags = {}, | |
210 | ||
211 | .cmd = "PRIVMSG", | |
212 | .origin = "origin", | |
213 | .target = "#test", | |
214 | ||
215 | .n_para = 3, | |
216 | .para = { "test", "test", "test test" }, | |
217 | }; | |
218 | char output[OUTPUT_BUFSIZE]; | |
219 | ||
220 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
221 | is_string(":origin PRIVMSG #test test test :test test", output, MSG); | |
222 | } | |
223 | } | |
224 | ||
225 | static void empty_tag(void) | |
226 | { | |
227 | const struct MsgBuf msgbuf = { | |
228 | .n_tags = 1, | |
229 | .tags = { | |
230 | { .key = "", .value = "value", .capmask = 1 }, | |
231 | }, | |
232 | ||
233 | .cmd = "PRIVMSG", | |
234 | .origin = "origin", | |
235 | .target = "#test", | |
236 | ||
237 | .n_para = 3, | |
238 | .para = { "test", "test", "test test" }, | |
239 | }; | |
240 | char output[OUTPUT_BUFSIZE]; | |
241 | ||
242 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
243 | is_string(":origin PRIVMSG #test test test :test test", output, MSG); | |
244 | } | |
245 | } | |
246 | ||
247 | static void too_long_for_tag2a_0remaining(void) | |
248 | { | |
249 | const struct MsgBuf msgbuf = { | |
250 | .n_tags = 3, | |
251 | .tags = { | |
252 | { .key = MKTEXT(259), .value = MKTEXT(250), .capmask = 1 }, | |
253 | { .key = "tag2", .value = "value2", .capmask = 1 }, | |
254 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
255 | }, | |
256 | ||
257 | .cmd = "PRIVMSG", | |
258 | .origin = "origin", | |
259 | .target = "#test", | |
260 | ||
261 | .n_para = 3, | |
262 | .para = { "test", "test", "test test" }, | |
263 | }; | |
264 | char output[OUTPUT_BUFSIZE]; | |
265 | ||
266 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
267 | char tmp[2048]; | |
268 | ||
269 | strcpy(tmp, "@"); | |
270 | strcat(tmp, MKTEXT(259)); | |
271 | strcat(tmp, "="); | |
272 | strcat(tmp, MKTEXT(250)); | |
273 | strcat(tmp, " "); | |
274 | is_int(512, strlen(tmp), MSG); | |
275 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
276 | ||
277 | is_string(tmp, output, MSG); | |
278 | } | |
279 | } | |
280 | ||
281 | static void too_long_for_tag2a_1remaining(void) | |
282 | { | |
283 | const struct MsgBuf msgbuf = { | |
284 | .n_tags = 3, | |
285 | .tags = { | |
286 | { .key = MKTEXT(259), .value = MKTEXT(249), .capmask = 1 }, | |
287 | { .key = "tag2", .value = "value2", .capmask = 1 }, | |
288 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
289 | }, | |
290 | ||
291 | .cmd = "PRIVMSG", | |
292 | .origin = "origin", | |
293 | .target = "#test", | |
294 | ||
295 | .n_para = 3, | |
296 | .para = { "test", "test", "test test" }, | |
297 | }; | |
298 | char output[OUTPUT_BUFSIZE]; | |
299 | ||
300 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
301 | char tmp[2048]; | |
302 | ||
303 | strcpy(tmp, "@"); | |
304 | strcat(tmp, MKTEXT(259)); | |
305 | strcat(tmp, "="); | |
306 | strcat(tmp, MKTEXT(249)); | |
307 | strcat(tmp, " "); | |
308 | is_int(512 - 1, strlen(tmp), MSG); | |
309 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
310 | ||
311 | is_string(tmp, output, MSG); | |
312 | } | |
313 | } | |
314 | ||
315 | static void too_long_for_tag2a_2remaining(void) | |
316 | { | |
317 | const struct MsgBuf msgbuf = { | |
318 | .n_tags = 3, | |
319 | .tags = { | |
320 | { .key = MKTEXT(259), .value = MKTEXT(248), .capmask = 1 }, | |
321 | { .key = "tag2", .value = "value2", .capmask = 1 }, | |
322 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
323 | }, | |
324 | ||
325 | .cmd = "PRIVMSG", | |
326 | .origin = "origin", | |
327 | .target = "#test", | |
328 | ||
329 | .n_para = 3, | |
330 | .para = { "test", "test", "test test" }, | |
331 | }; | |
332 | char output[OUTPUT_BUFSIZE]; | |
333 | ||
334 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
335 | char tmp[2048]; | |
336 | ||
337 | strcpy(tmp, "@"); | |
338 | strcat(tmp, MKTEXT(259)); | |
339 | strcat(tmp, "="); | |
340 | strcat(tmp, MKTEXT(248)); | |
341 | strcat(tmp, " "); | |
342 | is_int(512 - 2, strlen(tmp), MSG); | |
343 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
344 | ||
345 | is_string(tmp, output, MSG); | |
346 | } | |
347 | } | |
348 | ||
349 | static void too_long_for_tag2a_3remaining(void) | |
350 | { | |
351 | const struct MsgBuf msgbuf = { | |
352 | .n_tags = 3, | |
353 | .tags = { | |
354 | { .key = MKTEXT(259), .value = MKTEXT(247), .capmask = 1 }, | |
355 | { .key = "tag2", .value = "value2", .capmask = 1 }, | |
356 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
357 | }, | |
358 | ||
359 | .cmd = "PRIVMSG", | |
360 | .origin = "origin", | |
361 | .target = "#test", | |
362 | ||
363 | .n_para = 3, | |
364 | .para = { "test", "test", "test test" }, | |
365 | }; | |
366 | char output[OUTPUT_BUFSIZE]; | |
367 | ||
368 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
369 | char tmp[2048]; | |
370 | ||
371 | strcpy(tmp, "@"); | |
372 | strcat(tmp, MKTEXT(259)); | |
373 | strcat(tmp, "="); | |
374 | strcat(tmp, MKTEXT(247)); | |
375 | strcat(tmp, " "); | |
376 | is_int(512 - 3, strlen(tmp), MSG); | |
377 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
378 | ||
379 | is_string(tmp, output, MSG); | |
380 | } | |
381 | } | |
382 | ||
383 | static void too_long_for_tag2a_3short(void) | |
384 | { | |
385 | const struct MsgBuf msgbuf = { | |
386 | .n_tags = 3, | |
387 | .tags = { | |
388 | { .key = MKTEXT(259), .value = MKTEXT(241), .capmask = 1 }, | |
389 | { .key = "tag2", .value = "value2", .capmask = 1 }, | |
390 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
391 | }, | |
392 | ||
393 | .cmd = "PRIVMSG", | |
394 | .origin = "origin", | |
395 | .target = "#test", | |
396 | ||
397 | .n_para = 3, | |
398 | .para = { "test", "test", "test test" }, | |
399 | }; | |
400 | char output[OUTPUT_BUFSIZE]; | |
401 | ||
402 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
403 | char tmp[2048]; | |
404 | ||
405 | strcpy(tmp, "@"); | |
406 | strcat(tmp, MKTEXT(259)); | |
407 | strcat(tmp, "="); | |
408 | strcat(tmp, MKTEXT(241)); | |
409 | strcat(tmp, " "); | |
410 | is_int(512 - 9, strlen(tmp), MSG); | |
411 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
412 | ||
413 | is_string(tmp, output, MSG); | |
414 | } | |
415 | } | |
416 | ||
417 | static void too_long_for_tag2a_2short(void) | |
418 | { | |
419 | const struct MsgBuf msgbuf = { | |
420 | .n_tags = 3, | |
421 | .tags = { | |
422 | { .key = MKTEXT(259), .value = MKTEXT(240), .capmask = 1 }, | |
423 | { .key = "tag2", .value = "value2", .capmask = 1 }, | |
424 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
425 | }, | |
426 | ||
427 | .cmd = "PRIVMSG", | |
428 | .origin = "origin", | |
429 | .target = "#test", | |
430 | ||
431 | .n_para = 3, | |
432 | .para = { "test", "test", "test test" }, | |
433 | }; | |
434 | char output[OUTPUT_BUFSIZE]; | |
435 | ||
436 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
437 | char tmp[2048]; | |
438 | ||
439 | strcpy(tmp, "@"); | |
440 | strcat(tmp, MKTEXT(259)); | |
441 | strcat(tmp, "="); | |
442 | strcat(tmp, MKTEXT(240)); | |
443 | strcat(tmp, " "); | |
444 | is_int(512 - 10, strlen(tmp), MSG); | |
445 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
446 | ||
447 | is_string(tmp, output, MSG); | |
448 | } | |
449 | } | |
450 | ||
451 | static void too_long_for_tag2a_1short(void) | |
452 | { | |
453 | const struct MsgBuf msgbuf = { | |
454 | .n_tags = 3, | |
455 | .tags = { | |
456 | { .key = MKTEXT(259), .value = MKTEXT(239), .capmask = 1 }, | |
457 | { .key = "tag2", .value = "value2", .capmask = 1 }, | |
458 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
459 | }, | |
460 | ||
461 | .cmd = "PRIVMSG", | |
462 | .origin = "origin", | |
463 | .target = "#test", | |
464 | ||
465 | .n_para = 3, | |
466 | .para = { "test", "test", "test test" }, | |
467 | }; | |
468 | char output[OUTPUT_BUFSIZE]; | |
469 | ||
470 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
471 | char tmp[2048]; | |
472 | ||
473 | strcpy(tmp, "@"); | |
474 | strcat(tmp, MKTEXT(259)); | |
475 | strcat(tmp, "="); | |
476 | strcat(tmp, MKTEXT(239)); | |
477 | strcat(tmp, " "); | |
478 | is_int(512 - 11, strlen(tmp), MSG); | |
479 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
480 | ||
481 | is_string(tmp, output, MSG); | |
482 | } | |
483 | } | |
484 | ||
485 | static void exact_space_for_tag2a(void) | |
486 | { | |
487 | const struct MsgBuf msgbuf = { | |
488 | .n_tags = 3, | |
489 | .tags = { | |
490 | { .key = MKTEXT(259), .value = MKTEXT(238), .capmask = 1 }, | |
491 | { .key = "tag2", .value = "value2", .capmask = 1 }, | |
492 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
493 | }, | |
494 | ||
495 | .cmd = "PRIVMSG", | |
496 | .origin = "origin", | |
497 | .target = "#test", | |
498 | ||
499 | .n_para = 3, | |
500 | .para = { "test", "test", "test test" }, | |
501 | }; | |
502 | char output[OUTPUT_BUFSIZE]; | |
503 | ||
504 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
505 | char tmp[2048]; | |
506 | ||
507 | strcpy(tmp, "@"); | |
508 | strcat(tmp, MKTEXT(259)); | |
509 | strcat(tmp, "="); | |
510 | strcat(tmp, MKTEXT(238)); | |
511 | strcat(tmp, ";tag2=value2 "); | |
512 | is_int(512, strlen(tmp), MSG); | |
513 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
514 | ||
515 | is_string(tmp, output, MSG); | |
516 | } | |
517 | } | |
518 | ||
519 | static void too_long_for_tag2b_0remaining(void) | |
520 | { | |
521 | const struct MsgBuf msgbuf = { | |
522 | .n_tags = 3, | |
523 | .tags = { | |
524 | { .key = MKTEXT(259), .value = MKTEXT(250), .capmask = 1 }, | |
525 | { .key = "a", .value = "b", .capmask = 1 }, | |
526 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
527 | }, | |
528 | ||
529 | .cmd = "PRIVMSG", | |
530 | .origin = "origin", | |
531 | .target = "#test", | |
532 | ||
533 | .n_para = 3, | |
534 | .para = { "test", "test", "test test" }, | |
535 | }; | |
536 | char output[OUTPUT_BUFSIZE]; | |
537 | ||
538 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
539 | char tmp[2048]; | |
540 | ||
541 | strcpy(tmp, "@"); | |
542 | strcat(tmp, MKTEXT(259)); | |
543 | strcat(tmp, "="); | |
544 | strcat(tmp, MKTEXT(250)); | |
545 | strcat(tmp, " "); | |
546 | is_int(512, strlen(tmp), MSG); | |
547 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
548 | ||
549 | is_string(tmp, output, MSG); | |
550 | } | |
551 | } | |
552 | ||
553 | static void too_long_for_tag2b_1remaining(void) | |
554 | { | |
555 | const struct MsgBuf msgbuf = { | |
556 | .n_tags = 3, | |
557 | .tags = { | |
558 | { .key = MKTEXT(259), .value = MKTEXT(249), .capmask = 1 }, | |
559 | { .key = "a", .value = "b", .capmask = 1 }, | |
560 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
561 | }, | |
562 | ||
563 | .cmd = "PRIVMSG", | |
564 | .origin = "origin", | |
565 | .target = "#test", | |
566 | ||
567 | .n_para = 3, | |
568 | .para = { "test", "test", "test test" }, | |
569 | }; | |
570 | char output[OUTPUT_BUFSIZE]; | |
571 | ||
572 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
573 | char tmp[2048]; | |
574 | ||
575 | strcpy(tmp, "@"); | |
576 | strcat(tmp, MKTEXT(259)); | |
577 | strcat(tmp, "="); | |
578 | strcat(tmp, MKTEXT(249)); | |
579 | strcat(tmp, " "); | |
580 | is_int(512 - 1, strlen(tmp), MSG); | |
581 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
582 | ||
583 | is_string(tmp, output, MSG); | |
584 | } | |
585 | } | |
586 | ||
587 | static void too_long_for_tag2b_2remaining(void) | |
588 | { | |
589 | const struct MsgBuf msgbuf = { | |
590 | .n_tags = 3, | |
591 | .tags = { | |
592 | { .key = MKTEXT(259), .value = MKTEXT(248), .capmask = 1 }, | |
593 | { .key = "a", .value = "b", .capmask = 1 }, | |
594 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
595 | }, | |
596 | ||
597 | .cmd = "PRIVMSG", | |
598 | .origin = "origin", | |
599 | .target = "#test", | |
600 | ||
601 | .n_para = 3, | |
602 | .para = { "test", "test", "test test" }, | |
603 | }; | |
604 | char output[OUTPUT_BUFSIZE]; | |
605 | ||
606 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
607 | char tmp[2048]; | |
608 | ||
609 | strcpy(tmp, "@"); | |
610 | strcat(tmp, MKTEXT(259)); | |
611 | strcat(tmp, "="); | |
612 | strcat(tmp, MKTEXT(248)); | |
613 | strcat(tmp, " "); | |
614 | is_int(512 - 2, strlen(tmp), MSG); | |
615 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
616 | ||
617 | is_string(tmp, output, MSG); | |
618 | } | |
619 | } | |
620 | ||
621 | static void too_long_for_tag2b_3remaining(void) | |
622 | { | |
623 | const struct MsgBuf msgbuf = { | |
624 | .n_tags = 3, | |
625 | .tags = { | |
626 | { .key = MKTEXT(259), .value = MKTEXT(247), .capmask = 1 }, | |
627 | { .key = "a", .value = "b", .capmask = 1 }, | |
628 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
629 | }, | |
630 | ||
631 | .cmd = "PRIVMSG", | |
632 | .origin = "origin", | |
633 | .target = "#test", | |
634 | ||
635 | .n_para = 3, | |
636 | .para = { "test", "test", "test test" }, | |
637 | }; | |
638 | char output[OUTPUT_BUFSIZE]; | |
639 | ||
640 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
641 | char tmp[2048]; | |
642 | ||
643 | strcpy(tmp, "@"); | |
644 | strcat(tmp, MKTEXT(259)); | |
645 | strcat(tmp, "="); | |
646 | strcat(tmp, MKTEXT(247)); | |
647 | strcat(tmp, " "); | |
648 | is_int(512 - 3, strlen(tmp), MSG); | |
649 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
650 | ||
651 | is_string(tmp, output, MSG); | |
652 | } | |
653 | } | |
654 | ||
655 | static void too_long_for_tag2b_3short(void) | |
656 | { | |
657 | const struct MsgBuf msgbuf = { | |
658 | .n_tags = 3, | |
659 | .tags = { | |
660 | { .key = MKTEXT(267), .value = MKTEXT(241), .capmask = 1 }, | |
661 | { .key = "a", .value = "b", .capmask = 1 }, | |
662 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
663 | }, | |
664 | ||
665 | .cmd = "PRIVMSG", | |
666 | .origin = "origin", | |
667 | .target = "#test", | |
668 | ||
669 | .n_para = 3, | |
670 | .para = { "test", "test", "test test" }, | |
671 | }; | |
672 | char output[OUTPUT_BUFSIZE]; | |
673 | ||
674 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
675 | char tmp[2048]; | |
676 | ||
677 | strcpy(tmp, "@"); | |
678 | strcat(tmp, MKTEXT(267)); | |
679 | strcat(tmp, "="); | |
680 | strcat(tmp, MKTEXT(241)); | |
681 | strcat(tmp, " "); | |
682 | is_int(512 - 1, strlen(tmp), MSG); | |
683 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
684 | ||
685 | is_string(tmp, output, MSG); | |
686 | } | |
687 | } | |
688 | ||
689 | static void too_long_for_tag2b_2short(void) | |
690 | { | |
691 | const struct MsgBuf msgbuf = { | |
692 | .n_tags = 3, | |
693 | .tags = { | |
694 | { .key = MKTEXT(267), .value = MKTEXT(240), .capmask = 1 }, | |
695 | { .key = "a", .value = "b", .capmask = 1 }, | |
696 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
697 | }, | |
698 | ||
699 | .cmd = "PRIVMSG", | |
700 | .origin = "origin", | |
701 | .target = "#test", | |
702 | ||
703 | .n_para = 3, | |
704 | .para = { "test", "test", "test test" }, | |
705 | }; | |
706 | char output[OUTPUT_BUFSIZE]; | |
707 | ||
708 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
709 | char tmp[2048]; | |
710 | ||
711 | strcpy(tmp, "@"); | |
712 | strcat(tmp, MKTEXT(267)); | |
713 | strcat(tmp, "="); | |
714 | strcat(tmp, MKTEXT(240)); | |
715 | strcat(tmp, " "); | |
716 | is_int(512 - 2, strlen(tmp), MSG); | |
717 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
718 | ||
719 | is_string(tmp, output, MSG); | |
720 | } | |
721 | } | |
722 | ||
723 | static void too_long_for_tag2b_1short(void) | |
724 | { | |
725 | const struct MsgBuf msgbuf = { | |
726 | .n_tags = 3, | |
727 | .tags = { | |
728 | { .key = MKTEXT(267), .value = MKTEXT(239), .capmask = 1 }, | |
729 | { .key = "a", .value = "b", .capmask = 1 }, | |
730 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
731 | }, | |
732 | ||
733 | .cmd = "PRIVMSG", | |
734 | .origin = "origin", | |
735 | .target = "#test", | |
736 | ||
737 | .n_para = 3, | |
738 | .para = { "test", "test", "test test" }, | |
739 | }; | |
740 | char output[OUTPUT_BUFSIZE]; | |
741 | ||
742 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
743 | char tmp[2048]; | |
744 | ||
745 | strcpy(tmp, "@"); | |
746 | strcat(tmp, MKTEXT(267)); | |
747 | strcat(tmp, "="); | |
748 | strcat(tmp, MKTEXT(239)); | |
749 | strcat(tmp, " "); | |
750 | is_int(512 - 3, strlen(tmp), MSG); | |
751 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
752 | ||
753 | is_string(tmp, output, MSG); | |
754 | } | |
755 | } | |
756 | ||
757 | static void exact_space_for_tag2b(void) | |
758 | { | |
759 | const struct MsgBuf msgbuf = { | |
760 | .n_tags = 3, | |
761 | .tags = { | |
762 | { .key = MKTEXT(267), .value = MKTEXT(238), .capmask = 1 }, | |
763 | { .key = "a", .value = "b", .capmask = 1 }, | |
764 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
765 | }, | |
766 | ||
767 | .cmd = "PRIVMSG", | |
768 | .origin = "origin", | |
769 | .target = "#test", | |
770 | ||
771 | .n_para = 3, | |
772 | .para = { "test", "test", "test test" }, | |
773 | }; | |
774 | char output[OUTPUT_BUFSIZE]; | |
775 | ||
776 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
777 | char tmp[2048]; | |
778 | ||
779 | strcpy(tmp, "@"); | |
780 | strcat(tmp, MKTEXT(267)); | |
781 | strcat(tmp, "="); | |
782 | strcat(tmp, MKTEXT(238)); | |
783 | strcat(tmp, ";a=b "); | |
784 | is_int(512, strlen(tmp), MSG); | |
785 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
786 | ||
787 | is_string(tmp, output, MSG); | |
788 | } | |
789 | } | |
790 | ||
791 | static void long_tag1_no_value(void) | |
792 | { | |
793 | const struct MsgBuf msgbuf = { | |
794 | .n_tags = 1, | |
795 | .tags = { | |
796 | { .key = MKTEXT(510), .value = NULL, .capmask = 1 }, | |
797 | }, | |
798 | ||
799 | .cmd = "PRIVMSG", | |
800 | .origin = "origin", | |
801 | .target = "#test", | |
802 | ||
803 | .n_para = 3, | |
804 | .para = { "test", "test", "test test" }, | |
805 | }; | |
806 | char output[OUTPUT_BUFSIZE]; | |
807 | ||
808 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
809 | char tmp[2048]; | |
810 | ||
811 | strcpy(tmp, "@"); | |
812 | strcat(tmp, MKTEXT(510)); | |
813 | strcat(tmp, " "); | |
814 | is_int(512, strlen(tmp), MSG); | |
815 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
816 | ||
817 | is_string(tmp, output, MSG); | |
818 | } | |
819 | } | |
820 | ||
821 | static void long_tag1_empty_value(void) | |
822 | { | |
823 | const struct MsgBuf msgbuf = { | |
824 | .n_tags = 1, | |
825 | .tags = { | |
826 | { .key = MKTEXT(509), .value = "", .capmask = 1 }, | |
827 | }, | |
828 | ||
829 | .cmd = "PRIVMSG", | |
830 | .origin = "origin", | |
831 | .target = "#test", | |
832 | ||
833 | .n_para = 3, | |
834 | .para = { "test", "test", "test test" }, | |
835 | }; | |
836 | char output[OUTPUT_BUFSIZE]; | |
837 | ||
838 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
839 | char tmp[2048]; | |
840 | ||
841 | strcpy(tmp, "@"); | |
842 | strcat(tmp, MKTEXT(509)); | |
843 | strcat(tmp, "= "); | |
844 | is_int(512, strlen(tmp), MSG); | |
845 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
846 | ||
847 | is_string(tmp, output, MSG); | |
848 | } | |
849 | } | |
850 | ||
851 | static void long_tag1_short_value(void) | |
852 | { | |
853 | const struct MsgBuf msgbuf = { | |
854 | .n_tags = 1, | |
855 | .tags = { | |
856 | { .key = MKTEXT(508), .value = "x", .capmask = 1 }, | |
857 | }, | |
858 | ||
859 | .cmd = "PRIVMSG", | |
860 | .origin = "origin", | |
861 | .target = "#test", | |
862 | ||
863 | .n_para = 3, | |
864 | .para = { "test", "test", "test test" }, | |
865 | }; | |
866 | char output[OUTPUT_BUFSIZE]; | |
867 | ||
868 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
869 | char tmp[2048]; | |
870 | ||
871 | strcpy(tmp, "@"); | |
872 | strcat(tmp, MKTEXT(508)); | |
873 | strcat(tmp, "=x "); | |
874 | is_int(512, strlen(tmp), MSG); | |
875 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
876 | ||
877 | is_string(tmp, output, MSG); | |
878 | } | |
879 | } | |
880 | ||
881 | static void short_tag1_long_value(void) | |
882 | { | |
883 | const struct MsgBuf msgbuf = { | |
884 | .n_tags = 1, | |
885 | .tags = { | |
886 | { .key = "x", .value = MKTEXT(508), .capmask = 1 }, | |
887 | }, | |
888 | ||
889 | .cmd = "PRIVMSG", | |
890 | .origin = "origin", | |
891 | .target = "#test", | |
892 | ||
893 | .n_para = 3, | |
894 | .para = { "test", "test", "test test" }, | |
895 | }; | |
896 | char output[OUTPUT_BUFSIZE]; | |
897 | ||
898 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
899 | char tmp[2048]; | |
900 | ||
901 | strcpy(tmp, "@x="); | |
902 | strcat(tmp, MKTEXT(508)); | |
903 | strcat(tmp, " "); | |
904 | is_int(512, strlen(tmp), MSG); | |
905 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
906 | ||
907 | is_string(tmp, output, MSG); | |
908 | } | |
909 | } | |
910 | ||
911 | static void too_long_tag1_no_value(void) | |
912 | { | |
913 | const struct MsgBuf msgbuf = { | |
914 | .n_tags = 1, | |
915 | .tags = { | |
916 | { .key = MKTEXT(511), .value = NULL, .capmask = 1 }, | |
917 | }, | |
918 | ||
919 | .cmd = "PRIVMSG", | |
920 | .origin = "origin", | |
921 | .target = "#test", | |
922 | ||
923 | .n_para = 3, | |
924 | .para = { "test", "test", "test test" }, | |
925 | }; | |
926 | char output[OUTPUT_BUFSIZE]; | |
927 | ||
928 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
929 | is_string(":origin PRIVMSG #test test test :test test", output, MSG); | |
930 | } | |
931 | } | |
932 | ||
933 | static void too_long_tag1_empty_value(void) | |
934 | { | |
935 | const struct MsgBuf msgbuf = { | |
936 | .n_tags = 1, | |
937 | .tags = { | |
938 | { .key = MKTEXT(510), .value = "", .capmask = 1 }, | |
939 | }, | |
940 | ||
941 | .cmd = "PRIVMSG", | |
942 | .origin = "origin", | |
943 | .target = "#test", | |
944 | ||
945 | .n_para = 3, | |
946 | .para = { "test", "test", "test test" }, | |
947 | }; | |
948 | char output[OUTPUT_BUFSIZE]; | |
949 | ||
950 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
951 | is_string(":origin PRIVMSG #test test test :test test", output, MSG); | |
952 | } | |
953 | } | |
954 | ||
955 | static void too_long_tag1_short_value(void) | |
956 | { | |
957 | const struct MsgBuf msgbuf = { | |
958 | .n_tags = 1, | |
959 | .tags = { | |
960 | { .key = MKTEXT(509), .value = "x", .capmask = 1 }, | |
961 | }, | |
962 | ||
963 | .cmd = "PRIVMSG", | |
964 | .origin = "origin", | |
965 | .target = "#test", | |
966 | ||
967 | .n_para = 3, | |
968 | .para = { "test", "test", "test test" }, | |
969 | }; | |
970 | char output[OUTPUT_BUFSIZE]; | |
971 | ||
972 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
973 | is_string(":origin PRIVMSG #test test test :test test", output, MSG); | |
974 | } | |
975 | } | |
976 | ||
977 | static void short_tag1_too_long_value(void) | |
978 | { | |
979 | const struct MsgBuf msgbuf = { | |
980 | .n_tags = 1, | |
981 | .tags = { | |
982 | { .key = "x", .value = MKTEXT(509), .capmask = 1 }, | |
983 | }, | |
984 | ||
985 | .cmd = "PRIVMSG", | |
986 | .origin = "origin", | |
987 | .target = "#test", | |
988 | ||
989 | .n_para = 3, | |
990 | .para = { "test", "test", "test test" }, | |
991 | }; | |
992 | char output[OUTPUT_BUFSIZE]; | |
993 | ||
994 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
995 | is_string(":origin PRIVMSG #test test test :test test", output, MSG); | |
996 | } | |
997 | } | |
998 | ||
999 | static void long_tag2a_no_value(void) | |
1000 | { | |
1001 | const struct MsgBuf msgbuf = { | |
1002 | .n_tags = 2, | |
1003 | .tags = { | |
1004 | { .key = "a", .value = NULL, .capmask = 1 }, | |
1005 | { .key = MKTEXT(508), .value = NULL, .capmask = 1 }, | |
1006 | }, | |
1007 | ||
1008 | .cmd = "PRIVMSG", | |
1009 | .origin = "origin", | |
1010 | .target = "#test", | |
1011 | ||
1012 | .n_para = 3, | |
1013 | .para = { "test", "test", "test test" }, | |
1014 | }; | |
1015 | char output[OUTPUT_BUFSIZE]; | |
1016 | ||
1017 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1018 | char tmp[2048]; | |
1019 | ||
1020 | strcpy(tmp, "@a;"); | |
1021 | strcat(tmp, MKTEXT(508)); | |
1022 | strcat(tmp, " "); | |
1023 | is_int(512, strlen(tmp), MSG); | |
1024 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1025 | ||
1026 | is_string(tmp, output, MSG); | |
1027 | } | |
1028 | } | |
1029 | ||
1030 | static void long_tag2b_no_value(void) | |
1031 | { | |
1032 | const struct MsgBuf msgbuf = { | |
1033 | .n_tags = 2, | |
1034 | .tags = { | |
1035 | { .key = "a", .value = "", .capmask = 1 }, | |
1036 | { .key = MKTEXT(507), .value = NULL, .capmask = 1 }, | |
1037 | }, | |
1038 | ||
1039 | .cmd = "PRIVMSG", | |
1040 | .origin = "origin", | |
1041 | .target = "#test", | |
1042 | ||
1043 | .n_para = 3, | |
1044 | .para = { "test", "test", "test test" }, | |
1045 | }; | |
1046 | char output[OUTPUT_BUFSIZE]; | |
1047 | ||
1048 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1049 | char tmp[2048]; | |
1050 | ||
1051 | strcpy(tmp, "@a=;"); | |
1052 | strcat(tmp, MKTEXT(507)); | |
1053 | strcat(tmp, " "); | |
1054 | is_int(512, strlen(tmp), MSG); | |
1055 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1056 | ||
1057 | is_string(tmp, output, MSG); | |
1058 | } | |
1059 | } | |
1060 | ||
1061 | static void long_tag2c_no_value(void) | |
1062 | { | |
1063 | const struct MsgBuf msgbuf = { | |
1064 | .n_tags = 2, | |
1065 | .tags = { | |
1066 | { .key = "a", .value = "b", .capmask = 1 }, | |
1067 | { .key = MKTEXT(506), .value = NULL, .capmask = 1 }, | |
1068 | }, | |
1069 | ||
1070 | .cmd = "PRIVMSG", | |
1071 | .origin = "origin", | |
1072 | .target = "#test", | |
1073 | ||
1074 | .n_para = 3, | |
1075 | .para = { "test", "test", "test test" }, | |
1076 | }; | |
1077 | char output[OUTPUT_BUFSIZE]; | |
1078 | ||
1079 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1080 | char tmp[2048]; | |
1081 | ||
1082 | strcpy(tmp, "@a=b;"); | |
1083 | strcat(tmp, MKTEXT(506)); | |
1084 | strcat(tmp, " "); | |
1085 | is_int(512, strlen(tmp), MSG); | |
1086 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1087 | ||
1088 | is_string(tmp, output, MSG); | |
1089 | } | |
1090 | } | |
1091 | ||
1092 | static void long_tag2a_empty_value(void) | |
1093 | { | |
1094 | const struct MsgBuf msgbuf = { | |
1095 | .n_tags = 2, | |
1096 | .tags = { | |
1097 | { .key = "a", .value = NULL, .capmask = 1 }, | |
1098 | { .key = MKTEXT(507), .value = "", .capmask = 1 }, | |
1099 | }, | |
1100 | ||
1101 | .cmd = "PRIVMSG", | |
1102 | .origin = "origin", | |
1103 | .target = "#test", | |
1104 | ||
1105 | .n_para = 3, | |
1106 | .para = { "test", "test", "test test" }, | |
1107 | }; | |
1108 | char output[OUTPUT_BUFSIZE]; | |
1109 | ||
1110 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1111 | char tmp[2048]; | |
1112 | ||
1113 | strcpy(tmp, "@a;"); | |
1114 | strcat(tmp, MKTEXT(507)); | |
1115 | strcat(tmp, "= "); | |
1116 | is_int(512, strlen(tmp), MSG); | |
1117 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1118 | ||
1119 | is_string(tmp, output, MSG); | |
1120 | } | |
1121 | } | |
1122 | ||
1123 | static void long_tag2b_empty_value(void) | |
1124 | { | |
1125 | const struct MsgBuf msgbuf = { | |
1126 | .n_tags = 2, | |
1127 | .tags = { | |
1128 | { .key = "a", .value = "", .capmask = 1 }, | |
1129 | { .key = MKTEXT(506), .value = "", .capmask = 1 }, | |
1130 | }, | |
1131 | ||
1132 | .cmd = "PRIVMSG", | |
1133 | .origin = "origin", | |
1134 | .target = "#test", | |
1135 | ||
1136 | .n_para = 3, | |
1137 | .para = { "test", "test", "test test" }, | |
1138 | }; | |
1139 | char output[OUTPUT_BUFSIZE]; | |
1140 | ||
1141 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1142 | char tmp[2048]; | |
1143 | ||
1144 | strcpy(tmp, "@a=;"); | |
1145 | strcat(tmp, MKTEXT(506)); | |
1146 | strcat(tmp, "= "); | |
1147 | is_int(512, strlen(tmp), MSG); | |
1148 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1149 | ||
1150 | is_string(tmp, output, MSG); | |
1151 | } | |
1152 | } | |
1153 | ||
1154 | static void long_tag2c_empty_value(void) | |
1155 | { | |
1156 | const struct MsgBuf msgbuf = { | |
1157 | .n_tags = 2, | |
1158 | .tags = { | |
1159 | { .key = "a", .value = "b", .capmask = 1 }, | |
1160 | { .key = MKTEXT(505), .value = "", .capmask = 1 }, | |
1161 | }, | |
1162 | ||
1163 | .cmd = "PRIVMSG", | |
1164 | .origin = "origin", | |
1165 | .target = "#test", | |
1166 | ||
1167 | .n_para = 3, | |
1168 | .para = { "test", "test", "test test" }, | |
1169 | }; | |
1170 | char output[OUTPUT_BUFSIZE]; | |
1171 | ||
1172 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1173 | char tmp[2048]; | |
1174 | ||
1175 | strcpy(tmp, "@a=b;"); | |
1176 | strcat(tmp, MKTEXT(505)); | |
1177 | strcat(tmp, "= "); | |
1178 | is_int(512, strlen(tmp), MSG); | |
1179 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1180 | ||
1181 | is_string(tmp, output, MSG); | |
1182 | } | |
1183 | } | |
1184 | ||
1185 | static void long_tag2a_short_value(void) | |
1186 | { | |
1187 | const struct MsgBuf msgbuf = { | |
1188 | .n_tags = 2, | |
1189 | .tags = { | |
1190 | { .key = "a", .value = NULL, .capmask = 1 }, | |
1191 | { .key = MKTEXT(506), .value = "x", .capmask = 1 }, | |
1192 | }, | |
1193 | ||
1194 | .cmd = "PRIVMSG", | |
1195 | .origin = "origin", | |
1196 | .target = "#test", | |
1197 | ||
1198 | .n_para = 3, | |
1199 | .para = { "test", "test", "test test" }, | |
1200 | }; | |
1201 | char output[OUTPUT_BUFSIZE]; | |
1202 | ||
1203 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1204 | char tmp[2048]; | |
1205 | ||
1206 | strcpy(tmp, "@a;"); | |
1207 | strcat(tmp, MKTEXT(506)); | |
1208 | strcat(tmp, "=x "); | |
1209 | is_int(512, strlen(tmp), MSG); | |
1210 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1211 | ||
1212 | is_string(tmp, output, MSG); | |
1213 | } | |
1214 | } | |
1215 | ||
1216 | static void long_tag2b_short_value(void) | |
1217 | { | |
1218 | const struct MsgBuf msgbuf = { | |
1219 | .n_tags = 2, | |
1220 | .tags = { | |
1221 | { .key = "a", .value = "", .capmask = 1 }, | |
1222 | { .key = MKTEXT(505), .value = "x", .capmask = 1 }, | |
1223 | }, | |
1224 | ||
1225 | .cmd = "PRIVMSG", | |
1226 | .origin = "origin", | |
1227 | .target = "#test", | |
1228 | ||
1229 | .n_para = 3, | |
1230 | .para = { "test", "test", "test test" }, | |
1231 | }; | |
1232 | char output[OUTPUT_BUFSIZE]; | |
1233 | ||
1234 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1235 | char tmp[2048]; | |
1236 | ||
1237 | strcpy(tmp, "@a=;"); | |
1238 | strcat(tmp, MKTEXT(505)); | |
1239 | strcat(tmp, "=x "); | |
1240 | is_int(512, strlen(tmp), MSG); | |
1241 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1242 | ||
1243 | is_string(tmp, output, MSG); | |
1244 | } | |
1245 | } | |
1246 | ||
1247 | static void long_tag2c_short_value(void) | |
1248 | { | |
1249 | const struct MsgBuf msgbuf = { | |
1250 | .n_tags = 2, | |
1251 | .tags = { | |
1252 | { .key = "a", .value = "b", .capmask = 1 }, | |
1253 | { .key = MKTEXT(504), .value = "x", .capmask = 1 }, | |
1254 | }, | |
1255 | ||
1256 | .cmd = "PRIVMSG", | |
1257 | .origin = "origin", | |
1258 | .target = "#test", | |
1259 | ||
1260 | .n_para = 3, | |
1261 | .para = { "test", "test", "test test" }, | |
1262 | }; | |
1263 | char output[OUTPUT_BUFSIZE]; | |
1264 | ||
1265 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1266 | char tmp[2048]; | |
1267 | ||
1268 | strcpy(tmp, "@a=b;"); | |
1269 | strcat(tmp, MKTEXT(504)); | |
1270 | strcat(tmp, "=x "); | |
1271 | is_int(512, strlen(tmp), MSG); | |
1272 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1273 | ||
1274 | is_string(tmp, output, MSG); | |
1275 | } | |
1276 | } | |
1277 | ||
1278 | static void short_tag2a_long_value(void) | |
1279 | { | |
1280 | const struct MsgBuf msgbuf = { | |
1281 | .n_tags = 2, | |
1282 | .tags = { | |
1283 | { .key = "a", .value = NULL, .capmask = 1 }, | |
1284 | { .key = "x", .value = MKTEXT(506), .capmask = 1 }, | |
1285 | }, | |
1286 | ||
1287 | .cmd = "PRIVMSG", | |
1288 | .origin = "origin", | |
1289 | .target = "#test", | |
1290 | ||
1291 | .n_para = 3, | |
1292 | .para = { "test", "test", "test test" }, | |
1293 | }; | |
1294 | char output[OUTPUT_BUFSIZE]; | |
1295 | ||
1296 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1297 | char tmp[2048]; | |
1298 | ||
1299 | strcpy(tmp, "@a;x="); | |
1300 | strcat(tmp, MKTEXT(506)); | |
1301 | strcat(tmp, " "); | |
1302 | is_int(512, strlen(tmp), MSG); | |
1303 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1304 | ||
1305 | is_string(tmp, output, MSG); | |
1306 | } | |
1307 | } | |
1308 | ||
1309 | static void short_tag2b_long_value(void) | |
1310 | { | |
1311 | const struct MsgBuf msgbuf = { | |
1312 | .n_tags = 2, | |
1313 | .tags = { | |
1314 | { .key = "a", .value = "", .capmask = 1 }, | |
1315 | { .key = "x", .value = MKTEXT(505), .capmask = 1 }, | |
1316 | }, | |
1317 | ||
1318 | .cmd = "PRIVMSG", | |
1319 | .origin = "origin", | |
1320 | .target = "#test", | |
1321 | ||
1322 | .n_para = 3, | |
1323 | .para = { "test", "test", "test test" }, | |
1324 | }; | |
1325 | char output[OUTPUT_BUFSIZE]; | |
1326 | ||
1327 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1328 | char tmp[2048]; | |
1329 | ||
1330 | strcpy(tmp, "@a=;x="); | |
1331 | strcat(tmp, MKTEXT(505)); | |
1332 | strcat(tmp, " "); | |
1333 | is_int(512, strlen(tmp), MSG); | |
1334 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1335 | ||
1336 | is_string(tmp, output, MSG); | |
1337 | } | |
1338 | } | |
1339 | ||
1340 | static void short_tag2c_long_value(void) | |
1341 | { | |
1342 | const struct MsgBuf msgbuf = { | |
1343 | .n_tags = 2, | |
1344 | .tags = { | |
1345 | { .key = "a", .value = "b", .capmask = 1 }, | |
1346 | { .key = "x", .value = MKTEXT(504), .capmask = 1 }, | |
1347 | }, | |
1348 | ||
1349 | .cmd = "PRIVMSG", | |
1350 | .origin = "origin", | |
1351 | .target = "#test", | |
1352 | ||
1353 | .n_para = 3, | |
1354 | .para = { "test", "test", "test test" }, | |
1355 | }; | |
1356 | char output[OUTPUT_BUFSIZE]; | |
1357 | ||
1358 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1359 | char tmp[2048]; | |
1360 | ||
1361 | strcpy(tmp, "@a=b;x="); | |
1362 | strcat(tmp, MKTEXT(504)); | |
1363 | strcat(tmp, " "); | |
1364 | is_int(512, strlen(tmp), MSG); | |
1365 | strcat(tmp, ":origin PRIVMSG #test test test :test test"); | |
1366 | ||
1367 | is_string(tmp, output, MSG); | |
1368 | } | |
1369 | } | |
1370 | ||
1371 | static void too_long_tag2a_no_value(void) | |
1372 | { | |
1373 | const struct MsgBuf msgbuf = { | |
1374 | .n_tags = 2, | |
1375 | .tags = { | |
1376 | { .key = "a", .value = NULL, .capmask = 1 }, | |
1377 | { .key = MKTEXT(509), .value = NULL, .capmask = 1 }, | |
1378 | }, | |
1379 | ||
1380 | .cmd = "PRIVMSG", | |
1381 | .origin = "origin", | |
1382 | .target = "#test", | |
1383 | ||
1384 | .n_para = 3, | |
1385 | .para = { "test", "test", "test test" }, | |
1386 | }; | |
1387 | char output[OUTPUT_BUFSIZE]; | |
1388 | ||
1389 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1390 | is_string("@a :origin PRIVMSG #test test test :test test", output, MSG); | |
1391 | } | |
1392 | } | |
1393 | ||
1394 | static void too_long_tag2b_no_value(void) | |
1395 | { | |
1396 | const struct MsgBuf msgbuf = { | |
1397 | .n_tags = 2, | |
1398 | .tags = { | |
1399 | { .key = "a", .value = "", .capmask = 1 }, | |
1400 | { .key = MKTEXT(508), .value = NULL, .capmask = 1 }, | |
1401 | }, | |
1402 | ||
1403 | .cmd = "PRIVMSG", | |
1404 | .origin = "origin", | |
1405 | .target = "#test", | |
1406 | ||
1407 | .n_para = 3, | |
1408 | .para = { "test", "test", "test test" }, | |
1409 | }; | |
1410 | char output[OUTPUT_BUFSIZE]; | |
1411 | ||
1412 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1413 | is_string("@a= :origin PRIVMSG #test test test :test test", output, MSG); | |
1414 | } | |
1415 | } | |
1416 | ||
1417 | static void too_long_tag2c_no_value(void) | |
1418 | { | |
1419 | const struct MsgBuf msgbuf = { | |
1420 | .n_tags = 2, | |
1421 | .tags = { | |
1422 | { .key = "a", .value = "b", .capmask = 1 }, | |
1423 | { .key = MKTEXT(507), .value = NULL, .capmask = 1 }, | |
1424 | }, | |
1425 | ||
1426 | .cmd = "PRIVMSG", | |
1427 | .origin = "origin", | |
1428 | .target = "#test", | |
1429 | ||
1430 | .n_para = 3, | |
1431 | .para = { "test", "test", "test test" }, | |
1432 | }; | |
1433 | char output[OUTPUT_BUFSIZE]; | |
1434 | ||
1435 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1436 | is_string("@a=b :origin PRIVMSG #test test test :test test", output, MSG); | |
1437 | } | |
1438 | } | |
1439 | ||
1440 | static void too_long_tag2a_empty_value(void) | |
1441 | { | |
1442 | const struct MsgBuf msgbuf = { | |
1443 | .n_tags = 2, | |
1444 | .tags = { | |
1445 | { .key = "a", .value = NULL, .capmask = 1 }, | |
1446 | { .key = MKTEXT(508), .value = "", .capmask = 1 }, | |
1447 | }, | |
1448 | ||
1449 | .cmd = "PRIVMSG", | |
1450 | .origin = "origin", | |
1451 | .target = "#test", | |
1452 | ||
1453 | .n_para = 3, | |
1454 | .para = { "test", "test", "test test" }, | |
1455 | }; | |
1456 | char output[OUTPUT_BUFSIZE]; | |
1457 | ||
1458 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1459 | is_string("@a :origin PRIVMSG #test test test :test test", output, MSG); | |
1460 | } | |
1461 | } | |
1462 | ||
1463 | static void too_long_tag2b_empty_value(void) | |
1464 | { | |
1465 | const struct MsgBuf msgbuf = { | |
1466 | .n_tags = 2, | |
1467 | .tags = { | |
1468 | { .key = "a", .value = "", .capmask = 1 }, | |
1469 | { .key = MKTEXT(507), .value = "", .capmask = 1 }, | |
1470 | }, | |
1471 | ||
1472 | .cmd = "PRIVMSG", | |
1473 | .origin = "origin", | |
1474 | .target = "#test", | |
1475 | ||
1476 | .n_para = 3, | |
1477 | .para = { "test", "test", "test test" }, | |
1478 | }; | |
1479 | char output[OUTPUT_BUFSIZE]; | |
1480 | ||
1481 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1482 | is_string("@a= :origin PRIVMSG #test test test :test test", output, MSG); | |
1483 | } | |
1484 | } | |
1485 | ||
1486 | static void too_long_tag2c_empty_value(void) | |
1487 | { | |
1488 | const struct MsgBuf msgbuf = { | |
1489 | .n_tags = 2, | |
1490 | .tags = { | |
1491 | { .key = "a", .value = "b", .capmask = 1 }, | |
1492 | { .key = MKTEXT(506), .value = "", .capmask = 1 }, | |
1493 | }, | |
1494 | ||
1495 | .cmd = "PRIVMSG", | |
1496 | .origin = "origin", | |
1497 | .target = "#test", | |
1498 | ||
1499 | .n_para = 3, | |
1500 | .para = { "test", "test", "test test" }, | |
1501 | }; | |
1502 | char output[OUTPUT_BUFSIZE]; | |
1503 | ||
1504 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1505 | is_string("@a=b :origin PRIVMSG #test test test :test test", output, MSG); | |
1506 | } | |
1507 | } | |
1508 | ||
1509 | static void too_long_tag2a_short_value(void) | |
1510 | { | |
1511 | const struct MsgBuf msgbuf = { | |
1512 | .n_tags = 2, | |
1513 | .tags = { | |
1514 | { .key = "a", .value = NULL, .capmask = 1 }, | |
1515 | { .key = MKTEXT(507), .value = "x", .capmask = 1 }, | |
1516 | }, | |
1517 | ||
1518 | .cmd = "PRIVMSG", | |
1519 | .origin = "origin", | |
1520 | .target = "#test", | |
1521 | ||
1522 | .n_para = 3, | |
1523 | .para = { "test", "test", "test test" }, | |
1524 | }; | |
1525 | char output[OUTPUT_BUFSIZE]; | |
1526 | ||
1527 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1528 | is_string("@a :origin PRIVMSG #test test test :test test", output, MSG); | |
1529 | } | |
1530 | } | |
1531 | ||
1532 | static void too_long_tag2b_short_value(void) | |
1533 | { | |
1534 | const struct MsgBuf msgbuf = { | |
1535 | .n_tags = 2, | |
1536 | .tags = { | |
1537 | { .key = "a", .value = "", .capmask = 1 }, | |
1538 | { .key = MKTEXT(506), .value = "x", .capmask = 1 }, | |
1539 | }, | |
1540 | ||
1541 | .cmd = "PRIVMSG", | |
1542 | .origin = "origin", | |
1543 | .target = "#test", | |
1544 | ||
1545 | .n_para = 3, | |
1546 | .para = { "test", "test", "test test" }, | |
1547 | }; | |
1548 | char output[OUTPUT_BUFSIZE]; | |
1549 | ||
1550 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1551 | is_string("@a= :origin PRIVMSG #test test test :test test", output, MSG); | |
1552 | } | |
1553 | } | |
1554 | ||
1555 | static void too_long_tag2c_short_value(void) | |
1556 | { | |
1557 | const struct MsgBuf msgbuf = { | |
1558 | .n_tags = 2, | |
1559 | .tags = { | |
1560 | { .key = "a", .value = "b", .capmask = 1 }, | |
1561 | { .key = MKTEXT(505), .value = "x", .capmask = 1 }, | |
1562 | }, | |
1563 | ||
1564 | .cmd = "PRIVMSG", | |
1565 | .origin = "origin", | |
1566 | .target = "#test", | |
1567 | ||
1568 | .n_para = 3, | |
1569 | .para = { "test", "test", "test test" }, | |
1570 | }; | |
1571 | char output[OUTPUT_BUFSIZE]; | |
1572 | ||
1573 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1574 | is_string("@a=b :origin PRIVMSG #test test test :test test", output, MSG); | |
1575 | } | |
1576 | } | |
1577 | ||
1578 | static void short_tag2a_too_long_value(void) | |
1579 | { | |
1580 | const struct MsgBuf msgbuf = { | |
1581 | .n_tags = 2, | |
1582 | .tags = { | |
1583 | { .key = "a", .value = NULL, .capmask = 1 }, | |
1584 | { .key = "x", .value = MKTEXT(507), .capmask = 1 }, | |
1585 | }, | |
1586 | ||
1587 | .cmd = "PRIVMSG", | |
1588 | .origin = "origin", | |
1589 | .target = "#test", | |
1590 | ||
1591 | .n_para = 3, | |
1592 | .para = { "test", "test", "test test" }, | |
1593 | }; | |
1594 | char output[OUTPUT_BUFSIZE]; | |
1595 | ||
1596 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1597 | is_string("@a :origin PRIVMSG #test test test :test test", output, MSG); | |
1598 | } | |
1599 | } | |
1600 | ||
1601 | static void short_tag2b_too_long_value(void) | |
1602 | { | |
1603 | const struct MsgBuf msgbuf = { | |
1604 | .n_tags = 2, | |
1605 | .tags = { | |
1606 | { .key = "a", .value = "", .capmask = 1 }, | |
1607 | { .key = "x", .value = MKTEXT(506), .capmask = 1 }, | |
1608 | }, | |
1609 | ||
1610 | .cmd = "PRIVMSG", | |
1611 | .origin = "origin", | |
1612 | .target = "#test", | |
1613 | ||
1614 | .n_para = 3, | |
1615 | .para = { "test", "test", "test test" }, | |
1616 | }; | |
1617 | char output[OUTPUT_BUFSIZE]; | |
1618 | ||
1619 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1620 | is_string("@a= :origin PRIVMSG #test test test :test test", output, MSG); | |
1621 | } | |
1622 | } | |
1623 | ||
1624 | static void short_tag2c_too_long_value(void) | |
1625 | { | |
1626 | const struct MsgBuf msgbuf = { | |
1627 | .n_tags = 2, | |
1628 | .tags = { | |
1629 | { .key = "a", .value = "b", .capmask = 1 }, | |
1630 | { .key = "x", .value = MKTEXT(505), .capmask = 1 }, | |
1631 | }, | |
1632 | ||
1633 | .cmd = "PRIVMSG", | |
1634 | .origin = "origin", | |
1635 | .target = "#test", | |
1636 | ||
1637 | .n_para = 3, | |
1638 | .para = { "test", "test", "test test" }, | |
1639 | }; | |
1640 | char output[OUTPUT_BUFSIZE]; | |
1641 | ||
1642 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1643 | is_string("@a=b :origin PRIVMSG #test test test :test test", output, MSG); | |
1644 | } | |
1645 | } | |
1646 | ||
1647 | static void escape_test(void) | |
1648 | { | |
1649 | const struct MsgBuf msgbuf = { | |
1650 | .n_tags = 6, | |
1651 | .tags = { | |
1652 | { .key = "tag1", .value = ":; \\\r\n", .capmask = 1 }, | |
1653 | { .key = "tag2", .value = "^:^;^ ^\\^\r^\n^", .capmask = 1 }, | |
1654 | { .key = "tag3", .value = ":", .capmask = 1 }, | |
1655 | { .key = "tag4", .value = ";", .capmask = 1 }, | |
1656 | { .key = "tag5", .value = "\\", .capmask = 1 }, | |
1657 | { .key = "tag6", .value = " ", .capmask = 1 }, | |
1658 | }, | |
1659 | ||
1660 | .cmd = "PRIVMSG", | |
1661 | .origin = "origin", | |
1662 | .target = "#test", | |
1663 | ||
1664 | .n_para = 3, | |
1665 | .para = { "test", "test", "test test" }, | |
1666 | }; | |
1667 | char output[OUTPUT_BUFSIZE]; | |
1668 | ||
1669 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1670 | is_string("@tag1=:\\:\\s\\\\\\r\\n;tag2=^:^\\:^\\s^\\\\^\\r^\\n^;tag3=:;tag4=\\:;tag5=\\\\;tag6=\\s :origin PRIVMSG #test test test :test test", output, MSG); | |
1671 | } | |
1672 | } | |
1673 | ||
1674 | static void escape_test_8bit(void) | |
1675 | { | |
1676 | const struct MsgBuf msgbuf = { | |
1677 | .n_tags = 1, | |
1678 | .tags = { | |
1679 | { .key = "tag1", .value = "\176\177\178\376\377", .capmask = 1 }, | |
1680 | }, | |
1681 | ||
1682 | .cmd = "PRIVMSG", | |
1683 | .origin = "origin", | |
1684 | .target = "#test", | |
1685 | ||
1686 | .n_para = 3, | |
1687 | .para = { "test", "test", "test test" }, | |
1688 | }; | |
1689 | char output[OUTPUT_BUFSIZE]; | |
1690 | ||
1691 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1692 | is_string("@tag1=\176\177\178\376\377 :origin PRIVMSG #test test test :test test", output, MSG); | |
1693 | } | |
1694 | } | |
1695 | ||
1696 | static void long_para1a(void) | |
1697 | { | |
1698 | const struct MsgBuf msgbuf = { | |
1699 | .n_tags = 0, | |
1700 | ||
1701 | .cmd = "PRIVMSG", | |
1702 | .origin = "origin", | |
1703 | .target = "#test", | |
1704 | ||
1705 | .n_para = 1, | |
1706 | .para = { MKTEXT(488) }, | |
1707 | }; | |
1708 | char output[OUTPUT_BUFSIZE]; | |
1709 | ||
1710 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1711 | char tmp[2048]; | |
1712 | ||
1713 | strcpy(tmp, ":origin PRIVMSG #test "); | |
1714 | strcat(tmp, MKTEXT(488)); | |
1715 | is_int(510, strlen(tmp), MSG); | |
1716 | ||
1717 | is_string(tmp, output, MSG); | |
1718 | } | |
1719 | } | |
1720 | ||
1721 | static void too_long_para1a(void) | |
1722 | { | |
1723 | const struct MsgBuf msgbuf = { | |
1724 | .n_tags = 0, | |
1725 | ||
1726 | .cmd = "PRIVMSG", | |
1727 | .origin = "origin", | |
1728 | .target = "#test", | |
1729 | ||
1730 | .n_para = 1, | |
1731 | .para = { MKTEXT(489) }, | |
1732 | }; | |
1733 | char output[OUTPUT_BUFSIZE]; | |
1734 | ||
1735 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1736 | char tmp[2048]; | |
1737 | ||
1738 | strcpy(tmp, ":origin PRIVMSG #test "); | |
1739 | strcat(tmp, MKTEXT(489)); | |
1740 | tmp[strlen(tmp) - 1] = 0; | |
1741 | is_int(510, strlen(tmp), MSG); | |
1742 | ||
1743 | is_string(tmp, output, MSG); | |
1744 | } | |
1745 | } | |
1746 | ||
1747 | static void long_para1b(void) | |
1748 | { | |
1749 | char input[2048]; | |
1750 | const struct MsgBuf msgbuf = { | |
1751 | .n_tags = 0, | |
1752 | ||
1753 | .cmd = "PRIVMSG", | |
1754 | .origin = "origin", | |
1755 | .target = "#test", | |
1756 | ||
1757 | .n_para = 1, | |
1758 | .para = { input }, | |
1759 | }; | |
1760 | char output[OUTPUT_BUFSIZE]; | |
1761 | ||
1762 | /* make second-last char ' ' so that a ':' prefix is required */ | |
1763 | strcpy(input, MKTEXT(487)); | |
1764 | input[strlen(input) - 2] = ' '; | |
1765 | ||
1766 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1767 | char tmp[2048]; | |
1768 | ||
1769 | strcpy(tmp, ":origin PRIVMSG #test :"); | |
1770 | strcat(tmp, MKTEXT(487)); | |
1771 | tmp[strlen(tmp) - 2] = ' '; | |
1772 | is_int(510, strlen(tmp), MSG); | |
1773 | ||
1774 | is_string(tmp, output, MSG); | |
1775 | } | |
1776 | } | |
1777 | ||
1778 | static void too_long_para1b(void) | |
1779 | { | |
1780 | char input[2048]; | |
1781 | const struct MsgBuf msgbuf = { | |
1782 | .n_tags = 0, | |
1783 | ||
1784 | .cmd = "PRIVMSG", | |
1785 | .origin = "origin", | |
1786 | .target = "#test", | |
1787 | ||
1788 | .n_para = 1, | |
1789 | .para = { input }, | |
1790 | }; | |
1791 | char output[OUTPUT_BUFSIZE]; | |
1792 | ||
1793 | /* make second-last char ' ' so that a ':' prefix is required */ | |
1794 | strcpy(input, MKTEXT(488)); | |
1795 | input[strlen(input) - 3] = ' '; | |
1796 | ||
1797 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1798 | char tmp[2048]; | |
1799 | ||
1800 | strcpy(tmp, ":origin PRIVMSG #test :"); | |
1801 | strcat(tmp, MKTEXT(488)); | |
1802 | tmp[strlen(tmp) - 3] = ' '; | |
1803 | tmp[strlen(tmp) - 1] = 0; | |
1804 | is_int(510, strlen(tmp), MSG); | |
1805 | ||
1806 | is_string(tmp, output, MSG); | |
1807 | } | |
1808 | } | |
1809 | ||
1810 | static void long_para2a(void) | |
1811 | { | |
1812 | const struct MsgBuf msgbuf = { | |
1813 | .n_tags = 0, | |
1814 | ||
1815 | .cmd = "PRIVMSG", | |
1816 | .origin = "origin", | |
1817 | .target = "#test", | |
1818 | ||
1819 | .n_para = 2, | |
1820 | .para = { "test", MKTEXT(483) }, | |
1821 | }; | |
1822 | char output[OUTPUT_BUFSIZE]; | |
1823 | ||
1824 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1825 | char tmp[2048]; | |
1826 | ||
1827 | strcpy(tmp, ":origin PRIVMSG #test test "); | |
1828 | strcat(tmp, MKTEXT(483)); | |
1829 | is_int(510, strlen(tmp), MSG); | |
1830 | ||
1831 | is_string(tmp, output, MSG); | |
1832 | } | |
1833 | } | |
1834 | ||
1835 | static void too_long_para2a(void) | |
1836 | { | |
1837 | const struct MsgBuf msgbuf = { | |
1838 | .n_tags = 0, | |
1839 | ||
1840 | .cmd = "PRIVMSG", | |
1841 | .origin = "origin", | |
1842 | .target = "#test", | |
1843 | ||
1844 | .n_para = 2, | |
1845 | .para = { "test", MKTEXT(484) }, | |
1846 | }; | |
1847 | char output[OUTPUT_BUFSIZE]; | |
1848 | ||
1849 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1850 | char tmp[2048]; | |
1851 | ||
1852 | strcpy(tmp, ":origin PRIVMSG #test test "); | |
1853 | strcat(tmp, MKTEXT(484)); | |
1854 | tmp[strlen(tmp) - 1] = 0; | |
1855 | is_int(510, strlen(tmp), MSG); | |
1856 | ||
1857 | is_string(tmp, output, MSG); | |
1858 | } | |
1859 | } | |
1860 | ||
1861 | static void long_para2b(void) | |
1862 | { | |
1863 | char input[2048]; | |
1864 | const struct MsgBuf msgbuf = { | |
1865 | .n_tags = 0, | |
1866 | ||
1867 | .cmd = "PRIVMSG", | |
1868 | .origin = "origin", | |
1869 | .target = "#test", | |
1870 | ||
1871 | .n_para = 2, | |
1872 | .para = { "test", input }, | |
1873 | }; | |
1874 | char output[OUTPUT_BUFSIZE]; | |
1875 | ||
1876 | /* make second-last char ' ' so that a ':' prefix is required */ | |
1877 | strcpy(input, MKTEXT(482)); | |
1878 | input[strlen(input) - 2] = ' '; | |
1879 | ||
1880 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1881 | char tmp[2048]; | |
1882 | ||
1883 | strcpy(tmp, ":origin PRIVMSG #test test :"); | |
1884 | strcat(tmp, MKTEXT(482)); | |
1885 | tmp[strlen(tmp) - 2] = ' '; | |
1886 | is_int(510, strlen(tmp), MSG); | |
1887 | ||
1888 | is_string(tmp, output, MSG); | |
1889 | } | |
1890 | } | |
1891 | ||
1892 | static void too_long_para2b(void) | |
1893 | { | |
1894 | char input[2048]; | |
1895 | const struct MsgBuf msgbuf = { | |
1896 | .n_tags = 0, | |
1897 | ||
1898 | .cmd = "PRIVMSG", | |
1899 | .origin = "origin", | |
1900 | .target = "#test", | |
1901 | ||
1902 | .n_para = 2, | |
1903 | .para = { "test", input }, | |
1904 | }; | |
1905 | char output[OUTPUT_BUFSIZE]; | |
1906 | ||
1907 | /* make second-last char ' ' so that a ':' prefix is required */ | |
1908 | strcpy(input, MKTEXT(483)); | |
1909 | input[strlen(input) - 3] = ' '; | |
1910 | ||
1911 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1912 | char tmp[2048]; | |
1913 | ||
1914 | strcpy(tmp, ":origin PRIVMSG #test test :"); | |
1915 | strcat(tmp, MKTEXT(483)); | |
1916 | tmp[strlen(tmp) - 3] = ' '; | |
1917 | tmp[strlen(tmp) - 1] = 0; | |
1918 | is_int(510, strlen(tmp), MSG); | |
1919 | ||
1920 | is_string(tmp, output, MSG); | |
1921 | } | |
1922 | } | |
1923 | ||
1924 | static void long_para3a(void) | |
1925 | { | |
1926 | const struct MsgBuf msgbuf = { | |
1927 | .n_tags = 0, | |
1928 | ||
1929 | .cmd = "PRIVMSG", | |
1930 | .origin = "origin", | |
1931 | .target = "#test", | |
1932 | ||
1933 | .n_para = 3, | |
1934 | .para = { "test1", "test2", MKTEXT(476) }, | |
1935 | }; | |
1936 | char output[OUTPUT_BUFSIZE]; | |
1937 | ||
1938 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1939 | char tmp[2048]; | |
1940 | ||
1941 | strcpy(tmp, ":origin PRIVMSG #test test1 test2 "); | |
1942 | strcat(tmp, MKTEXT(476)); | |
1943 | is_int(510, strlen(tmp), MSG); | |
1944 | ||
1945 | is_string(tmp, output, MSG); | |
1946 | } | |
1947 | } | |
1948 | ||
1949 | static void too_long_para3a(void) | |
1950 | { | |
1951 | const struct MsgBuf msgbuf = { | |
1952 | .n_tags = 0, | |
1953 | ||
1954 | .cmd = "PRIVMSG", | |
1955 | .origin = "origin", | |
1956 | .target = "#test", | |
1957 | ||
1958 | .n_para = 3, | |
1959 | .para = { "test1", "test2", MKTEXT(477) }, | |
1960 | }; | |
1961 | char output[OUTPUT_BUFSIZE]; | |
1962 | ||
1963 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1964 | char tmp[2048]; | |
1965 | ||
1966 | strcpy(tmp, ":origin PRIVMSG #test test1 test2 "); | |
1967 | strcat(tmp, MKTEXT(477)); | |
1968 | tmp[strlen(tmp) - 1] = 0; | |
1969 | is_int(510, strlen(tmp), MSG); | |
1970 | ||
1971 | is_string(tmp, output, MSG); | |
1972 | } | |
1973 | } | |
1974 | ||
1975 | static void long_para3b(void) | |
1976 | { | |
1977 | char input[2048]; | |
1978 | const struct MsgBuf msgbuf = { | |
1979 | .n_tags = 0, | |
1980 | ||
1981 | .cmd = "PRIVMSG", | |
1982 | .origin = "origin", | |
1983 | .target = "#test", | |
1984 | ||
1985 | .n_para = 3, | |
1986 | .para = { "test1", "test2", input }, | |
1987 | }; | |
1988 | char output[OUTPUT_BUFSIZE]; | |
1989 | ||
1990 | /* make second-last char ' ' so that a ':' prefix is required */ | |
1991 | strcpy(input, MKTEXT(475)); | |
1992 | input[strlen(input) - 2] = ' '; | |
1993 | ||
1994 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
1995 | char tmp[2048]; | |
1996 | ||
1997 | strcpy(tmp, ":origin PRIVMSG #test test1 test2 :"); | |
1998 | strcat(tmp, MKTEXT(475)); | |
1999 | tmp[strlen(tmp) - 2] = ' '; | |
2000 | is_int(510, strlen(tmp), MSG); | |
2001 | ||
2002 | is_string(tmp, output, MSG); | |
2003 | } | |
2004 | } | |
2005 | ||
2006 | static void too_long_para3b(void) | |
2007 | { | |
2008 | char input[2048]; | |
2009 | const struct MsgBuf msgbuf = { | |
2010 | .n_tags = 0, | |
2011 | ||
2012 | .cmd = "PRIVMSG", | |
2013 | .origin = "origin", | |
2014 | .target = "#test", | |
2015 | ||
2016 | .n_para = 3, | |
2017 | .para = { "test1", "test2", input }, | |
2018 | }; | |
2019 | char output[OUTPUT_BUFSIZE]; | |
2020 | ||
2021 | /* make second-last char ' ' so that a ':' prefix is required */ | |
2022 | strcpy(input, MKTEXT(476)); | |
2023 | input[strlen(input) - 3] = ' '; | |
2024 | ||
2025 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2026 | char tmp[2048]; | |
2027 | ||
2028 | strcpy(tmp, ":origin PRIVMSG #test test1 test2 :"); | |
2029 | strcat(tmp, MKTEXT(476)); | |
2030 | tmp[strlen(tmp) - 3] = ' '; | |
2031 | tmp[strlen(tmp) - 1] = 0; | |
2032 | is_int(510, strlen(tmp), MSG); | |
2033 | ||
2034 | is_string(tmp, output, MSG); | |
2035 | } | |
2036 | } | |
2037 | ||
2038 | static void long_para15a(void) | |
2039 | { | |
2040 | const struct MsgBuf msgbuf = { | |
2041 | .n_tags = 0, | |
2042 | ||
2043 | .cmd = "PRIVMSG", | |
2044 | .origin = "origin", | |
2045 | .target = "#test", | |
2046 | ||
2047 | .n_para = 15, | |
2048 | .para = { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", MKTEXT(399) }, | |
2049 | }; | |
2050 | char output[OUTPUT_BUFSIZE]; | |
2051 | ||
2052 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2053 | char tmp[2048]; | |
2054 | ||
2055 | strcpy(tmp, ":origin PRIVMSG #test test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 "); | |
2056 | strcat(tmp, MKTEXT(399)); | |
2057 | is_int(510, strlen(tmp), MSG); | |
2058 | ||
2059 | is_string(tmp, output, MSG); | |
2060 | } | |
2061 | } | |
2062 | ||
2063 | static void too_long_para15a(void) | |
2064 | { | |
2065 | const struct MsgBuf msgbuf = { | |
2066 | .n_tags = 0, | |
2067 | ||
2068 | .cmd = "PRIVMSG", | |
2069 | .origin = "origin", | |
2070 | .target = "#test", | |
2071 | ||
2072 | .n_para = 15, | |
2073 | .para = { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", MKTEXT(400) }, | |
2074 | }; | |
2075 | char output[OUTPUT_BUFSIZE]; | |
2076 | ||
2077 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2078 | char tmp[2048]; | |
2079 | ||
2080 | strcpy(tmp, ":origin PRIVMSG #test test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 "); | |
2081 | strcat(tmp, MKTEXT(400)); | |
2082 | tmp[strlen(tmp) - 1] = 0; | |
2083 | is_int(510, strlen(tmp), MSG); | |
2084 | ||
2085 | is_string(tmp, output, MSG); | |
2086 | } | |
2087 | } | |
2088 | ||
2089 | static void long_para15b(void) | |
2090 | { | |
2091 | char input[2048]; | |
2092 | const struct MsgBuf msgbuf = { | |
2093 | .n_tags = 0, | |
2094 | ||
2095 | .cmd = "PRIVMSG", | |
2096 | .origin = "origin", | |
2097 | .target = "#test", | |
2098 | ||
2099 | .n_para = 15, | |
2100 | .para = { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", input }, | |
2101 | }; | |
2102 | char output[OUTPUT_BUFSIZE]; | |
2103 | ||
2104 | /* make second-last char ' ' so that a ':' prefix is required */ | |
2105 | strcpy(input, MKTEXT(398)); | |
2106 | input[strlen(input) - 2] = ' '; | |
2107 | ||
2108 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2109 | char tmp[2048]; | |
2110 | ||
2111 | strcpy(tmp, ":origin PRIVMSG #test test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 :"); | |
2112 | strcat(tmp, MKTEXT(398)); | |
2113 | tmp[strlen(tmp) - 2] = ' '; | |
2114 | is_int(510, strlen(tmp), MSG); | |
2115 | ||
2116 | is_string(tmp, output, MSG); | |
2117 | } | |
2118 | } | |
2119 | ||
2120 | static void too_long_para15b(void) | |
2121 | { | |
2122 | char input[2048]; | |
2123 | const struct MsgBuf msgbuf = { | |
2124 | .n_tags = 0, | |
2125 | ||
2126 | .cmd = "PRIVMSG", | |
2127 | .origin = "origin", | |
2128 | .target = "#test", | |
2129 | ||
2130 | .n_para = 15, | |
2131 | .para = { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", input }, | |
2132 | }; | |
2133 | char output[OUTPUT_BUFSIZE]; | |
2134 | ||
2135 | /* make second-last char ' ' so that a ':' prefix is required */ | |
2136 | strcpy(input, MKTEXT(399)); | |
2137 | input[strlen(input) - 3] = ' '; | |
2138 | ||
2139 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2140 | char tmp[2048]; | |
2141 | ||
2142 | strcpy(tmp, ":origin PRIVMSG #test test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 :"); | |
2143 | strcat(tmp, MKTEXT(399)); | |
2144 | tmp[strlen(tmp) - 3] = ' '; | |
2145 | tmp[strlen(tmp) - 1] = 0; | |
2146 | is_int(510, strlen(tmp), MSG); | |
2147 | ||
2148 | is_string(tmp, output, MSG); | |
2149 | } | |
2150 | } | |
2151 | ||
2152 | static const struct MsgBuf small_buffer_tags_msgbuf = { | |
2153 | .n_tags = 15, | |
2154 | .tags = { | |
2155 | { .key = "tag1", .value = "value1", .capmask = 1 }, | |
2156 | { .key = "tag2", .value = "value2", .capmask = 1 }, | |
2157 | { .key = "tag3", .value = "value3", .capmask = 1 }, | |
2158 | { .key = "tag4", .value = "value4", .capmask = 1 }, | |
2159 | { .key = "tag5", .value = "value5", .capmask = 1 }, | |
2160 | { .key = "tag6", .value = "value6", .capmask = 1 }, | |
2161 | { .key = "tag7", .value = "value7", .capmask = 1 }, | |
2162 | { .key = "tag8", .value = "value8", .capmask = 1 }, | |
2163 | { .key = "tag9", .value = "value9", .capmask = 1 }, | |
2164 | { .key = "tag10", .value = "value10", .capmask = 1 }, | |
2165 | { .key = "tag11", .value = "value11", .capmask = 1 }, | |
2166 | { .key = "tag12", .value = "value12", .capmask = 1 }, | |
2167 | { .key = "tag13", .value = "value13", .capmask = 1 }, | |
2168 | { .key = "tag14", .value = "value14", .capmask = 1 }, | |
2169 | { .key = "tag15", .value = "value15", .capmask = 1 }, | |
2170 | }, | |
2171 | ||
2172 | .cmd = "PRIVMSG", | |
2173 | .origin = "origin", | |
2174 | .target = "#test", | |
2175 | ||
2176 | .n_para = 3, | |
2177 | .para = { "test", "test", "test test" }, | |
2178 | }; | |
2179 | ||
2180 | static void small_buffer_tags_2_remaining_for_para(void) | |
2181 | { | |
2182 | char output[100]; | |
2183 | ||
2184 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_tags_msgbuf, 1), MSG)) { | |
2185 | is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag5=value5;tag6=value6;tag7=value7;tag8=value8 :o", output, MSG); | |
2186 | } | |
2187 | } | |
2188 | ||
2189 | static void small_buffer_tags_1_remaining_for_para(void) | |
2190 | { | |
2191 | char output[99]; | |
2192 | ||
2193 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_tags_msgbuf, 1), MSG)) { | |
2194 | is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag5=value5;tag6=value6;tag7=value7;tag8=value8 :", output, MSG); | |
2195 | } | |
2196 | } | |
2197 | ||
2198 | static void small_buffer_tags_0_remaining_for_para(void) | |
2199 | { | |
2200 | char output[98]; | |
2201 | ||
2202 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_tags_msgbuf, 1), MSG)) { | |
2203 | is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag5=value5;tag6=value6;tag7=value7;tag8=value8 ", output, MSG); | |
2204 | } | |
2205 | } | |
2206 | ||
2207 | static void small_buffer_tags_X_remaining_for_para(void) | |
2208 | { | |
2209 | char output[97]; | |
2210 | ||
2211 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_tags_msgbuf, 1), MSG)) { | |
2212 | // Must leave enough space for a tag but not enough space for the tag | |
2213 | // " ;tag8=value8 " | |
2214 | is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag5=value5;tag6=value6;tag7=value7 :origin PRI", output, MSG); | |
2215 | } | |
2216 | } | |
2217 | ||
2218 | static const struct MsgBuf small_buffer_a_msgbuf = { | |
2219 | .n_tags = 3, | |
2220 | .tags = { | |
2221 | { .key = "a", .value = NULL, .capmask = 1 }, | |
2222 | { .key = "c", .value = "d", .capmask = 1 }, | |
2223 | { .key = "e", .value = "f", .capmask = 1 }, | |
2224 | }, | |
2225 | ||
2226 | .cmd = "PRIVMSG", | |
2227 | .origin = "origin", | |
2228 | .target = "#test", | |
2229 | ||
2230 | .n_para = 3, | |
2231 | .para = { "test", "test", "test test" }, | |
2232 | }; | |
2233 | ||
2234 | static const struct MsgBuf small_buffer_b_msgbuf = { | |
2235 | .n_tags = 3, | |
2236 | .tags = { | |
2237 | { .key = "a", .value = "b", .capmask = 1 }, | |
2238 | { .key = "c", .value = "d", .capmask = 1 }, | |
2239 | { .key = "e", .value = "f", .capmask = 1 }, | |
2240 | }, | |
2241 | ||
2242 | .cmd = "PRIVMSG", | |
2243 | .origin = "origin", | |
2244 | .target = "#test", | |
2245 | ||
2246 | .n_para = 3, | |
2247 | .para = { "test", "test", "test test" }, | |
2248 | }; | |
2249 | ||
2250 | static void small_buffer1(void) | |
2251 | { | |
2252 | char output[1]; | |
2253 | ||
2254 | memset(output, 0, sizeof(output)); | |
2255 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2256 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2257 | is_string("", output, MSG); | |
2258 | } | |
2259 | ||
2260 | memset(output, 0, sizeof(output)); | |
2261 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2262 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2263 | is_string("", output, MSG); | |
2264 | } | |
2265 | } | |
2266 | ||
2267 | static void small_buffer2(void) | |
2268 | { | |
2269 | char output[2]; | |
2270 | ||
2271 | memset(output, 0, sizeof(output)); | |
2272 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2273 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2274 | is_string(":", output, MSG); | |
2275 | } | |
2276 | ||
2277 | memset(output, 0, sizeof(output)); | |
2278 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2279 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2280 | is_string(":", output, MSG); | |
2281 | } | |
2282 | } | |
2283 | ||
2284 | static void small_buffer3(void) | |
2285 | { | |
2286 | char output[3]; | |
2287 | ||
2288 | memset(output, 0, sizeof(output)); | |
2289 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2290 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2291 | is_string(":o", output, MSG); | |
2292 | } | |
2293 | ||
2294 | memset(output, 0, sizeof(output)); | |
2295 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2296 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2297 | is_string(":o", output, MSG); | |
2298 | } | |
2299 | } | |
2300 | ||
2301 | static void small_buffer4(void) | |
2302 | { | |
2303 | char output[4]; | |
2304 | ||
2305 | memset(output, 0, sizeof(output)); | |
2306 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2307 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2308 | is_string("@a ", output, MSG); | |
2309 | } | |
2310 | ||
2311 | memset(output, 0, sizeof(output)); | |
2312 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2313 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2314 | is_string(":or", output, MSG); | |
2315 | } | |
2316 | } | |
2317 | ||
2318 | static void small_buffer5(void) | |
2319 | { | |
2320 | char output[5]; | |
2321 | ||
2322 | memset(output, 0, sizeof(output)); | |
2323 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2324 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2325 | is_string("@a :", output, MSG); | |
2326 | } | |
2327 | ||
2328 | memset(output, 0, sizeof(output)); | |
2329 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2330 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2331 | is_string(":ori", output, MSG); | |
2332 | } | |
2333 | } | |
2334 | ||
2335 | static void small_buffer6(void) | |
2336 | { | |
2337 | char output[6]; | |
2338 | ||
2339 | memset(output, 0, sizeof(output)); | |
2340 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2341 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2342 | is_string("@a :o", output, MSG); | |
2343 | } | |
2344 | ||
2345 | memset(output, 0, sizeof(output)); | |
2346 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2347 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2348 | is_string("@a=b ", output, MSG); | |
2349 | } | |
2350 | } | |
2351 | ||
2352 | static void small_buffer7(void) | |
2353 | { | |
2354 | char output[7]; | |
2355 | ||
2356 | memset(output, 0, sizeof(output)); | |
2357 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2358 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2359 | is_string("@a :or", output, MSG); | |
2360 | } | |
2361 | ||
2362 | memset(output, 0, sizeof(output)); | |
2363 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2364 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2365 | is_string("@a=b :", output, MSG); | |
2366 | } | |
2367 | } | |
2368 | ||
2369 | static void small_buffer8(void) | |
2370 | { | |
2371 | char output[8]; | |
2372 | ||
2373 | memset(output, 0, sizeof(output)); | |
2374 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2375 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2376 | is_string("@a;c=d ", output, MSG); | |
2377 | } | |
2378 | ||
2379 | memset(output, 0, sizeof(output)); | |
2380 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2381 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2382 | is_string("@a=b :o", output, MSG); | |
2383 | } | |
2384 | } | |
2385 | ||
2386 | static void small_buffer9(void) | |
2387 | { | |
2388 | char output[9]; | |
2389 | ||
2390 | memset(output, 0, sizeof(output)); | |
2391 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2392 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2393 | is_string("@a;c=d :", output, MSG); | |
2394 | } | |
2395 | ||
2396 | memset(output, 0, sizeof(output)); | |
2397 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2398 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2399 | is_string("@a=b :or", output, MSG); | |
2400 | } | |
2401 | } | |
2402 | ||
2403 | static void small_buffer10(void) | |
2404 | { | |
2405 | char output[10]; | |
2406 | ||
2407 | memset(output, 0, sizeof(output)); | |
2408 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2409 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2410 | is_string("@a;c=d :o", output, MSG); | |
2411 | } | |
2412 | ||
2413 | memset(output, 0, sizeof(output)); | |
2414 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2415 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2416 | is_string("@a=b;c=d ", output, MSG); | |
2417 | } | |
2418 | } | |
2419 | ||
2420 | static void small_buffer11(void) | |
2421 | { | |
2422 | char output[11]; | |
2423 | ||
2424 | memset(output, 0, sizeof(output)); | |
2425 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2426 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2427 | is_string("@a;c=d :or", output, MSG); | |
2428 | } | |
2429 | ||
2430 | memset(output, 0, sizeof(output)); | |
2431 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2432 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2433 | is_string("@a=b;c=d :", output, MSG); | |
2434 | } | |
2435 | } | |
2436 | ||
2437 | static void small_buffer12(void) | |
2438 | { | |
2439 | char output[12]; | |
2440 | ||
2441 | memset(output, 0, sizeof(output)); | |
2442 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2443 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2444 | is_string("@a;c=d;e=f ", output, MSG); | |
2445 | } | |
2446 | ||
2447 | memset(output, 0, sizeof(output)); | |
2448 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2449 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2450 | is_string("@a=b;c=d :o", output, MSG); | |
2451 | } | |
2452 | } | |
2453 | ||
2454 | static void small_buffer13(void) | |
2455 | { | |
2456 | char output[13]; | |
2457 | ||
2458 | memset(output, 0, sizeof(output)); | |
2459 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2460 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2461 | is_string("@a;c=d;e=f :", output, MSG); | |
2462 | } | |
2463 | ||
2464 | memset(output, 0, sizeof(output)); | |
2465 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2466 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2467 | is_string("@a=b;c=d :or", output, MSG); | |
2468 | } | |
2469 | } | |
2470 | ||
2471 | static void small_buffer14(void) | |
2472 | { | |
2473 | char output[14]; | |
2474 | ||
2475 | memset(output, 0, sizeof(output)); | |
2476 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2477 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2478 | is_string("@a;c=d;e=f :o", output, MSG); | |
2479 | } | |
2480 | ||
2481 | memset(output, 0, sizeof(output)); | |
2482 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2483 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2484 | is_string("@a=b;c=d;e=f ", output, MSG); | |
2485 | } | |
2486 | } | |
2487 | ||
2488 | static void small_buffer15(void) | |
2489 | { | |
2490 | char output[15]; | |
2491 | ||
2492 | memset(output, 0, sizeof(output)); | |
2493 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_a_msgbuf, 1), MSG)) { | |
2494 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2495 | is_string("@a;c=d;e=f :or", output, MSG); | |
2496 | } | |
2497 | ||
2498 | memset(output, 0, sizeof(output)); | |
2499 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &small_buffer_b_msgbuf, 1), MSG)) { | |
2500 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2501 | is_string("@a=b;c=d;e=f :", output, MSG); | |
2502 | } | |
2503 | } | |
2504 | ||
2505 | static const struct MsgBuf long_tags_small_buffer_msgbuf = { | |
2506 | .n_tags = 1, | |
2507 | .tags = { | |
2508 | { .key = MKTEXT(510), .value = NULL, .capmask = 1 }, | |
2509 | }, | |
2510 | ||
2511 | .cmd = "PRIVMSG", | |
2512 | .origin = "origin", | |
2513 | .target = "#test", | |
2514 | ||
2515 | .n_para = 3, | |
2516 | .para = { "test", "test", "test test" }, | |
2517 | }; | |
2518 | ||
2519 | #define LONG_TAGS "@10abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx"\ | |
2520 | "yzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcbaZYXWVUT"\ | |
2521 | "SRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"\ | |
2522 | "QRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCB"\ | |
2523 | "AzyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefgh"\ | |
2524 | "ijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ " | |
2525 | ||
2526 | static void long_tags_small_buffer0(void) | |
2527 | { | |
2528 | char output[TAGSLEN + 0 + 1]; | |
2529 | ||
2530 | memset(output, 0, sizeof(output)); | |
2531 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &long_tags_small_buffer_msgbuf, 1), MSG)) { | |
2532 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2533 | is_string(LONG_TAGS "", output, MSG); | |
2534 | } | |
2535 | } | |
2536 | ||
2537 | static void long_tags_small_buffer1(void) | |
2538 | { | |
2539 | char output[TAGSLEN + 1 + 1]; | |
2540 | ||
2541 | memset(output, 0, sizeof(output)); | |
2542 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &long_tags_small_buffer_msgbuf, 1), MSG)) { | |
2543 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2544 | is_string(LONG_TAGS ":", output, MSG); | |
2545 | } | |
2546 | } | |
2547 | ||
2548 | static void long_tags_small_buffer2(void) | |
2549 | { | |
2550 | char output[TAGSLEN + 2 + 1]; | |
2551 | ||
2552 | memset(output, 0, sizeof(output)); | |
2553 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &long_tags_small_buffer_msgbuf, 1), MSG)) { | |
2554 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2555 | is_string(LONG_TAGS ":o", output, MSG); | |
2556 | } | |
2557 | } | |
2558 | ||
2559 | static void long_tags_small_buffer3(void) | |
2560 | { | |
2561 | char output[TAGSLEN + 3 + 1]; | |
2562 | ||
2563 | memset(output, 0, sizeof(output)); | |
2564 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &long_tags_small_buffer_msgbuf, 1), MSG)) { | |
2565 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2566 | is_string(LONG_TAGS ":or", output, MSG); | |
2567 | } | |
2568 | } | |
2569 | ||
2570 | static void long_tags_small_buffer4(void) | |
2571 | { | |
2572 | char output[TAGSLEN + 4 + 1]; | |
2573 | ||
2574 | memset(output, 0, sizeof(output)); | |
2575 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &long_tags_small_buffer_msgbuf, 1), MSG)) { | |
2576 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2577 | is_string(LONG_TAGS ":ori", output, MSG); | |
2578 | } | |
2579 | } | |
2580 | ||
2581 | static void long_tags_small_buffer5(void) | |
2582 | { | |
2583 | char output[TAGSLEN + 5 + 1]; | |
2584 | ||
2585 | memset(output, 0, sizeof(output)); | |
2586 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &long_tags_small_buffer_msgbuf, 1), MSG)) { | |
2587 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2588 | is_string(LONG_TAGS ":orig", output, MSG); | |
2589 | } | |
2590 | } | |
2591 | ||
2592 | static const struct MsgBuf no_tags_small_buffer_msgbuf = { | |
2593 | .n_tags = 0, | |
2594 | ||
2595 | .cmd = "PRIVMSG", | |
2596 | .origin = "origin", | |
2597 | .target = "#test", | |
2598 | ||
2599 | .n_para = 3, | |
2600 | .para = { "test", "test", "test test" }, | |
2601 | }; | |
2602 | ||
2603 | static void no_tags_small_buffer1(void) | |
2604 | { | |
2605 | char output[1]; | |
2606 | ||
2607 | memset(output, 0, sizeof(output)); | |
2608 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &no_tags_small_buffer_msgbuf, 1), MSG)) { | |
2609 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2610 | is_string("", output, MSG); | |
2611 | } | |
2612 | } | |
2613 | ||
2614 | static void no_tags_small_buffer2(void) | |
2615 | { | |
2616 | char output[2]; | |
2617 | ||
2618 | memset(output, 0, sizeof(output)); | |
2619 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &no_tags_small_buffer_msgbuf, 1), MSG)) { | |
2620 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2621 | is_string(":", output, MSG); | |
2622 | } | |
2623 | } | |
2624 | ||
2625 | static void no_tags_small_buffer3(void) | |
2626 | { | |
2627 | char output[3]; | |
2628 | ||
2629 | memset(output, 0, sizeof(output)); | |
2630 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &no_tags_small_buffer_msgbuf, 1), MSG)) { | |
2631 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2632 | is_string(":o", output, MSG); | |
2633 | } | |
2634 | } | |
2635 | ||
2636 | static void no_tags_small_buffer4(void) | |
2637 | { | |
2638 | char output[4]; | |
2639 | ||
2640 | memset(output, 0, sizeof(output)); | |
2641 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &no_tags_small_buffer_msgbuf, 1), MSG)) { | |
2642 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2643 | is_string(":or", output, MSG); | |
2644 | } | |
2645 | } | |
2646 | ||
2647 | static void no_tags_small_buffer5(void) | |
2648 | { | |
2649 | char output[5]; | |
2650 | ||
2651 | memset(output, 0, sizeof(output)); | |
2652 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &no_tags_small_buffer_msgbuf, 1), MSG)) { | |
2653 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2654 | is_string(":ori", output, MSG); | |
2655 | } | |
2656 | } | |
2657 | ||
2658 | static void no_tags_small_buffer6(void) | |
2659 | { | |
2660 | char output[6]; | |
2661 | ||
2662 | memset(output, 0, sizeof(output)); | |
2663 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &no_tags_small_buffer_msgbuf, 1), MSG)) { | |
2664 | is_int(sizeof(output) - 1, strlen(output), MSG); | |
2665 | is_string(":orig", output, MSG); | |
2666 | } | |
2667 | } | |
2668 | ||
2669 | static void para_no_origin(void) | |
2670 | { | |
2671 | const struct MsgBuf msgbuf = { | |
2672 | .n_tags = 0, | |
2673 | ||
2674 | .cmd = "PRIVMSG", | |
2675 | .origin = NULL, | |
2676 | .target = "#test", | |
2677 | ||
2678 | .n_para = 3, | |
2679 | .para = { "test1", "test2", "test3 test4" }, | |
2680 | }; | |
2681 | char output[OUTPUT_BUFSIZE]; | |
2682 | ||
2683 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2684 | is_string(":me.name. PRIVMSG #test test1 test2 :test3 test4", output, MSG); | |
2685 | } | |
2686 | } | |
2687 | ||
2688 | static void para_no_cmd(void) | |
2689 | { | |
2690 | const struct MsgBuf msgbuf = { | |
2691 | .n_tags = 0, | |
2692 | ||
2693 | .cmd = NULL, | |
2694 | .origin = "origin", | |
2695 | .target = "#test", | |
2696 | ||
2697 | .n_para = 3, | |
2698 | .para = { "test1", "test2", "test3 test4" }, | |
2699 | }; | |
2700 | char output[OUTPUT_BUFSIZE]; | |
2701 | ||
2702 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2703 | is_string(":origin #test test1 test2 :test3 test4", output, MSG); | |
2704 | } | |
2705 | } | |
2706 | ||
2707 | static void para_no_target(void) | |
2708 | { | |
2709 | const struct MsgBuf msgbuf = { | |
2710 | .n_tags = 0, | |
2711 | ||
2712 | .cmd = "PRIVMSG", | |
2713 | .origin = "origin", | |
2714 | .target = NULL, | |
2715 | ||
2716 | .n_para = 3, | |
2717 | .para = { "test1", "test2", "test3 test4" }, | |
2718 | }; | |
2719 | char output[OUTPUT_BUFSIZE]; | |
2720 | ||
2721 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2722 | is_string(":origin PRIVMSG test1 test2 :test3 test4", output, MSG); | |
2723 | } | |
2724 | } | |
2725 | ||
2726 | static void para_no_origin_no_cmd(void) | |
2727 | { | |
2728 | const struct MsgBuf msgbuf = { | |
2729 | .n_tags = 0, | |
2730 | ||
2731 | .cmd = NULL, | |
2732 | .origin = NULL, | |
2733 | .target = "#test", | |
2734 | ||
2735 | .n_para = 3, | |
2736 | .para = { "test1", "test2", "test3 test4" }, | |
2737 | }; | |
2738 | char output[OUTPUT_BUFSIZE]; | |
2739 | ||
2740 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2741 | is_string(":me.name. #test test1 test2 :test3 test4", output, MSG); | |
2742 | } | |
2743 | } | |
2744 | ||
2745 | static void para_no_origin_no_target(void) | |
2746 | { | |
2747 | const struct MsgBuf msgbuf = { | |
2748 | .n_tags = 0, | |
2749 | ||
2750 | .cmd = "PRIVMSG", | |
2751 | .origin = NULL, | |
2752 | .target = NULL, | |
2753 | ||
2754 | .n_para = 3, | |
2755 | .para = { "test1", "test2", "test3 test4" }, | |
2756 | }; | |
2757 | char output[OUTPUT_BUFSIZE]; | |
2758 | ||
2759 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2760 | is_string(":me.name. PRIVMSG test1 test2 :test3 test4", output, MSG); | |
2761 | } | |
2762 | } | |
2763 | ||
2764 | static void para_no_cmd_no_target(void) | |
2765 | { | |
2766 | const struct MsgBuf msgbuf = { | |
2767 | .n_tags = 0, | |
2768 | ||
2769 | .cmd = NULL, | |
2770 | .origin = "origin", | |
2771 | .target = NULL, | |
2772 | ||
2773 | .n_para = 3, | |
2774 | .para = { "test1", "test2", "test3 test4" }, | |
2775 | }; | |
2776 | char output[OUTPUT_BUFSIZE]; | |
2777 | ||
2778 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2779 | is_string(":origin test1 test2 :test3 test4", output, MSG); | |
2780 | } | |
2781 | } | |
2782 | ||
2783 | static void para_no_origin_no_cmd_no_target(void) | |
2784 | { | |
2785 | const struct MsgBuf msgbuf = { | |
2786 | .n_tags = 0, | |
2787 | ||
2788 | .cmd = NULL, | |
2789 | .origin = NULL, | |
2790 | .target = NULL, | |
2791 | ||
2792 | .n_para = 3, | |
2793 | .para = { "test1", "test2", "test3 test4" }, | |
2794 | }; | |
2795 | char output[OUTPUT_BUFSIZE]; | |
2796 | ||
2797 | if (is_int(0, msgbuf_unparse(output, sizeof(output), &msgbuf, 1), MSG)) { | |
2798 | is_string(":me.name. test1 test2 :test3 test4", output, MSG); | |
2799 | } | |
2800 | } | |
2801 | ||
2802 | int main(int argc, char *argv[]) | |
2803 | { | |
2804 | memset(&me, 0, sizeof(me)); | |
2805 | strcpy(me.name, "me.name."); | |
2806 | ||
2807 | plan_lazy(); | |
2808 | ||
2809 | is_int(512, TAGSLEN, MSG); | |
2810 | is_int(510, DATALEN, MSG); | |
2811 | is_int(512 + 510 + 1, EXT_BUFSIZE, MSG); | |
2812 | ||
2813 | basic_tags1(); | |
2814 | basic_tags2(); | |
2815 | basic_tags15(); | |
2816 | basic_tags15_capmask1(); | |
2817 | basic_tags15_capmask2(); | |
2818 | ||
2819 | no_tags(); | |
2820 | empty_tag(); | |
2821 | ||
2822 | long_tag1_no_value(); | |
2823 | long_tag1_empty_value(); | |
2824 | long_tag1_short_value(); | |
2825 | short_tag1_long_value(); | |
2826 | short_tag1_long_value(); | |
2827 | short_tag1_long_value(); | |
2828 | ||
2829 | too_long_tag1_no_value(); | |
2830 | too_long_tag1_empty_value(); | |
2831 | too_long_tag1_short_value(); | |
2832 | short_tag1_too_long_value(); | |
2833 | short_tag1_too_long_value(); | |
2834 | short_tag1_too_long_value(); | |
2835 | ||
2836 | long_tag2a_no_value(); | |
2837 | long_tag2b_no_value(); | |
2838 | long_tag2c_no_value(); | |
2839 | long_tag2a_empty_value(); | |
2840 | long_tag2b_empty_value(); | |
2841 | long_tag2c_empty_value(); | |
2842 | long_tag2a_short_value(); | |
2843 | long_tag2b_short_value(); | |
2844 | long_tag2c_short_value(); | |
2845 | short_tag2a_long_value(); | |
2846 | short_tag2b_long_value(); | |
2847 | short_tag2c_long_value(); | |
2848 | ||
2849 | too_long_tag2a_no_value(); | |
2850 | too_long_tag2b_no_value(); | |
2851 | too_long_tag2c_no_value(); | |
2852 | too_long_tag2a_empty_value(); | |
2853 | too_long_tag2b_empty_value(); | |
2854 | too_long_tag2c_empty_value(); | |
2855 | too_long_tag2a_short_value(); | |
2856 | too_long_tag2b_short_value(); | |
2857 | too_long_tag2c_short_value(); | |
2858 | short_tag2a_too_long_value(); | |
2859 | short_tag2b_too_long_value(); | |
2860 | short_tag2c_too_long_value(); | |
2861 | ||
2862 | too_long_for_tag2a_0remaining(); | |
2863 | too_long_for_tag2a_1remaining(); | |
2864 | too_long_for_tag2a_2remaining(); | |
2865 | too_long_for_tag2a_3remaining(); | |
2866 | too_long_for_tag2a_3short(); | |
2867 | too_long_for_tag2a_2short(); | |
2868 | too_long_for_tag2a_1short(); | |
2869 | exact_space_for_tag2a(); | |
2870 | ||
2871 | too_long_for_tag2b_0remaining(); | |
2872 | too_long_for_tag2b_1remaining(); | |
2873 | too_long_for_tag2b_2remaining(); | |
2874 | too_long_for_tag2b_3remaining(); | |
2875 | too_long_for_tag2b_3short(); | |
2876 | too_long_for_tag2b_2short(); | |
2877 | too_long_for_tag2b_1short(); | |
2878 | exact_space_for_tag2b(); | |
2879 | ||
2880 | escape_test(); | |
2881 | escape_test_8bit(); | |
2882 | ||
2883 | long_para1a(); | |
2884 | too_long_para1a(); | |
2885 | long_para1b(); | |
2886 | too_long_para1b(); | |
2887 | ||
2888 | long_para2a(); | |
2889 | too_long_para2a(); | |
2890 | long_para2b(); | |
2891 | too_long_para2b(); | |
2892 | ||
2893 | long_para3a(); | |
2894 | too_long_para3a(); | |
2895 | long_para3b(); | |
2896 | too_long_para3b(); | |
2897 | ||
2898 | long_para15a(); | |
2899 | too_long_para15a(); | |
2900 | long_para15b(); | |
2901 | too_long_para15b(); | |
2902 | ||
2903 | small_buffer_tags_2_remaining_for_para(); | |
2904 | small_buffer_tags_1_remaining_for_para(); | |
2905 | small_buffer_tags_0_remaining_for_para(); | |
2906 | small_buffer_tags_X_remaining_for_para(); | |
2907 | ||
2908 | small_buffer1(); | |
2909 | small_buffer2(); | |
2910 | small_buffer3(); | |
2911 | small_buffer4(); | |
2912 | small_buffer5(); | |
2913 | small_buffer6(); | |
2914 | small_buffer7(); | |
2915 | small_buffer8(); | |
2916 | small_buffer9(); | |
2917 | small_buffer10(); | |
2918 | small_buffer11(); | |
2919 | small_buffer12(); | |
2920 | small_buffer13(); | |
2921 | small_buffer14(); | |
2922 | small_buffer15(); | |
2923 | ||
2924 | long_tags_small_buffer0(); | |
2925 | long_tags_small_buffer1(); | |
2926 | long_tags_small_buffer2(); | |
2927 | long_tags_small_buffer3(); | |
2928 | long_tags_small_buffer4(); | |
2929 | long_tags_small_buffer5(); | |
2930 | ||
2931 | no_tags_small_buffer1(); | |
2932 | no_tags_small_buffer2(); | |
2933 | no_tags_small_buffer3(); | |
2934 | no_tags_small_buffer4(); | |
2935 | no_tags_small_buffer5(); | |
2936 | no_tags_small_buffer6(); | |
2937 | ||
2938 | para_no_origin(); | |
2939 | para_no_cmd(); | |
2940 | para_no_target(); | |
2941 | para_no_origin_no_cmd(); | |
2942 | para_no_origin_no_target(); | |
2943 | para_no_cmd_no_target(); | |
2944 | para_no_origin_no_cmd_no_target(); | |
2945 | ||
2946 | // TODO msgbuf_vunparse_fmt | |
2947 | ||
2948 | return 0; | |
2949 | } |