2 * msgbuf_unparse1.c: Test msgbuf under various conditions
3 * Copyright 2017 Simon Arlott
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.
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.
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
24 #include "tap/basic.h"
27 #include "ircd_defs.h"
31 #define MSG "%s:%d (%s)", __FILE__, __LINE__, __FUNCTION__
34 static const char text
[] =
35 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba"
36 "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
37 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba"
38 "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
39 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba"
40 "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
41 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba"
42 "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
43 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba"
44 "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
47 #define MKTEXT(n) &text[sizeof(text) - ((n) + 1)]
49 /* must be much larger than the intended maximum output tags/data size */
50 #define OUTPUT_BUFSIZE (EXT_BUFSIZE * 4)
52 static void basic_tags1(void)
54 const struct MsgBuf msgbuf
= {
57 { .key
= "tag", .value
= "value", .capmask
= 1 },
65 .para
= { "test", "test", "test test" },
67 char output
[OUTPUT_BUFSIZE
];
69 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
70 is_string("@tag=value :origin PRIVMSG #test test test :test test", output
, MSG
);
74 static void basic_tags2(void)
76 const struct MsgBuf msgbuf
= {
79 { .key
= "tag1", .value
= "value1", .capmask
= 1 },
80 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
88 .para
= { "test", "test", "test test" },
90 char output
[OUTPUT_BUFSIZE
];
92 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
93 is_string("@tag1=value1;tag2=value2 :origin PRIVMSG #test test test :test test", output
, MSG
);
97 static void basic_tags15(void)
99 const struct MsgBuf msgbuf
= {
102 { .key
= "tag1", .value
= "value1", .capmask
= 1 },
103 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
104 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
105 { .key
= "tag4", .value
= "value4", .capmask
= 1 },
106 { .key
= "tag5", .value
= "value5", .capmask
= 1 },
107 { .key
= "tag6", .value
= "value6", .capmask
= 1 },
108 { .key
= "tag7", .value
= "value7", .capmask
= 1 },
109 { .key
= "tag8", .value
= "value8", .capmask
= 1 },
110 { .key
= "tag9", .value
= "value9", .capmask
= 1 },
111 { .key
= "tag10", .value
= "value10", .capmask
= 1 },
112 { .key
= "tag11", .value
= "value11", .capmask
= 1 },
113 { .key
= "tag12", .value
= "value12", .capmask
= 1 },
114 { .key
= "tag13", .value
= "value13", .capmask
= 1 },
115 { .key
= "tag14", .value
= "value14", .capmask
= 1 },
116 { .key
= "tag15", .value
= "value15", .capmask
= 1 },
124 .para
= { "test", "test", "test test" },
126 char output
[OUTPUT_BUFSIZE
];
128 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
129 is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag5=value5;tag6=value6;tag7=value7;tag8=value8;tag9=value9;tag10=value10;tag11=value11;tag12=value12;tag13=value13;tag14=value14;tag15=value15 :origin PRIVMSG #test test test :test test", output
, MSG
);
133 static void basic_tags15_capmask1(void)
135 const struct MsgBuf msgbuf
= {
138 { .key
= "tag1", .value
= "value1", .capmask
= 0x1 },
139 { .key
= "tag2", .value
= "value2", .capmask
= 0x3 },
140 { .key
= "tag3", .value
= "value3", .capmask
= 0xffffffff },
141 { .key
= "tag4", .value
= "value4", .capmask
= 0xffff },
142 { .key
= "tag5", .value
= "value5", .capmask
= 0x0 },
143 { .key
= "tag6", .value
= "value6", .capmask
= 0x3e9 },
144 { .key
= "tag7", .value
= "value7", .capmask
= 0x2 },
145 { .key
= "tag8", .value
= "value8", .capmask
= 0x65 },
146 { .key
= "tag9", .value
= "value9", .capmask
= 0x5 },
147 { .key
= "tag10", .value
= "value10", .capmask
= 0x7fffffff },
148 { .key
= "tag11", .value
= "value11", .capmask
= 0x80000001 },
149 { .key
= "tag12", .value
= "value12", .capmask
= 0xf },
150 { .key
= "tag13", .value
= "value13", .capmask
= 0x6 },
151 { .key
= "tag14", .value
= "value14", .capmask
= 0x4 },
152 { .key
= "tag15", .value
= "value15", .capmask
= 0x7 },
160 .para
= { "test", "test", "test test" },
162 char output
[OUTPUT_BUFSIZE
];
164 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
165 is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag6=value6;tag8=value8;tag9=value9;tag10=value10;tag11=value11;tag12=value12;tag15=value15 :origin PRIVMSG #test test test :test test", output
, MSG
);
169 static void basic_tags15_capmask2(void)
171 const struct MsgBuf msgbuf
= {
174 { .key
= "tag1", .value
= "value1", .capmask
= 0x1 },
175 { .key
= "tag2", .value
= "value2", .capmask
= 0x3 },
176 { .key
= "tag3", .value
= "value3", .capmask
= 0xffffffff },
177 { .key
= "tag4", .value
= "value4", .capmask
= 0xffff },
178 { .key
= "tag5", .value
= "value5", .capmask
= 0x0 },
179 { .key
= "tag6", .value
= "value6", .capmask
= 0x3e9 },
180 { .key
= "tag7", .value
= "value7", .capmask
= 0x2 },
181 { .key
= "tag8", .value
= "value8", .capmask
= 0x65 },
182 { .key
= "tag9", .value
= "value9", .capmask
= 0x5 },
183 { .key
= "tag10", .value
= "value10", .capmask
= 0x7fffffff },
184 { .key
= "tag11", .value
= "value11", .capmask
= 0x80000001 },
185 { .key
= "tag12", .value
= "value12", .capmask
= 0xf },
186 { .key
= "tag13", .value
= "value13", .capmask
= 0x6 },
187 { .key
= "tag14", .value
= "value14", .capmask
= 0x4 },
188 { .key
= "tag15", .value
= "value15", .capmask
= 0x7 },
196 .para
= { "test", "test", "test test" },
198 char output
[OUTPUT_BUFSIZE
];
200 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 0x24), MSG
)) {
201 is_string("@tag3=value3;tag4=value4;tag6=value6;tag8=value8;tag9=value9;tag10=value10;tag12=value12;tag13=value13;tag14=value14;tag15=value15 :origin PRIVMSG #test test test :test test", output
, MSG
);
205 static void no_tags(void)
207 const struct MsgBuf msgbuf
= {
216 .para
= { "test", "test", "test test" },
218 char output
[OUTPUT_BUFSIZE
];
220 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
221 is_string(":origin PRIVMSG #test test test :test test", output
, MSG
);
225 static void empty_tag(void)
227 const struct MsgBuf msgbuf
= {
230 { .key
= "", .value
= "value", .capmask
= 1 },
238 .para
= { "test", "test", "test test" },
240 char output
[OUTPUT_BUFSIZE
];
242 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
243 is_string(":origin PRIVMSG #test test test :test test", output
, MSG
);
247 static void too_long_for_tag2a_0remaining(void)
249 const struct MsgBuf msgbuf
= {
252 { .key
= MKTEXT(259), .value
= MKTEXT(250), .capmask
= 1 },
253 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
254 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
262 .para
= { "test", "test", "test test" },
264 char output
[OUTPUT_BUFSIZE
];
266 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
270 strcat(tmp
, MKTEXT(259));
272 strcat(tmp
, MKTEXT(250));
274 is_int(512, strlen(tmp
), MSG
);
275 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
277 is_string(tmp
, output
, MSG
);
281 static void too_long_for_tag2a_1remaining(void)
283 const struct MsgBuf msgbuf
= {
286 { .key
= MKTEXT(259), .value
= MKTEXT(249), .capmask
= 1 },
287 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
288 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
296 .para
= { "test", "test", "test test" },
298 char output
[OUTPUT_BUFSIZE
];
300 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
304 strcat(tmp
, MKTEXT(259));
306 strcat(tmp
, MKTEXT(249));
308 is_int(512 - 1, strlen(tmp
), MSG
);
309 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
311 is_string(tmp
, output
, MSG
);
315 static void too_long_for_tag2a_2remaining(void)
317 const struct MsgBuf msgbuf
= {
320 { .key
= MKTEXT(259), .value
= MKTEXT(248), .capmask
= 1 },
321 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
322 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
330 .para
= { "test", "test", "test test" },
332 char output
[OUTPUT_BUFSIZE
];
334 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
338 strcat(tmp
, MKTEXT(259));
340 strcat(tmp
, MKTEXT(248));
342 is_int(512 - 2, strlen(tmp
), MSG
);
343 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
345 is_string(tmp
, output
, MSG
);
349 static void too_long_for_tag2a_3remaining(void)
351 const struct MsgBuf msgbuf
= {
354 { .key
= MKTEXT(259), .value
= MKTEXT(247), .capmask
= 1 },
355 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
356 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
364 .para
= { "test", "test", "test test" },
366 char output
[OUTPUT_BUFSIZE
];
368 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
372 strcat(tmp
, MKTEXT(259));
374 strcat(tmp
, MKTEXT(247));
376 is_int(512 - 3, strlen(tmp
), MSG
);
377 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
379 is_string(tmp
, output
, MSG
);
383 static void too_long_for_tag2a_3short(void)
385 const struct MsgBuf msgbuf
= {
388 { .key
= MKTEXT(259), .value
= MKTEXT(241), .capmask
= 1 },
389 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
390 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
398 .para
= { "test", "test", "test test" },
400 char output
[OUTPUT_BUFSIZE
];
402 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
406 strcat(tmp
, MKTEXT(259));
408 strcat(tmp
, MKTEXT(241));
410 is_int(512 - 9, strlen(tmp
), MSG
);
411 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
413 is_string(tmp
, output
, MSG
);
417 static void too_long_for_tag2a_2short(void)
419 const struct MsgBuf msgbuf
= {
422 { .key
= MKTEXT(259), .value
= MKTEXT(240), .capmask
= 1 },
423 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
424 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
432 .para
= { "test", "test", "test test" },
434 char output
[OUTPUT_BUFSIZE
];
436 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
440 strcat(tmp
, MKTEXT(259));
442 strcat(tmp
, MKTEXT(240));
444 is_int(512 - 10, strlen(tmp
), MSG
);
445 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
447 is_string(tmp
, output
, MSG
);
451 static void too_long_for_tag2a_1short(void)
453 const struct MsgBuf msgbuf
= {
456 { .key
= MKTEXT(259), .value
= MKTEXT(239), .capmask
= 1 },
457 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
458 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
466 .para
= { "test", "test", "test test" },
468 char output
[OUTPUT_BUFSIZE
];
470 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
474 strcat(tmp
, MKTEXT(259));
476 strcat(tmp
, MKTEXT(239));
478 is_int(512 - 11, strlen(tmp
), MSG
);
479 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
481 is_string(tmp
, output
, MSG
);
485 static void exact_space_for_tag2a(void)
487 const struct MsgBuf msgbuf
= {
490 { .key
= MKTEXT(259), .value
= MKTEXT(238), .capmask
= 1 },
491 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
492 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
500 .para
= { "test", "test", "test test" },
502 char output
[OUTPUT_BUFSIZE
];
504 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
508 strcat(tmp
, MKTEXT(259));
510 strcat(tmp
, MKTEXT(238));
511 strcat(tmp
, ";tag2=value2 ");
512 is_int(512, strlen(tmp
), MSG
);
513 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
515 is_string(tmp
, output
, MSG
);
519 static void too_long_for_tag2b_0remaining(void)
521 const struct MsgBuf msgbuf
= {
524 { .key
= MKTEXT(259), .value
= MKTEXT(250), .capmask
= 1 },
525 { .key
= "a", .value
= "b", .capmask
= 1 },
526 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
534 .para
= { "test", "test", "test test" },
536 char output
[OUTPUT_BUFSIZE
];
538 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
542 strcat(tmp
, MKTEXT(259));
544 strcat(tmp
, MKTEXT(250));
546 is_int(512, strlen(tmp
), MSG
);
547 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
549 is_string(tmp
, output
, MSG
);
553 static void too_long_for_tag2b_1remaining(void)
555 const struct MsgBuf msgbuf
= {
558 { .key
= MKTEXT(259), .value
= MKTEXT(249), .capmask
= 1 },
559 { .key
= "a", .value
= "b", .capmask
= 1 },
560 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
568 .para
= { "test", "test", "test test" },
570 char output
[OUTPUT_BUFSIZE
];
572 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
576 strcat(tmp
, MKTEXT(259));
578 strcat(tmp
, MKTEXT(249));
580 is_int(512 - 1, strlen(tmp
), MSG
);
581 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
583 is_string(tmp
, output
, MSG
);
587 static void too_long_for_tag2b_2remaining(void)
589 const struct MsgBuf msgbuf
= {
592 { .key
= MKTEXT(259), .value
= MKTEXT(248), .capmask
= 1 },
593 { .key
= "a", .value
= "b", .capmask
= 1 },
594 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
602 .para
= { "test", "test", "test test" },
604 char output
[OUTPUT_BUFSIZE
];
606 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
610 strcat(tmp
, MKTEXT(259));
612 strcat(tmp
, MKTEXT(248));
614 is_int(512 - 2, strlen(tmp
), MSG
);
615 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
617 is_string(tmp
, output
, MSG
);
621 static void too_long_for_tag2b_3remaining(void)
623 const struct MsgBuf msgbuf
= {
626 { .key
= MKTEXT(259), .value
= MKTEXT(247), .capmask
= 1 },
627 { .key
= "a", .value
= "b", .capmask
= 1 },
628 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
636 .para
= { "test", "test", "test test" },
638 char output
[OUTPUT_BUFSIZE
];
640 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
644 strcat(tmp
, MKTEXT(259));
646 strcat(tmp
, MKTEXT(247));
648 is_int(512 - 3, strlen(tmp
), MSG
);
649 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
651 is_string(tmp
, output
, MSG
);
655 static void too_long_for_tag2b_3short(void)
657 const struct MsgBuf msgbuf
= {
660 { .key
= MKTEXT(267), .value
= MKTEXT(241), .capmask
= 1 },
661 { .key
= "a", .value
= "b", .capmask
= 1 },
662 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
670 .para
= { "test", "test", "test test" },
672 char output
[OUTPUT_BUFSIZE
];
674 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
678 strcat(tmp
, MKTEXT(267));
680 strcat(tmp
, MKTEXT(241));
682 is_int(512 - 1, strlen(tmp
), MSG
);
683 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
685 is_string(tmp
, output
, MSG
);
689 static void too_long_for_tag2b_2short(void)
691 const struct MsgBuf msgbuf
= {
694 { .key
= MKTEXT(267), .value
= MKTEXT(240), .capmask
= 1 },
695 { .key
= "a", .value
= "b", .capmask
= 1 },
696 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
704 .para
= { "test", "test", "test test" },
706 char output
[OUTPUT_BUFSIZE
];
708 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
712 strcat(tmp
, MKTEXT(267));
714 strcat(tmp
, MKTEXT(240));
716 is_int(512 - 2, strlen(tmp
), MSG
);
717 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
719 is_string(tmp
, output
, MSG
);
723 static void too_long_for_tag2b_1short(void)
725 const struct MsgBuf msgbuf
= {
728 { .key
= MKTEXT(267), .value
= MKTEXT(239), .capmask
= 1 },
729 { .key
= "a", .value
= "b", .capmask
= 1 },
730 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
738 .para
= { "test", "test", "test test" },
740 char output
[OUTPUT_BUFSIZE
];
742 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
746 strcat(tmp
, MKTEXT(267));
748 strcat(tmp
, MKTEXT(239));
750 is_int(512 - 3, strlen(tmp
), MSG
);
751 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
753 is_string(tmp
, output
, MSG
);
757 static void exact_space_for_tag2b(void)
759 const struct MsgBuf msgbuf
= {
762 { .key
= MKTEXT(267), .value
= MKTEXT(238), .capmask
= 1 },
763 { .key
= "a", .value
= "b", .capmask
= 1 },
764 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
772 .para
= { "test", "test", "test test" },
774 char output
[OUTPUT_BUFSIZE
];
776 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
780 strcat(tmp
, MKTEXT(267));
782 strcat(tmp
, MKTEXT(238));
783 strcat(tmp
, ";a=b ");
784 is_int(512, strlen(tmp
), MSG
);
785 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
787 is_string(tmp
, output
, MSG
);
791 static void long_tag1_no_value(void)
793 const struct MsgBuf msgbuf
= {
796 { .key
= MKTEXT(510), .value
= NULL
, .capmask
= 1 },
804 .para
= { "test", "test", "test test" },
806 char output
[OUTPUT_BUFSIZE
];
808 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
812 strcat(tmp
, MKTEXT(510));
814 is_int(512, strlen(tmp
), MSG
);
815 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
817 is_string(tmp
, output
, MSG
);
821 static void long_tag1_empty_value(void)
823 const struct MsgBuf msgbuf
= {
826 { .key
= MKTEXT(509), .value
= "", .capmask
= 1 },
834 .para
= { "test", "test", "test test" },
836 char output
[OUTPUT_BUFSIZE
];
838 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
842 strcat(tmp
, MKTEXT(509));
844 is_int(512, strlen(tmp
), MSG
);
845 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
847 is_string(tmp
, output
, MSG
);
851 static void long_tag1_short_value(void)
853 const struct MsgBuf msgbuf
= {
856 { .key
= MKTEXT(508), .value
= "x", .capmask
= 1 },
864 .para
= { "test", "test", "test test" },
866 char output
[OUTPUT_BUFSIZE
];
868 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
872 strcat(tmp
, MKTEXT(508));
874 is_int(512, strlen(tmp
), MSG
);
875 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
877 is_string(tmp
, output
, MSG
);
881 static void short_tag1_long_value(void)
883 const struct MsgBuf msgbuf
= {
886 { .key
= "x", .value
= MKTEXT(508), .capmask
= 1 },
894 .para
= { "test", "test", "test test" },
896 char output
[OUTPUT_BUFSIZE
];
898 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
902 strcat(tmp
, MKTEXT(508));
904 is_int(512, strlen(tmp
), MSG
);
905 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
907 is_string(tmp
, output
, MSG
);
911 static void too_long_tag1_no_value(void)
913 const struct MsgBuf msgbuf
= {
916 { .key
= MKTEXT(511), .value
= NULL
, .capmask
= 1 },
924 .para
= { "test", "test", "test test" },
926 char output
[OUTPUT_BUFSIZE
];
928 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
929 is_string(":origin PRIVMSG #test test test :test test", output
, MSG
);
933 static void too_long_tag1_empty_value(void)
935 const struct MsgBuf msgbuf
= {
938 { .key
= MKTEXT(510), .value
= "", .capmask
= 1 },
946 .para
= { "test", "test", "test test" },
948 char output
[OUTPUT_BUFSIZE
];
950 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
951 is_string(":origin PRIVMSG #test test test :test test", output
, MSG
);
955 static void too_long_tag1_short_value(void)
957 const struct MsgBuf msgbuf
= {
960 { .key
= MKTEXT(509), .value
= "x", .capmask
= 1 },
968 .para
= { "test", "test", "test test" },
970 char output
[OUTPUT_BUFSIZE
];
972 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
973 is_string(":origin PRIVMSG #test test test :test test", output
, MSG
);
977 static void short_tag1_too_long_value(void)
979 const struct MsgBuf msgbuf
= {
982 { .key
= "x", .value
= MKTEXT(509), .capmask
= 1 },
990 .para
= { "test", "test", "test test" },
992 char output
[OUTPUT_BUFSIZE
];
994 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
995 is_string(":origin PRIVMSG #test test test :test test", output
, MSG
);
999 static void long_tag2a_no_value(void)
1001 const struct MsgBuf msgbuf
= {
1004 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1005 { .key
= MKTEXT(508), .value
= NULL
, .capmask
= 1 },
1013 .para
= { "test", "test", "test test" },
1015 char output
[OUTPUT_BUFSIZE
];
1017 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1021 strcat(tmp
, MKTEXT(508));
1023 is_int(512, strlen(tmp
), MSG
);
1024 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1026 is_string(tmp
, output
, MSG
);
1030 static void long_tag2b_no_value(void)
1032 const struct MsgBuf msgbuf
= {
1035 { .key
= "a", .value
= "", .capmask
= 1 },
1036 { .key
= MKTEXT(507), .value
= NULL
, .capmask
= 1 },
1044 .para
= { "test", "test", "test test" },
1046 char output
[OUTPUT_BUFSIZE
];
1048 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1051 strcpy(tmp
, "@a=;");
1052 strcat(tmp
, MKTEXT(507));
1054 is_int(512, strlen(tmp
), MSG
);
1055 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1057 is_string(tmp
, output
, MSG
);
1061 static void long_tag2c_no_value(void)
1063 const struct MsgBuf msgbuf
= {
1066 { .key
= "a", .value
= "b", .capmask
= 1 },
1067 { .key
= MKTEXT(506), .value
= NULL
, .capmask
= 1 },
1075 .para
= { "test", "test", "test test" },
1077 char output
[OUTPUT_BUFSIZE
];
1079 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1082 strcpy(tmp
, "@a=b;");
1083 strcat(tmp
, MKTEXT(506));
1085 is_int(512, strlen(tmp
), MSG
);
1086 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1088 is_string(tmp
, output
, MSG
);
1092 static void long_tag2a_empty_value(void)
1094 const struct MsgBuf msgbuf
= {
1097 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1098 { .key
= MKTEXT(507), .value
= "", .capmask
= 1 },
1106 .para
= { "test", "test", "test test" },
1108 char output
[OUTPUT_BUFSIZE
];
1110 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1114 strcat(tmp
, MKTEXT(507));
1116 is_int(512, strlen(tmp
), MSG
);
1117 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1119 is_string(tmp
, output
, MSG
);
1123 static void long_tag2b_empty_value(void)
1125 const struct MsgBuf msgbuf
= {
1128 { .key
= "a", .value
= "", .capmask
= 1 },
1129 { .key
= MKTEXT(506), .value
= "", .capmask
= 1 },
1137 .para
= { "test", "test", "test test" },
1139 char output
[OUTPUT_BUFSIZE
];
1141 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1144 strcpy(tmp
, "@a=;");
1145 strcat(tmp
, MKTEXT(506));
1147 is_int(512, strlen(tmp
), MSG
);
1148 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1150 is_string(tmp
, output
, MSG
);
1154 static void long_tag2c_empty_value(void)
1156 const struct MsgBuf msgbuf
= {
1159 { .key
= "a", .value
= "b", .capmask
= 1 },
1160 { .key
= MKTEXT(505), .value
= "", .capmask
= 1 },
1168 .para
= { "test", "test", "test test" },
1170 char output
[OUTPUT_BUFSIZE
];
1172 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1175 strcpy(tmp
, "@a=b;");
1176 strcat(tmp
, MKTEXT(505));
1178 is_int(512, strlen(tmp
), MSG
);
1179 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1181 is_string(tmp
, output
, MSG
);
1185 static void long_tag2a_short_value(void)
1187 const struct MsgBuf msgbuf
= {
1190 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1191 { .key
= MKTEXT(506), .value
= "x", .capmask
= 1 },
1199 .para
= { "test", "test", "test test" },
1201 char output
[OUTPUT_BUFSIZE
];
1203 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1207 strcat(tmp
, MKTEXT(506));
1209 is_int(512, strlen(tmp
), MSG
);
1210 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1212 is_string(tmp
, output
, MSG
);
1216 static void long_tag2b_short_value(void)
1218 const struct MsgBuf msgbuf
= {
1221 { .key
= "a", .value
= "", .capmask
= 1 },
1222 { .key
= MKTEXT(505), .value
= "x", .capmask
= 1 },
1230 .para
= { "test", "test", "test test" },
1232 char output
[OUTPUT_BUFSIZE
];
1234 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1237 strcpy(tmp
, "@a=;");
1238 strcat(tmp
, MKTEXT(505));
1240 is_int(512, strlen(tmp
), MSG
);
1241 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1243 is_string(tmp
, output
, MSG
);
1247 static void long_tag2c_short_value(void)
1249 const struct MsgBuf msgbuf
= {
1252 { .key
= "a", .value
= "b", .capmask
= 1 },
1253 { .key
= MKTEXT(504), .value
= "x", .capmask
= 1 },
1261 .para
= { "test", "test", "test test" },
1263 char output
[OUTPUT_BUFSIZE
];
1265 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1268 strcpy(tmp
, "@a=b;");
1269 strcat(tmp
, MKTEXT(504));
1271 is_int(512, strlen(tmp
), MSG
);
1272 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1274 is_string(tmp
, output
, MSG
);
1278 static void short_tag2a_long_value(void)
1280 const struct MsgBuf msgbuf
= {
1283 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1284 { .key
= "x", .value
= MKTEXT(506), .capmask
= 1 },
1292 .para
= { "test", "test", "test test" },
1294 char output
[OUTPUT_BUFSIZE
];
1296 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1299 strcpy(tmp
, "@a;x=");
1300 strcat(tmp
, MKTEXT(506));
1302 is_int(512, strlen(tmp
), MSG
);
1303 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1305 is_string(tmp
, output
, MSG
);
1309 static void short_tag2b_long_value(void)
1311 const struct MsgBuf msgbuf
= {
1314 { .key
= "a", .value
= "", .capmask
= 1 },
1315 { .key
= "x", .value
= MKTEXT(505), .capmask
= 1 },
1323 .para
= { "test", "test", "test test" },
1325 char output
[OUTPUT_BUFSIZE
];
1327 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1330 strcpy(tmp
, "@a=;x=");
1331 strcat(tmp
, MKTEXT(505));
1333 is_int(512, strlen(tmp
), MSG
);
1334 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1336 is_string(tmp
, output
, MSG
);
1340 static void short_tag2c_long_value(void)
1342 const struct MsgBuf msgbuf
= {
1345 { .key
= "a", .value
= "b", .capmask
= 1 },
1346 { .key
= "x", .value
= MKTEXT(504), .capmask
= 1 },
1354 .para
= { "test", "test", "test test" },
1356 char output
[OUTPUT_BUFSIZE
];
1358 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1361 strcpy(tmp
, "@a=b;x=");
1362 strcat(tmp
, MKTEXT(504));
1364 is_int(512, strlen(tmp
), MSG
);
1365 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1367 is_string(tmp
, output
, MSG
);
1371 static void too_long_tag2a_no_value(void)
1373 const struct MsgBuf msgbuf
= {
1376 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1377 { .key
= MKTEXT(509), .value
= NULL
, .capmask
= 1 },
1385 .para
= { "test", "test", "test test" },
1387 char output
[OUTPUT_BUFSIZE
];
1389 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1390 is_string("@a :origin PRIVMSG #test test test :test test", output
, MSG
);
1394 static void too_long_tag2b_no_value(void)
1396 const struct MsgBuf msgbuf
= {
1399 { .key
= "a", .value
= "", .capmask
= 1 },
1400 { .key
= MKTEXT(508), .value
= NULL
, .capmask
= 1 },
1408 .para
= { "test", "test", "test test" },
1410 char output
[OUTPUT_BUFSIZE
];
1412 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1413 is_string("@a= :origin PRIVMSG #test test test :test test", output
, MSG
);
1417 static void too_long_tag2c_no_value(void)
1419 const struct MsgBuf msgbuf
= {
1422 { .key
= "a", .value
= "b", .capmask
= 1 },
1423 { .key
= MKTEXT(507), .value
= NULL
, .capmask
= 1 },
1431 .para
= { "test", "test", "test test" },
1433 char output
[OUTPUT_BUFSIZE
];
1435 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1436 is_string("@a=b :origin PRIVMSG #test test test :test test", output
, MSG
);
1440 static void too_long_tag2a_empty_value(void)
1442 const struct MsgBuf msgbuf
= {
1445 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1446 { .key
= MKTEXT(508), .value
= "", .capmask
= 1 },
1454 .para
= { "test", "test", "test test" },
1456 char output
[OUTPUT_BUFSIZE
];
1458 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1459 is_string("@a :origin PRIVMSG #test test test :test test", output
, MSG
);
1463 static void too_long_tag2b_empty_value(void)
1465 const struct MsgBuf msgbuf
= {
1468 { .key
= "a", .value
= "", .capmask
= 1 },
1469 { .key
= MKTEXT(507), .value
= "", .capmask
= 1 },
1477 .para
= { "test", "test", "test test" },
1479 char output
[OUTPUT_BUFSIZE
];
1481 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1482 is_string("@a= :origin PRIVMSG #test test test :test test", output
, MSG
);
1486 static void too_long_tag2c_empty_value(void)
1488 const struct MsgBuf msgbuf
= {
1491 { .key
= "a", .value
= "b", .capmask
= 1 },
1492 { .key
= MKTEXT(506), .value
= "", .capmask
= 1 },
1500 .para
= { "test", "test", "test test" },
1502 char output
[OUTPUT_BUFSIZE
];
1504 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1505 is_string("@a=b :origin PRIVMSG #test test test :test test", output
, MSG
);
1509 static void too_long_tag2a_short_value(void)
1511 const struct MsgBuf msgbuf
= {
1514 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1515 { .key
= MKTEXT(507), .value
= "x", .capmask
= 1 },
1523 .para
= { "test", "test", "test test" },
1525 char output
[OUTPUT_BUFSIZE
];
1527 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1528 is_string("@a :origin PRIVMSG #test test test :test test", output
, MSG
);
1532 static void too_long_tag2b_short_value(void)
1534 const struct MsgBuf msgbuf
= {
1537 { .key
= "a", .value
= "", .capmask
= 1 },
1538 { .key
= MKTEXT(506), .value
= "x", .capmask
= 1 },
1546 .para
= { "test", "test", "test test" },
1548 char output
[OUTPUT_BUFSIZE
];
1550 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1551 is_string("@a= :origin PRIVMSG #test test test :test test", output
, MSG
);
1555 static void too_long_tag2c_short_value(void)
1557 const struct MsgBuf msgbuf
= {
1560 { .key
= "a", .value
= "b", .capmask
= 1 },
1561 { .key
= MKTEXT(505), .value
= "x", .capmask
= 1 },
1569 .para
= { "test", "test", "test test" },
1571 char output
[OUTPUT_BUFSIZE
];
1573 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1574 is_string("@a=b :origin PRIVMSG #test test test :test test", output
, MSG
);
1578 static void short_tag2a_too_long_value(void)
1580 const struct MsgBuf msgbuf
= {
1583 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1584 { .key
= "x", .value
= MKTEXT(507), .capmask
= 1 },
1592 .para
= { "test", "test", "test test" },
1594 char output
[OUTPUT_BUFSIZE
];
1596 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1597 is_string("@a :origin PRIVMSG #test test test :test test", output
, MSG
);
1601 static void short_tag2b_too_long_value(void)
1603 const struct MsgBuf msgbuf
= {
1606 { .key
= "a", .value
= "", .capmask
= 1 },
1607 { .key
= "x", .value
= MKTEXT(506), .capmask
= 1 },
1615 .para
= { "test", "test", "test test" },
1617 char output
[OUTPUT_BUFSIZE
];
1619 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1620 is_string("@a= :origin PRIVMSG #test test test :test test", output
, MSG
);
1624 static void short_tag2c_too_long_value(void)
1626 const struct MsgBuf msgbuf
= {
1629 { .key
= "a", .value
= "b", .capmask
= 1 },
1630 { .key
= "x", .value
= MKTEXT(505), .capmask
= 1 },
1638 .para
= { "test", "test", "test test" },
1640 char output
[OUTPUT_BUFSIZE
];
1642 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1643 is_string("@a=b :origin PRIVMSG #test test test :test test", output
, MSG
);
1647 static void escape_test(void)
1649 const struct MsgBuf msgbuf
= {
1652 { .key
= "tag1", .value
= ":; \\\r\n", .capmask
= 1 },
1653 { .key
= "tag2", .value
= "^:^;^ ^\\^\r^\n^", .capmask
= 1 },
1654 { .key
= "tag3", .value
= ":", .capmask
= 1 },
1655 { .key
= "tag4", .value
= ";", .capmask
= 1 },
1656 { .key
= "tag5", .value
= "\\", .capmask
= 1 },
1657 { .key
= "tag6", .value
= " ", .capmask
= 1 },
1665 .para
= { "test", "test", "test test" },
1667 char output
[OUTPUT_BUFSIZE
];
1669 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1670 is_string("@tag1=:\\:\\s\\\\\\r\\n;tag2=^:^\\:^\\s^\\\\^\\r^\\n^;tag3=:;tag4=\\:;tag5=\\\\;tag6=\\s :origin PRIVMSG #test test test :test test", output
, MSG
);
1674 static void escape_test_8bit(void)
1676 const struct MsgBuf msgbuf
= {
1679 { .key
= "tag1", .value
= "\176\177\178\376\377", .capmask
= 1 },
1687 .para
= { "test", "test", "test test" },
1689 char output
[OUTPUT_BUFSIZE
];
1691 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1692 is_string("@tag1=\176\177\178\376\377 :origin PRIVMSG #test test test :test test", output
, MSG
);
1696 static void long_para1a(void)
1698 const struct MsgBuf msgbuf
= {
1706 .para
= { MKTEXT(488) },
1708 char output
[OUTPUT_BUFSIZE
];
1710 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1713 strcpy(tmp
, ":origin PRIVMSG #test ");
1714 strcat(tmp
, MKTEXT(488));
1715 is_int(510, strlen(tmp
), MSG
);
1717 is_string(tmp
, output
, MSG
);
1721 static void too_long_para1a(void)
1723 const struct MsgBuf msgbuf
= {
1731 .para
= { MKTEXT(489) },
1733 char output
[OUTPUT_BUFSIZE
];
1735 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1738 strcpy(tmp
, ":origin PRIVMSG #test ");
1739 strcat(tmp
, MKTEXT(489));
1740 tmp
[strlen(tmp
) - 1] = 0;
1741 is_int(510, strlen(tmp
), MSG
);
1743 is_string(tmp
, output
, MSG
);
1747 static void long_para1b(void)
1750 const struct MsgBuf msgbuf
= {
1760 char output
[OUTPUT_BUFSIZE
];
1762 /* make second-last char ' ' so that a ':' prefix is required */
1763 strcpy(input
, MKTEXT(487));
1764 input
[strlen(input
) - 2] = ' ';
1766 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1769 strcpy(tmp
, ":origin PRIVMSG #test :");
1770 strcat(tmp
, MKTEXT(487));
1771 tmp
[strlen(tmp
) - 2] = ' ';
1772 is_int(510, strlen(tmp
), MSG
);
1774 is_string(tmp
, output
, MSG
);
1778 static void too_long_para1b(void)
1781 const struct MsgBuf msgbuf
= {
1791 char output
[OUTPUT_BUFSIZE
];
1793 /* make second-last char ' ' so that a ':' prefix is required */
1794 strcpy(input
, MKTEXT(488));
1795 input
[strlen(input
) - 3] = ' ';
1797 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1800 strcpy(tmp
, ":origin PRIVMSG #test :");
1801 strcat(tmp
, MKTEXT(488));
1802 tmp
[strlen(tmp
) - 3] = ' ';
1803 tmp
[strlen(tmp
) - 1] = 0;
1804 is_int(510, strlen(tmp
), MSG
);
1806 is_string(tmp
, output
, MSG
);
1810 static void long_para2a(void)
1812 const struct MsgBuf msgbuf
= {
1820 .para
= { "test", MKTEXT(483) },
1822 char output
[OUTPUT_BUFSIZE
];
1824 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1827 strcpy(tmp
, ":origin PRIVMSG #test test ");
1828 strcat(tmp
, MKTEXT(483));
1829 is_int(510, strlen(tmp
), MSG
);
1831 is_string(tmp
, output
, MSG
);
1835 static void too_long_para2a(void)
1837 const struct MsgBuf msgbuf
= {
1845 .para
= { "test", MKTEXT(484) },
1847 char output
[OUTPUT_BUFSIZE
];
1849 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1852 strcpy(tmp
, ":origin PRIVMSG #test test ");
1853 strcat(tmp
, MKTEXT(484));
1854 tmp
[strlen(tmp
) - 1] = 0;
1855 is_int(510, strlen(tmp
), MSG
);
1857 is_string(tmp
, output
, MSG
);
1861 static void long_para2b(void)
1864 const struct MsgBuf msgbuf
= {
1872 .para
= { "test", input
},
1874 char output
[OUTPUT_BUFSIZE
];
1876 /* make second-last char ' ' so that a ':' prefix is required */
1877 strcpy(input
, MKTEXT(482));
1878 input
[strlen(input
) - 2] = ' ';
1880 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1883 strcpy(tmp
, ":origin PRIVMSG #test test :");
1884 strcat(tmp
, MKTEXT(482));
1885 tmp
[strlen(tmp
) - 2] = ' ';
1886 is_int(510, strlen(tmp
), MSG
);
1888 is_string(tmp
, output
, MSG
);
1892 static void too_long_para2b(void)
1895 const struct MsgBuf msgbuf
= {
1903 .para
= { "test", input
},
1905 char output
[OUTPUT_BUFSIZE
];
1907 /* make second-last char ' ' so that a ':' prefix is required */
1908 strcpy(input
, MKTEXT(483));
1909 input
[strlen(input
) - 3] = ' ';
1911 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1914 strcpy(tmp
, ":origin PRIVMSG #test test :");
1915 strcat(tmp
, MKTEXT(483));
1916 tmp
[strlen(tmp
) - 3] = ' ';
1917 tmp
[strlen(tmp
) - 1] = 0;
1918 is_int(510, strlen(tmp
), MSG
);
1920 is_string(tmp
, output
, MSG
);
1924 static void long_para3a(void)
1926 const struct MsgBuf msgbuf
= {
1934 .para
= { "test1", "test2", MKTEXT(476) },
1936 char output
[OUTPUT_BUFSIZE
];
1938 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1941 strcpy(tmp
, ":origin PRIVMSG #test test1 test2 ");
1942 strcat(tmp
, MKTEXT(476));
1943 is_int(510, strlen(tmp
), MSG
);
1945 is_string(tmp
, output
, MSG
);
1949 static void too_long_para3a(void)
1951 const struct MsgBuf msgbuf
= {
1959 .para
= { "test1", "test2", MKTEXT(477) },
1961 char output
[OUTPUT_BUFSIZE
];
1963 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1966 strcpy(tmp
, ":origin PRIVMSG #test test1 test2 ");
1967 strcat(tmp
, MKTEXT(477));
1968 tmp
[strlen(tmp
) - 1] = 0;
1969 is_int(510, strlen(tmp
), MSG
);
1971 is_string(tmp
, output
, MSG
);
1975 static void long_para3b(void)
1978 const struct MsgBuf msgbuf
= {
1986 .para
= { "test1", "test2", input
},
1988 char output
[OUTPUT_BUFSIZE
];
1990 /* make second-last char ' ' so that a ':' prefix is required */
1991 strcpy(input
, MKTEXT(475));
1992 input
[strlen(input
) - 2] = ' ';
1994 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1997 strcpy(tmp
, ":origin PRIVMSG #test test1 test2 :");
1998 strcat(tmp
, MKTEXT(475));
1999 tmp
[strlen(tmp
) - 2] = ' ';
2000 is_int(510, strlen(tmp
), MSG
);
2002 is_string(tmp
, output
, MSG
);
2006 static void too_long_para3b(void)
2009 const struct MsgBuf msgbuf
= {
2017 .para
= { "test1", "test2", input
},
2019 char output
[OUTPUT_BUFSIZE
];
2021 /* make second-last char ' ' so that a ':' prefix is required */
2022 strcpy(input
, MKTEXT(476));
2023 input
[strlen(input
) - 3] = ' ';
2025 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2028 strcpy(tmp
, ":origin PRIVMSG #test test1 test2 :");
2029 strcat(tmp
, MKTEXT(476));
2030 tmp
[strlen(tmp
) - 3] = ' ';
2031 tmp
[strlen(tmp
) - 1] = 0;
2032 is_int(510, strlen(tmp
), MSG
);
2034 is_string(tmp
, output
, MSG
);
2038 static void long_para15a(void)
2040 const struct MsgBuf msgbuf
= {
2048 .para
= { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", MKTEXT(399) },
2050 char output
[OUTPUT_BUFSIZE
];
2052 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2055 strcpy(tmp
, ":origin PRIVMSG #test test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 ");
2056 strcat(tmp
, MKTEXT(399));
2057 is_int(510, strlen(tmp
), MSG
);
2059 is_string(tmp
, output
, MSG
);
2063 static void too_long_para15a(void)
2065 const struct MsgBuf msgbuf
= {
2073 .para
= { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", MKTEXT(400) },
2075 char output
[OUTPUT_BUFSIZE
];
2077 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2080 strcpy(tmp
, ":origin PRIVMSG #test test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 ");
2081 strcat(tmp
, MKTEXT(400));
2082 tmp
[strlen(tmp
) - 1] = 0;
2083 is_int(510, strlen(tmp
), MSG
);
2085 is_string(tmp
, output
, MSG
);
2089 static void long_para15b(void)
2092 const struct MsgBuf msgbuf
= {
2100 .para
= { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", input
},
2102 char output
[OUTPUT_BUFSIZE
];
2104 /* make second-last char ' ' so that a ':' prefix is required */
2105 strcpy(input
, MKTEXT(398));
2106 input
[strlen(input
) - 2] = ' ';
2108 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2111 strcpy(tmp
, ":origin PRIVMSG #test test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 :");
2112 strcat(tmp
, MKTEXT(398));
2113 tmp
[strlen(tmp
) - 2] = ' ';
2114 is_int(510, strlen(tmp
), MSG
);
2116 is_string(tmp
, output
, MSG
);
2120 static void too_long_para15b(void)
2123 const struct MsgBuf msgbuf
= {
2131 .para
= { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", input
},
2133 char output
[OUTPUT_BUFSIZE
];
2135 /* make second-last char ' ' so that a ':' prefix is required */
2136 strcpy(input
, MKTEXT(399));
2137 input
[strlen(input
) - 3] = ' ';
2139 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2142 strcpy(tmp
, ":origin PRIVMSG #test test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 :");
2143 strcat(tmp
, MKTEXT(399));
2144 tmp
[strlen(tmp
) - 3] = ' ';
2145 tmp
[strlen(tmp
) - 1] = 0;
2146 is_int(510, strlen(tmp
), MSG
);
2148 is_string(tmp
, output
, MSG
);
2152 static const struct MsgBuf small_buffer_tags_msgbuf
= {
2155 { .key
= "tag1", .value
= "value1", .capmask
= 1 },
2156 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
2157 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
2158 { .key
= "tag4", .value
= "value4", .capmask
= 1 },
2159 { .key
= "tag5", .value
= "value5", .capmask
= 1 },
2160 { .key
= "tag6", .value
= "value6", .capmask
= 1 },
2161 { .key
= "tag7", .value
= "value7", .capmask
= 1 },
2162 { .key
= "tag8", .value
= "value8", .capmask
= 1 },
2163 { .key
= "tag9", .value
= "value9", .capmask
= 1 },
2164 { .key
= "tag10", .value
= "value10", .capmask
= 1 },
2165 { .key
= "tag11", .value
= "value11", .capmask
= 1 },
2166 { .key
= "tag12", .value
= "value12", .capmask
= 1 },
2167 { .key
= "tag13", .value
= "value13", .capmask
= 1 },
2168 { .key
= "tag14", .value
= "value14", .capmask
= 1 },
2169 { .key
= "tag15", .value
= "value15", .capmask
= 1 },
2177 .para
= { "test", "test", "test test" },
2180 static void small_buffer_tags_2_remaining_for_para(void)
2184 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_tags_msgbuf
, 1), MSG
)) {
2185 is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag5=value5;tag6=value6;tag7=value7;tag8=value8 :o", output
, MSG
);
2189 static void small_buffer_tags_1_remaining_for_para(void)
2193 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_tags_msgbuf
, 1), MSG
)) {
2194 is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag5=value5;tag6=value6;tag7=value7;tag8=value8 :", output
, MSG
);
2198 static void small_buffer_tags_0_remaining_for_para(void)
2202 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_tags_msgbuf
, 1), MSG
)) {
2203 is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag5=value5;tag6=value6;tag7=value7;tag8=value8 ", output
, MSG
);
2207 static void small_buffer_tags_X_remaining_for_para(void)
2211 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_tags_msgbuf
, 1), MSG
)) {
2212 // Must leave enough space for a tag but not enough space for the tag
2214 is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag5=value5;tag6=value6;tag7=value7 :origin PRI", output
, MSG
);
2218 static const struct MsgBuf small_buffer_a_msgbuf
= {
2221 { .key
= "a", .value
= NULL
, .capmask
= 1 },
2222 { .key
= "c", .value
= "d", .capmask
= 1 },
2223 { .key
= "e", .value
= "f", .capmask
= 1 },
2231 .para
= { "test", "test", "test test" },
2234 static const struct MsgBuf small_buffer_b_msgbuf
= {
2237 { .key
= "a", .value
= "b", .capmask
= 1 },
2238 { .key
= "c", .value
= "d", .capmask
= 1 },
2239 { .key
= "e", .value
= "f", .capmask
= 1 },
2247 .para
= { "test", "test", "test test" },
2250 static void small_buffer1(void)
2254 memset(output
, 0, sizeof(output
));
2255 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2256 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2257 is_string("", output
, MSG
);
2260 memset(output
, 0, sizeof(output
));
2261 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2262 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2263 is_string("", output
, MSG
);
2267 static void small_buffer2(void)
2271 memset(output
, 0, sizeof(output
));
2272 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2273 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2274 is_string(":", output
, MSG
);
2277 memset(output
, 0, sizeof(output
));
2278 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2279 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2280 is_string(":", output
, MSG
);
2284 static void small_buffer3(void)
2288 memset(output
, 0, sizeof(output
));
2289 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2290 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2291 is_string(":o", output
, MSG
);
2294 memset(output
, 0, sizeof(output
));
2295 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2296 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2297 is_string(":o", output
, MSG
);
2301 static void small_buffer4(void)
2305 memset(output
, 0, sizeof(output
));
2306 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2307 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2308 is_string("@a ", output
, MSG
);
2311 memset(output
, 0, sizeof(output
));
2312 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2313 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2314 is_string(":or", output
, MSG
);
2318 static void small_buffer5(void)
2322 memset(output
, 0, sizeof(output
));
2323 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2324 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2325 is_string("@a :", output
, MSG
);
2328 memset(output
, 0, sizeof(output
));
2329 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2330 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2331 is_string(":ori", output
, MSG
);
2335 static void small_buffer6(void)
2339 memset(output
, 0, sizeof(output
));
2340 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2341 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2342 is_string("@a :o", output
, MSG
);
2345 memset(output
, 0, sizeof(output
));
2346 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2347 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2348 is_string("@a=b ", output
, MSG
);
2352 static void small_buffer7(void)
2356 memset(output
, 0, sizeof(output
));
2357 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2358 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2359 is_string("@a :or", output
, MSG
);
2362 memset(output
, 0, sizeof(output
));
2363 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2364 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2365 is_string("@a=b :", output
, MSG
);
2369 static void small_buffer8(void)
2373 memset(output
, 0, sizeof(output
));
2374 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2375 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2376 is_string("@a;c=d ", output
, MSG
);
2379 memset(output
, 0, sizeof(output
));
2380 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2381 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2382 is_string("@a=b :o", output
, MSG
);
2386 static void small_buffer9(void)
2390 memset(output
, 0, sizeof(output
));
2391 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2392 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2393 is_string("@a;c=d :", output
, MSG
);
2396 memset(output
, 0, sizeof(output
));
2397 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2398 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2399 is_string("@a=b :or", output
, MSG
);
2403 static void small_buffer10(void)
2407 memset(output
, 0, sizeof(output
));
2408 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2409 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2410 is_string("@a;c=d :o", output
, MSG
);
2413 memset(output
, 0, sizeof(output
));
2414 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2415 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2416 is_string("@a=b;c=d ", output
, MSG
);
2420 static void small_buffer11(void)
2424 memset(output
, 0, sizeof(output
));
2425 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2426 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2427 is_string("@a;c=d :or", output
, MSG
);
2430 memset(output
, 0, sizeof(output
));
2431 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2432 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2433 is_string("@a=b;c=d :", output
, MSG
);
2437 static void small_buffer12(void)
2441 memset(output
, 0, sizeof(output
));
2442 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2443 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2444 is_string("@a;c=d;e=f ", output
, MSG
);
2447 memset(output
, 0, sizeof(output
));
2448 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2449 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2450 is_string("@a=b;c=d :o", output
, MSG
);
2454 static void small_buffer13(void)
2458 memset(output
, 0, sizeof(output
));
2459 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2460 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2461 is_string("@a;c=d;e=f :", output
, MSG
);
2464 memset(output
, 0, sizeof(output
));
2465 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2466 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2467 is_string("@a=b;c=d :or", output
, MSG
);
2471 static void small_buffer14(void)
2475 memset(output
, 0, sizeof(output
));
2476 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2477 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2478 is_string("@a;c=d;e=f :o", output
, MSG
);
2481 memset(output
, 0, sizeof(output
));
2482 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2483 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2484 is_string("@a=b;c=d;e=f ", output
, MSG
);
2488 static void small_buffer15(void)
2492 memset(output
, 0, sizeof(output
));
2493 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_a_msgbuf
, 1), MSG
)) {
2494 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2495 is_string("@a;c=d;e=f :or", output
, MSG
);
2498 memset(output
, 0, sizeof(output
));
2499 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &small_buffer_b_msgbuf
, 1), MSG
)) {
2500 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2501 is_string("@a=b;c=d;e=f :", output
, MSG
);
2505 static const struct MsgBuf long_tags_small_buffer_msgbuf
= {
2508 { .key
= MKTEXT(510), .value
= NULL
, .capmask
= 1 },
2516 .para
= { "test", "test", "test test" },
2519 #define LONG_TAGS "@10abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx"\
2520 "yzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcbaZYXWVUT"\
2521 "SRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"\
2522 "QRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCB"\
2523 "AzyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefgh"\
2524 "ijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
2526 static void long_tags_small_buffer0(void)
2528 char output
[TAGSLEN
+ 0 + 1];
2530 memset(output
, 0, sizeof(output
));
2531 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &long_tags_small_buffer_msgbuf
, 1), MSG
)) {
2532 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2533 is_string(LONG_TAGS
"", output
, MSG
);
2537 static void long_tags_small_buffer1(void)
2539 char output
[TAGSLEN
+ 1 + 1];
2541 memset(output
, 0, sizeof(output
));
2542 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &long_tags_small_buffer_msgbuf
, 1), MSG
)) {
2543 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2544 is_string(LONG_TAGS
":", output
, MSG
);
2548 static void long_tags_small_buffer2(void)
2550 char output
[TAGSLEN
+ 2 + 1];
2552 memset(output
, 0, sizeof(output
));
2553 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &long_tags_small_buffer_msgbuf
, 1), MSG
)) {
2554 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2555 is_string(LONG_TAGS
":o", output
, MSG
);
2559 static void long_tags_small_buffer3(void)
2561 char output
[TAGSLEN
+ 3 + 1];
2563 memset(output
, 0, sizeof(output
));
2564 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &long_tags_small_buffer_msgbuf
, 1), MSG
)) {
2565 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2566 is_string(LONG_TAGS
":or", output
, MSG
);
2570 static void long_tags_small_buffer4(void)
2572 char output
[TAGSLEN
+ 4 + 1];
2574 memset(output
, 0, sizeof(output
));
2575 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &long_tags_small_buffer_msgbuf
, 1), MSG
)) {
2576 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2577 is_string(LONG_TAGS
":ori", output
, MSG
);
2581 static void long_tags_small_buffer5(void)
2583 char output
[TAGSLEN
+ 5 + 1];
2585 memset(output
, 0, sizeof(output
));
2586 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &long_tags_small_buffer_msgbuf
, 1), MSG
)) {
2587 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2588 is_string(LONG_TAGS
":orig", output
, MSG
);
2592 static const struct MsgBuf no_tags_small_buffer_msgbuf
= {
2600 .para
= { "test", "test", "test test" },
2603 static void no_tags_small_buffer1(void)
2607 memset(output
, 0, sizeof(output
));
2608 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &no_tags_small_buffer_msgbuf
, 1), MSG
)) {
2609 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2610 is_string("", output
, MSG
);
2614 static void no_tags_small_buffer2(void)
2618 memset(output
, 0, sizeof(output
));
2619 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &no_tags_small_buffer_msgbuf
, 1), MSG
)) {
2620 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2621 is_string(":", output
, MSG
);
2625 static void no_tags_small_buffer3(void)
2629 memset(output
, 0, sizeof(output
));
2630 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &no_tags_small_buffer_msgbuf
, 1), MSG
)) {
2631 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2632 is_string(":o", output
, MSG
);
2636 static void no_tags_small_buffer4(void)
2640 memset(output
, 0, sizeof(output
));
2641 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &no_tags_small_buffer_msgbuf
, 1), MSG
)) {
2642 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2643 is_string(":or", output
, MSG
);
2647 static void no_tags_small_buffer5(void)
2651 memset(output
, 0, sizeof(output
));
2652 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &no_tags_small_buffer_msgbuf
, 1), MSG
)) {
2653 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2654 is_string(":ori", output
, MSG
);
2658 static void no_tags_small_buffer6(void)
2662 memset(output
, 0, sizeof(output
));
2663 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &no_tags_small_buffer_msgbuf
, 1), MSG
)) {
2664 is_int(sizeof(output
) - 1, strlen(output
), MSG
);
2665 is_string(":orig", output
, MSG
);
2669 static void para_no_origin(void)
2671 const struct MsgBuf msgbuf
= {
2679 .para
= { "test1", "test2", "test3 test4" },
2681 char output
[OUTPUT_BUFSIZE
];
2683 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2684 is_string(":me.name. PRIVMSG #test test1 test2 :test3 test4", output
, MSG
);
2688 static void para_no_cmd(void)
2690 const struct MsgBuf msgbuf
= {
2698 .para
= { "test1", "test2", "test3 test4" },
2700 char output
[OUTPUT_BUFSIZE
];
2702 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2703 is_string(":origin #test test1 test2 :test3 test4", output
, MSG
);
2707 static void para_no_target(void)
2709 const struct MsgBuf msgbuf
= {
2717 .para
= { "test1", "test2", "test3 test4" },
2719 char output
[OUTPUT_BUFSIZE
];
2721 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2722 is_string(":origin PRIVMSG test1 test2 :test3 test4", output
, MSG
);
2726 static void para_no_origin_no_cmd(void)
2728 const struct MsgBuf msgbuf
= {
2736 .para
= { "test1", "test2", "test3 test4" },
2738 char output
[OUTPUT_BUFSIZE
];
2740 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2741 is_string(":me.name. #test test1 test2 :test3 test4", output
, MSG
);
2745 static void para_no_origin_no_target(void)
2747 const struct MsgBuf msgbuf
= {
2755 .para
= { "test1", "test2", "test3 test4" },
2757 char output
[OUTPUT_BUFSIZE
];
2759 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2760 is_string(":me.name. PRIVMSG test1 test2 :test3 test4", output
, MSG
);
2764 static void para_no_cmd_no_target(void)
2766 const struct MsgBuf msgbuf
= {
2774 .para
= { "test1", "test2", "test3 test4" },
2776 char output
[OUTPUT_BUFSIZE
];
2778 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2779 is_string(":origin test1 test2 :test3 test4", output
, MSG
);
2783 static void para_no_origin_no_cmd_no_target(void)
2785 const struct MsgBuf msgbuf
= {
2793 .para
= { "test1", "test2", "test3 test4" },
2795 char output
[OUTPUT_BUFSIZE
];
2797 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2798 is_string(":me.name. test1 test2 :test3 test4", output
, MSG
);
2802 int main(int argc
, char *argv
[])
2804 memset(&me
, 0, sizeof(me
));
2805 strcpy(me
.name
, "me.name.");
2809 is_int(512, TAGSLEN
, MSG
);
2810 is_int(510, DATALEN
, MSG
);
2811 is_int(512 + 510 + 1, EXT_BUFSIZE
, MSG
);
2816 basic_tags15_capmask1();
2817 basic_tags15_capmask2();
2822 long_tag1_no_value();
2823 long_tag1_empty_value();
2824 long_tag1_short_value();
2825 short_tag1_long_value();
2826 short_tag1_long_value();
2827 short_tag1_long_value();
2829 too_long_tag1_no_value();
2830 too_long_tag1_empty_value();
2831 too_long_tag1_short_value();
2832 short_tag1_too_long_value();
2833 short_tag1_too_long_value();
2834 short_tag1_too_long_value();
2836 long_tag2a_no_value();
2837 long_tag2b_no_value();
2838 long_tag2c_no_value();
2839 long_tag2a_empty_value();
2840 long_tag2b_empty_value();
2841 long_tag2c_empty_value();
2842 long_tag2a_short_value();
2843 long_tag2b_short_value();
2844 long_tag2c_short_value();
2845 short_tag2a_long_value();
2846 short_tag2b_long_value();
2847 short_tag2c_long_value();
2849 too_long_tag2a_no_value();
2850 too_long_tag2b_no_value();
2851 too_long_tag2c_no_value();
2852 too_long_tag2a_empty_value();
2853 too_long_tag2b_empty_value();
2854 too_long_tag2c_empty_value();
2855 too_long_tag2a_short_value();
2856 too_long_tag2b_short_value();
2857 too_long_tag2c_short_value();
2858 short_tag2a_too_long_value();
2859 short_tag2b_too_long_value();
2860 short_tag2c_too_long_value();
2862 too_long_for_tag2a_0remaining();
2863 too_long_for_tag2a_1remaining();
2864 too_long_for_tag2a_2remaining();
2865 too_long_for_tag2a_3remaining();
2866 too_long_for_tag2a_3short();
2867 too_long_for_tag2a_2short();
2868 too_long_for_tag2a_1short();
2869 exact_space_for_tag2a();
2871 too_long_for_tag2b_0remaining();
2872 too_long_for_tag2b_1remaining();
2873 too_long_for_tag2b_2remaining();
2874 too_long_for_tag2b_3remaining();
2875 too_long_for_tag2b_3short();
2876 too_long_for_tag2b_2short();
2877 too_long_for_tag2b_1short();
2878 exact_space_for_tag2b();
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();
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();
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();
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();
2946 // TODO msgbuf_vunparse_fmt