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