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 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"
48 #define MKTEXT(n) &text[sizeof(text) - ((n) + 1)]
50 /* must be much larger than the intended maximum output tags/data size */
51 #define OUTPUT_BUFSIZE (EXT_BUFSIZE * 4)
53 static void basic_tags1(void)
55 const struct MsgBuf msgbuf
= {
58 { .key
= "tag", .value
= "value", .capmask
= 1 },
66 .para
= { "test", "test", "test test" },
68 char output
[OUTPUT_BUFSIZE
];
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
);
75 static void basic_tags2(void)
77 const struct MsgBuf msgbuf
= {
80 { .key
= "tag1", .value
= "value1", .capmask
= 1 },
81 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
89 .para
= { "test", "test", "test test" },
91 char output
[OUTPUT_BUFSIZE
];
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
);
98 static void basic_tags15(void)
100 const struct MsgBuf msgbuf
= {
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 },
125 .para
= { "test", "test", "test test" },
127 char output
[OUTPUT_BUFSIZE
];
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
);
134 static void basic_tags15_capmask1(void)
136 const struct MsgBuf msgbuf
= {
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 },
161 .para
= { "test", "test", "test test" },
163 char output
[OUTPUT_BUFSIZE
];
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
);
170 static void basic_tags15_capmask2(void)
172 const struct MsgBuf msgbuf
= {
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 },
197 .para
= { "test", "test", "test test" },
199 char output
[OUTPUT_BUFSIZE
];
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
);
206 static void no_tags(void)
208 const struct MsgBuf msgbuf
= {
217 .para
= { "test", "test", "test test" },
219 char output
[OUTPUT_BUFSIZE
];
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
);
226 static void empty_tag(void)
228 const struct MsgBuf msgbuf
= {
231 { .key
= "", .value
= "value", .capmask
= 1 },
239 .para
= { "test", "test", "test test" },
241 char output
[OUTPUT_BUFSIZE
];
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
);
248 static void too_long_for_tag2a_0remaining(void)
250 const struct MsgBuf msgbuf
= {
253 { .key
= MKTEXT(259), .value
= MKTEXT(250), .capmask
= 1 },
254 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
255 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
263 .para
= { "test", "test", "test test" },
265 char output
[OUTPUT_BUFSIZE
];
267 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
271 strcat(tmp
, MKTEXT(259));
273 strcat(tmp
, MKTEXT(250));
275 is_int(512, strlen(tmp
), MSG
);
276 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
278 is_string(tmp
, output
, MSG
);
282 static void too_long_for_tag2a_1remaining(void)
284 const struct MsgBuf msgbuf
= {
287 { .key
= MKTEXT(259), .value
= MKTEXT(249), .capmask
= 1 },
288 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
289 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
297 .para
= { "test", "test", "test test" },
299 char output
[OUTPUT_BUFSIZE
];
301 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
305 strcat(tmp
, MKTEXT(259));
307 strcat(tmp
, MKTEXT(249));
309 is_int(512 - 1, strlen(tmp
), MSG
);
310 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
312 is_string(tmp
, output
, MSG
);
316 static void too_long_for_tag2a_2remaining(void)
318 const struct MsgBuf msgbuf
= {
321 { .key
= MKTEXT(259), .value
= MKTEXT(248), .capmask
= 1 },
322 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
323 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
331 .para
= { "test", "test", "test test" },
333 char output
[OUTPUT_BUFSIZE
];
335 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
339 strcat(tmp
, MKTEXT(259));
341 strcat(tmp
, MKTEXT(248));
343 is_int(512 - 2, strlen(tmp
), MSG
);
344 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
346 is_string(tmp
, output
, MSG
);
350 static void too_long_for_tag2a_3remaining(void)
352 const struct MsgBuf msgbuf
= {
355 { .key
= MKTEXT(259), .value
= MKTEXT(247), .capmask
= 1 },
356 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
357 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
365 .para
= { "test", "test", "test test" },
367 char output
[OUTPUT_BUFSIZE
];
369 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
373 strcat(tmp
, MKTEXT(259));
375 strcat(tmp
, MKTEXT(247));
377 is_int(512 - 3, strlen(tmp
), MSG
);
378 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
380 is_string(tmp
, output
, MSG
);
384 static void too_long_for_tag2a_3short(void)
386 const struct MsgBuf msgbuf
= {
389 { .key
= MKTEXT(259), .value
= MKTEXT(241), .capmask
= 1 },
390 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
391 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
399 .para
= { "test", "test", "test test" },
401 char output
[OUTPUT_BUFSIZE
];
403 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
407 strcat(tmp
, MKTEXT(259));
409 strcat(tmp
, MKTEXT(241));
411 is_int(512 - 9, strlen(tmp
), MSG
);
412 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
414 is_string(tmp
, output
, MSG
);
418 static void too_long_for_tag2a_2short(void)
420 const struct MsgBuf msgbuf
= {
423 { .key
= MKTEXT(259), .value
= MKTEXT(240), .capmask
= 1 },
424 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
425 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
433 .para
= { "test", "test", "test test" },
435 char output
[OUTPUT_BUFSIZE
];
437 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
441 strcat(tmp
, MKTEXT(259));
443 strcat(tmp
, MKTEXT(240));
445 is_int(512 - 10, strlen(tmp
), MSG
);
446 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
448 is_string(tmp
, output
, MSG
);
452 static void too_long_for_tag2a_1short(void)
454 const struct MsgBuf msgbuf
= {
457 { .key
= MKTEXT(259), .value
= MKTEXT(239), .capmask
= 1 },
458 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
459 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
467 .para
= { "test", "test", "test test" },
469 char output
[OUTPUT_BUFSIZE
];
471 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
475 strcat(tmp
, MKTEXT(259));
477 strcat(tmp
, MKTEXT(239));
479 is_int(512 - 11, strlen(tmp
), MSG
);
480 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
482 is_string(tmp
, output
, MSG
);
486 static void exact_space_for_tag2a(void)
488 const struct MsgBuf msgbuf
= {
491 { .key
= MKTEXT(259), .value
= MKTEXT(238), .capmask
= 1 },
492 { .key
= "tag2", .value
= "value2", .capmask
= 1 },
493 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
501 .para
= { "test", "test", "test test" },
503 char output
[OUTPUT_BUFSIZE
];
505 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
509 strcat(tmp
, MKTEXT(259));
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");
516 is_string(tmp
, output
, MSG
);
520 static void too_long_for_tag2b_0remaining(void)
522 const struct MsgBuf msgbuf
= {
525 { .key
= MKTEXT(259), .value
= MKTEXT(250), .capmask
= 1 },
526 { .key
= "a", .value
= "b", .capmask
= 1 },
527 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
535 .para
= { "test", "test", "test test" },
537 char output
[OUTPUT_BUFSIZE
];
539 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
543 strcat(tmp
, MKTEXT(259));
545 strcat(tmp
, MKTEXT(250));
547 is_int(512, strlen(tmp
), MSG
);
548 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
550 is_string(tmp
, output
, MSG
);
554 static void too_long_for_tag2b_1remaining(void)
556 const struct MsgBuf msgbuf
= {
559 { .key
= MKTEXT(259), .value
= MKTEXT(249), .capmask
= 1 },
560 { .key
= "a", .value
= "b", .capmask
= 1 },
561 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
569 .para
= { "test", "test", "test test" },
571 char output
[OUTPUT_BUFSIZE
];
573 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
577 strcat(tmp
, MKTEXT(259));
579 strcat(tmp
, MKTEXT(249));
581 is_int(512 - 1, strlen(tmp
), MSG
);
582 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
584 is_string(tmp
, output
, MSG
);
588 static void too_long_for_tag2b_2remaining(void)
590 const struct MsgBuf msgbuf
= {
593 { .key
= MKTEXT(259), .value
= MKTEXT(248), .capmask
= 1 },
594 { .key
= "a", .value
= "b", .capmask
= 1 },
595 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
603 .para
= { "test", "test", "test test" },
605 char output
[OUTPUT_BUFSIZE
];
607 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
611 strcat(tmp
, MKTEXT(259));
613 strcat(tmp
, MKTEXT(248));
615 is_int(512 - 2, strlen(tmp
), MSG
);
616 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
618 is_string(tmp
, output
, MSG
);
622 static void too_long_for_tag2b_3remaining(void)
624 const struct MsgBuf msgbuf
= {
627 { .key
= MKTEXT(259), .value
= MKTEXT(247), .capmask
= 1 },
628 { .key
= "a", .value
= "b", .capmask
= 1 },
629 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
637 .para
= { "test", "test", "test test" },
639 char output
[OUTPUT_BUFSIZE
];
641 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
645 strcat(tmp
, MKTEXT(259));
647 strcat(tmp
, MKTEXT(247));
649 is_int(512 - 3, strlen(tmp
), MSG
);
650 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
652 is_string(tmp
, output
, MSG
);
656 static void too_long_for_tag2b_3short(void)
658 const struct MsgBuf msgbuf
= {
661 { .key
= MKTEXT(267), .value
= MKTEXT(241), .capmask
= 1 },
662 { .key
= "a", .value
= "b", .capmask
= 1 },
663 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
671 .para
= { "test", "test", "test test" },
673 char output
[OUTPUT_BUFSIZE
];
675 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
679 strcat(tmp
, MKTEXT(267));
681 strcat(tmp
, MKTEXT(241));
683 is_int(512 - 1, strlen(tmp
), MSG
);
684 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
686 is_string(tmp
, output
, MSG
);
690 static void too_long_for_tag2b_2short(void)
692 const struct MsgBuf msgbuf
= {
695 { .key
= MKTEXT(267), .value
= MKTEXT(240), .capmask
= 1 },
696 { .key
= "a", .value
= "b", .capmask
= 1 },
697 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
705 .para
= { "test", "test", "test test" },
707 char output
[OUTPUT_BUFSIZE
];
709 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
713 strcat(tmp
, MKTEXT(267));
715 strcat(tmp
, MKTEXT(240));
717 is_int(512 - 2, strlen(tmp
), MSG
);
718 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
720 is_string(tmp
, output
, MSG
);
724 static void too_long_for_tag2b_1short(void)
726 const struct MsgBuf msgbuf
= {
729 { .key
= MKTEXT(267), .value
= MKTEXT(239), .capmask
= 1 },
730 { .key
= "a", .value
= "b", .capmask
= 1 },
731 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
739 .para
= { "test", "test", "test test" },
741 char output
[OUTPUT_BUFSIZE
];
743 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
747 strcat(tmp
, MKTEXT(267));
749 strcat(tmp
, MKTEXT(239));
751 is_int(512 - 3, strlen(tmp
), MSG
);
752 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
754 is_string(tmp
, output
, MSG
);
758 static void exact_space_for_tag2b(void)
760 const struct MsgBuf msgbuf
= {
763 { .key
= MKTEXT(267), .value
= MKTEXT(238), .capmask
= 1 },
764 { .key
= "a", .value
= "b", .capmask
= 1 },
765 { .key
= "tag3", .value
= "value3", .capmask
= 1 },
773 .para
= { "test", "test", "test test" },
775 char output
[OUTPUT_BUFSIZE
];
777 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
781 strcat(tmp
, MKTEXT(267));
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");
788 is_string(tmp
, output
, MSG
);
792 static void long_tag1_no_value(void)
794 const struct MsgBuf msgbuf
= {
797 { .key
= MKTEXT(510), .value
= NULL
, .capmask
= 1 },
805 .para
= { "test", "test", "test test" },
807 char output
[OUTPUT_BUFSIZE
];
809 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
813 strcat(tmp
, MKTEXT(510));
815 is_int(512, strlen(tmp
), MSG
);
816 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
818 is_string(tmp
, output
, MSG
);
822 static void long_tag1_empty_value(void)
824 const struct MsgBuf msgbuf
= {
827 { .key
= MKTEXT(509), .value
= "", .capmask
= 1 },
835 .para
= { "test", "test", "test test" },
837 char output
[OUTPUT_BUFSIZE
];
839 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
843 strcat(tmp
, MKTEXT(509));
845 is_int(512, strlen(tmp
), MSG
);
846 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
848 is_string(tmp
, output
, MSG
);
852 static void long_tag1_short_value(void)
854 const struct MsgBuf msgbuf
= {
857 { .key
= MKTEXT(508), .value
= "x", .capmask
= 1 },
865 .para
= { "test", "test", "test test" },
867 char output
[OUTPUT_BUFSIZE
];
869 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
873 strcat(tmp
, MKTEXT(508));
875 is_int(512, strlen(tmp
), MSG
);
876 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
878 is_string(tmp
, output
, MSG
);
882 static void short_tag1_long_value(void)
884 const struct MsgBuf msgbuf
= {
887 { .key
= "x", .value
= MKTEXT(508), .capmask
= 1 },
895 .para
= { "test", "test", "test test" },
897 char output
[OUTPUT_BUFSIZE
];
899 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
903 strcat(tmp
, MKTEXT(508));
905 is_int(512, strlen(tmp
), MSG
);
906 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
908 is_string(tmp
, output
, MSG
);
912 static void too_long_tag1_no_value(void)
914 const struct MsgBuf msgbuf
= {
917 { .key
= MKTEXT(511), .value
= NULL
, .capmask
= 1 },
925 .para
= { "test", "test", "test test" },
927 char output
[OUTPUT_BUFSIZE
];
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
);
934 static void too_long_tag1_empty_value(void)
936 const struct MsgBuf msgbuf
= {
939 { .key
= MKTEXT(510), .value
= "", .capmask
= 1 },
947 .para
= { "test", "test", "test test" },
949 char output
[OUTPUT_BUFSIZE
];
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
);
956 static void too_long_tag1_short_value(void)
958 const struct MsgBuf msgbuf
= {
961 { .key
= MKTEXT(509), .value
= "x", .capmask
= 1 },
969 .para
= { "test", "test", "test test" },
971 char output
[OUTPUT_BUFSIZE
];
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
);
978 static void short_tag1_too_long_value(void)
980 const struct MsgBuf msgbuf
= {
983 { .key
= "x", .value
= MKTEXT(509), .capmask
= 1 },
991 .para
= { "test", "test", "test test" },
993 char output
[OUTPUT_BUFSIZE
];
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
);
1000 static void long_tag2a_no_value(void)
1002 const struct MsgBuf msgbuf
= {
1005 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1006 { .key
= MKTEXT(508), .value
= NULL
, .capmask
= 1 },
1014 .para
= { "test", "test", "test test" },
1016 char output
[OUTPUT_BUFSIZE
];
1018 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1022 strcat(tmp
, MKTEXT(508));
1024 is_int(512, strlen(tmp
), MSG
);
1025 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1027 is_string(tmp
, output
, MSG
);
1031 static void long_tag2b_no_value(void)
1033 const struct MsgBuf msgbuf
= {
1036 { .key
= "a", .value
= "", .capmask
= 1 },
1037 { .key
= MKTEXT(507), .value
= NULL
, .capmask
= 1 },
1045 .para
= { "test", "test", "test test" },
1047 char output
[OUTPUT_BUFSIZE
];
1049 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1052 strcpy(tmp
, "@a=;");
1053 strcat(tmp
, MKTEXT(507));
1055 is_int(512, strlen(tmp
), MSG
);
1056 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1058 is_string(tmp
, output
, MSG
);
1062 static void long_tag2c_no_value(void)
1064 const struct MsgBuf msgbuf
= {
1067 { .key
= "a", .value
= "b", .capmask
= 1 },
1068 { .key
= MKTEXT(506), .value
= NULL
, .capmask
= 1 },
1076 .para
= { "test", "test", "test test" },
1078 char output
[OUTPUT_BUFSIZE
];
1080 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1083 strcpy(tmp
, "@a=b;");
1084 strcat(tmp
, MKTEXT(506));
1086 is_int(512, strlen(tmp
), MSG
);
1087 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1089 is_string(tmp
, output
, MSG
);
1093 static void long_tag2a_empty_value(void)
1095 const struct MsgBuf msgbuf
= {
1098 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1099 { .key
= MKTEXT(507), .value
= "", .capmask
= 1 },
1107 .para
= { "test", "test", "test test" },
1109 char output
[OUTPUT_BUFSIZE
];
1111 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1115 strcat(tmp
, MKTEXT(507));
1117 is_int(512, strlen(tmp
), MSG
);
1118 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1120 is_string(tmp
, output
, MSG
);
1124 static void long_tag2b_empty_value(void)
1126 const struct MsgBuf msgbuf
= {
1129 { .key
= "a", .value
= "", .capmask
= 1 },
1130 { .key
= MKTEXT(506), .value
= "", .capmask
= 1 },
1138 .para
= { "test", "test", "test test" },
1140 char output
[OUTPUT_BUFSIZE
];
1142 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1145 strcpy(tmp
, "@a=;");
1146 strcat(tmp
, MKTEXT(506));
1148 is_int(512, strlen(tmp
), MSG
);
1149 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1151 is_string(tmp
, output
, MSG
);
1155 static void long_tag2c_empty_value(void)
1157 const struct MsgBuf msgbuf
= {
1160 { .key
= "a", .value
= "b", .capmask
= 1 },
1161 { .key
= MKTEXT(505), .value
= "", .capmask
= 1 },
1169 .para
= { "test", "test", "test test" },
1171 char output
[OUTPUT_BUFSIZE
];
1173 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1176 strcpy(tmp
, "@a=b;");
1177 strcat(tmp
, MKTEXT(505));
1179 is_int(512, strlen(tmp
), MSG
);
1180 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1182 is_string(tmp
, output
, MSG
);
1186 static void long_tag2a_short_value(void)
1188 const struct MsgBuf msgbuf
= {
1191 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1192 { .key
= MKTEXT(506), .value
= "x", .capmask
= 1 },
1200 .para
= { "test", "test", "test test" },
1202 char output
[OUTPUT_BUFSIZE
];
1204 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1208 strcat(tmp
, MKTEXT(506));
1210 is_int(512, strlen(tmp
), MSG
);
1211 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1213 is_string(tmp
, output
, MSG
);
1217 static void long_tag2b_short_value(void)
1219 const struct MsgBuf msgbuf
= {
1222 { .key
= "a", .value
= "", .capmask
= 1 },
1223 { .key
= MKTEXT(505), .value
= "x", .capmask
= 1 },
1231 .para
= { "test", "test", "test test" },
1233 char output
[OUTPUT_BUFSIZE
];
1235 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1238 strcpy(tmp
, "@a=;");
1239 strcat(tmp
, MKTEXT(505));
1241 is_int(512, strlen(tmp
), MSG
);
1242 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1244 is_string(tmp
, output
, MSG
);
1248 static void long_tag2c_short_value(void)
1250 const struct MsgBuf msgbuf
= {
1253 { .key
= "a", .value
= "b", .capmask
= 1 },
1254 { .key
= MKTEXT(504), .value
= "x", .capmask
= 1 },
1262 .para
= { "test", "test", "test test" },
1264 char output
[OUTPUT_BUFSIZE
];
1266 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1269 strcpy(tmp
, "@a=b;");
1270 strcat(tmp
, MKTEXT(504));
1272 is_int(512, strlen(tmp
), MSG
);
1273 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1275 is_string(tmp
, output
, MSG
);
1279 static void short_tag2a_long_value(void)
1281 const struct MsgBuf msgbuf
= {
1284 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1285 { .key
= "x", .value
= MKTEXT(506), .capmask
= 1 },
1293 .para
= { "test", "test", "test test" },
1295 char output
[OUTPUT_BUFSIZE
];
1297 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1300 strcpy(tmp
, "@a;x=");
1301 strcat(tmp
, MKTEXT(506));
1303 is_int(512, strlen(tmp
), MSG
);
1304 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1306 is_string(tmp
, output
, MSG
);
1310 static void short_tag2b_long_value(void)
1312 const struct MsgBuf msgbuf
= {
1315 { .key
= "a", .value
= "", .capmask
= 1 },
1316 { .key
= "x", .value
= MKTEXT(505), .capmask
= 1 },
1324 .para
= { "test", "test", "test test" },
1326 char output
[OUTPUT_BUFSIZE
];
1328 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1331 strcpy(tmp
, "@a=;x=");
1332 strcat(tmp
, MKTEXT(505));
1334 is_int(512, strlen(tmp
), MSG
);
1335 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1337 is_string(tmp
, output
, MSG
);
1341 static void short_tag2c_long_value(void)
1343 const struct MsgBuf msgbuf
= {
1346 { .key
= "a", .value
= "b", .capmask
= 1 },
1347 { .key
= "x", .value
= MKTEXT(504), .capmask
= 1 },
1355 .para
= { "test", "test", "test test" },
1357 char output
[OUTPUT_BUFSIZE
];
1359 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1362 strcpy(tmp
, "@a=b;x=");
1363 strcat(tmp
, MKTEXT(504));
1365 is_int(512, strlen(tmp
), MSG
);
1366 strcat(tmp
, ":origin PRIVMSG #test test test :test test");
1368 is_string(tmp
, output
, MSG
);
1372 static void too_long_tag2a_no_value(void)
1374 const struct MsgBuf msgbuf
= {
1377 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1378 { .key
= MKTEXT(509), .value
= NULL
, .capmask
= 1 },
1386 .para
= { "test", "test", "test test" },
1388 char output
[OUTPUT_BUFSIZE
];
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
);
1395 static void too_long_tag2b_no_value(void)
1397 const struct MsgBuf msgbuf
= {
1400 { .key
= "a", .value
= "", .capmask
= 1 },
1401 { .key
= MKTEXT(508), .value
= NULL
, .capmask
= 1 },
1409 .para
= { "test", "test", "test test" },
1411 char output
[OUTPUT_BUFSIZE
];
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
);
1418 static void too_long_tag2c_no_value(void)
1420 const struct MsgBuf msgbuf
= {
1423 { .key
= "a", .value
= "b", .capmask
= 1 },
1424 { .key
= MKTEXT(507), .value
= NULL
, .capmask
= 1 },
1432 .para
= { "test", "test", "test test" },
1434 char output
[OUTPUT_BUFSIZE
];
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
);
1441 static void too_long_tag2a_empty_value(void)
1443 const struct MsgBuf msgbuf
= {
1446 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1447 { .key
= MKTEXT(508), .value
= "", .capmask
= 1 },
1455 .para
= { "test", "test", "test test" },
1457 char output
[OUTPUT_BUFSIZE
];
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
);
1464 static void too_long_tag2b_empty_value(void)
1466 const struct MsgBuf msgbuf
= {
1469 { .key
= "a", .value
= "", .capmask
= 1 },
1470 { .key
= MKTEXT(507), .value
= "", .capmask
= 1 },
1478 .para
= { "test", "test", "test test" },
1480 char output
[OUTPUT_BUFSIZE
];
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
);
1487 static void too_long_tag2c_empty_value(void)
1489 const struct MsgBuf msgbuf
= {
1492 { .key
= "a", .value
= "b", .capmask
= 1 },
1493 { .key
= MKTEXT(506), .value
= "", .capmask
= 1 },
1501 .para
= { "test", "test", "test test" },
1503 char output
[OUTPUT_BUFSIZE
];
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
);
1510 static void too_long_tag2a_short_value(void)
1512 const struct MsgBuf msgbuf
= {
1515 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1516 { .key
= MKTEXT(507), .value
= "x", .capmask
= 1 },
1524 .para
= { "test", "test", "test test" },
1526 char output
[OUTPUT_BUFSIZE
];
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
);
1533 static void too_long_tag2b_short_value(void)
1535 const struct MsgBuf msgbuf
= {
1538 { .key
= "a", .value
= "", .capmask
= 1 },
1539 { .key
= MKTEXT(506), .value
= "x", .capmask
= 1 },
1547 .para
= { "test", "test", "test test" },
1549 char output
[OUTPUT_BUFSIZE
];
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
);
1556 static void too_long_tag2c_short_value(void)
1558 const struct MsgBuf msgbuf
= {
1561 { .key
= "a", .value
= "b", .capmask
= 1 },
1562 { .key
= MKTEXT(505), .value
= "x", .capmask
= 1 },
1570 .para
= { "test", "test", "test test" },
1572 char output
[OUTPUT_BUFSIZE
];
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
);
1579 static void short_tag2a_too_long_value(void)
1581 const struct MsgBuf msgbuf
= {
1584 { .key
= "a", .value
= NULL
, .capmask
= 1 },
1585 { .key
= "x", .value
= MKTEXT(507), .capmask
= 1 },
1593 .para
= { "test", "test", "test test" },
1595 char output
[OUTPUT_BUFSIZE
];
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
);
1602 static void short_tag2b_too_long_value(void)
1604 const struct MsgBuf msgbuf
= {
1607 { .key
= "a", .value
= "", .capmask
= 1 },
1608 { .key
= "x", .value
= MKTEXT(506), .capmask
= 1 },
1616 .para
= { "test", "test", "test test" },
1618 char output
[OUTPUT_BUFSIZE
];
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
);
1625 static void short_tag2c_too_long_value(void)
1627 const struct MsgBuf msgbuf
= {
1630 { .key
= "a", .value
= "b", .capmask
= 1 },
1631 { .key
= "x", .value
= MKTEXT(505), .capmask
= 1 },
1639 .para
= { "test", "test", "test test" },
1641 char output
[OUTPUT_BUFSIZE
];
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
);
1648 static void escape_test(void)
1650 const struct MsgBuf msgbuf
= {
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 },
1666 .para
= { "test", "test", "test test" },
1668 char output
[OUTPUT_BUFSIZE
];
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
);
1675 static void escape_test_8bit(void)
1677 const struct MsgBuf msgbuf
= {
1680 { .key
= "tag1", .value
= "\176\177\178\376\377", .capmask
= 1 },
1688 .para
= { "test", "test", "test test" },
1690 char output
[OUTPUT_BUFSIZE
];
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
);
1697 static void long_para1a(void)
1699 const struct MsgBuf msgbuf
= {
1707 .para
= { MKTEXT(488) },
1709 char output
[OUTPUT_BUFSIZE
];
1711 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1714 strcpy(tmp
, ":origin PRIVMSG #test ");
1715 strcat(tmp
, MKTEXT(488));
1716 is_int(510, strlen(tmp
), MSG
);
1718 is_string(tmp
, output
, MSG
);
1722 static void too_long_para1a(void)
1724 const struct MsgBuf msgbuf
= {
1732 .para
= { MKTEXT(489) },
1734 char output
[OUTPUT_BUFSIZE
];
1736 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1739 strcpy(tmp
, ":origin PRIVMSG #test ");
1740 strcat(tmp
, MKTEXT(489));
1741 tmp
[strlen(tmp
) - 1] = 0;
1742 is_int(510, strlen(tmp
), MSG
);
1744 is_string(tmp
, output
, MSG
);
1748 static void long_para1b(void)
1751 const struct MsgBuf msgbuf
= {
1761 char output
[OUTPUT_BUFSIZE
];
1763 /* make second-last char ' ' so that a ':' prefix is required */
1764 strcpy(input
, MKTEXT(487));
1765 input
[strlen(input
) - 2] = ' ';
1767 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1770 strcpy(tmp
, ":origin PRIVMSG #test :");
1771 strcat(tmp
, MKTEXT(487));
1772 tmp
[strlen(tmp
) - 2] = ' ';
1773 is_int(510, strlen(tmp
), MSG
);
1775 is_string(tmp
, output
, MSG
);
1779 static void too_long_para1b(void)
1782 const struct MsgBuf msgbuf
= {
1792 char output
[OUTPUT_BUFSIZE
];
1794 /* make second-last char ' ' so that a ':' prefix is required */
1795 strcpy(input
, MKTEXT(488));
1796 input
[strlen(input
) - 3] = ' ';
1798 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
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
);
1807 is_string(tmp
, output
, MSG
);
1811 static void long_para2a(void)
1813 const struct MsgBuf msgbuf
= {
1821 .para
= { "test", MKTEXT(483) },
1823 char output
[OUTPUT_BUFSIZE
];
1825 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1828 strcpy(tmp
, ":origin PRIVMSG #test test ");
1829 strcat(tmp
, MKTEXT(483));
1830 is_int(510, strlen(tmp
), MSG
);
1832 is_string(tmp
, output
, MSG
);
1836 static void too_long_para2a(void)
1838 const struct MsgBuf msgbuf
= {
1846 .para
= { "test", MKTEXT(484) },
1848 char output
[OUTPUT_BUFSIZE
];
1850 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
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
);
1858 is_string(tmp
, output
, MSG
);
1862 static void long_para2b(void)
1865 const struct MsgBuf msgbuf
= {
1873 .para
= { "test", input
},
1875 char output
[OUTPUT_BUFSIZE
];
1877 /* make second-last char ' ' so that a ':' prefix is required */
1878 strcpy(input
, MKTEXT(482));
1879 input
[strlen(input
) - 2] = ' ';
1881 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1884 strcpy(tmp
, ":origin PRIVMSG #test test :");
1885 strcat(tmp
, MKTEXT(482));
1886 tmp
[strlen(tmp
) - 2] = ' ';
1887 is_int(510, strlen(tmp
), MSG
);
1889 is_string(tmp
, output
, MSG
);
1893 static void too_long_para2b(void)
1896 const struct MsgBuf msgbuf
= {
1904 .para
= { "test", input
},
1906 char output
[OUTPUT_BUFSIZE
];
1908 /* make second-last char ' ' so that a ':' prefix is required */
1909 strcpy(input
, MKTEXT(483));
1910 input
[strlen(input
) - 3] = ' ';
1912 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
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
);
1921 is_string(tmp
, output
, MSG
);
1925 static void long_para3a(void)
1927 const struct MsgBuf msgbuf
= {
1935 .para
= { "test1", "test2", MKTEXT(476) },
1937 char output
[OUTPUT_BUFSIZE
];
1939 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
1942 strcpy(tmp
, ":origin PRIVMSG #test test1 test2 ");
1943 strcat(tmp
, MKTEXT(476));
1944 is_int(510, strlen(tmp
), MSG
);
1946 is_string(tmp
, output
, MSG
);
1950 static void too_long_para3a(void)
1952 const struct MsgBuf msgbuf
= {
1960 .para
= { "test1", "test2", MKTEXT(477) },
1962 char output
[OUTPUT_BUFSIZE
];
1964 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
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
);
1972 is_string(tmp
, output
, MSG
);
1976 static void long_para3b(void)
1979 const struct MsgBuf msgbuf
= {
1987 .para
= { "test1", "test2", input
},
1989 char output
[OUTPUT_BUFSIZE
];
1991 /* make second-last char ' ' so that a ':' prefix is required */
1992 strcpy(input
, MKTEXT(475));
1993 input
[strlen(input
) - 2] = ' ';
1995 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
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
);
2003 is_string(tmp
, output
, MSG
);
2007 static void too_long_para3b(void)
2010 const struct MsgBuf msgbuf
= {
2018 .para
= { "test1", "test2", input
},
2020 char output
[OUTPUT_BUFSIZE
];
2022 /* make second-last char ' ' so that a ':' prefix is required */
2023 strcpy(input
, MKTEXT(476));
2024 input
[strlen(input
) - 3] = ' ';
2026 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
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
);
2035 is_string(tmp
, output
, MSG
);
2039 static void long_para15a(void)
2041 const struct MsgBuf msgbuf
= {
2049 .para
= { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", MKTEXT(399) },
2051 char output
[OUTPUT_BUFSIZE
];
2053 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
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
);
2060 is_string(tmp
, output
, MSG
);
2064 static void too_long_para15a(void)
2066 const struct MsgBuf msgbuf
= {
2074 .para
= { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", MKTEXT(400) },
2076 char output
[OUTPUT_BUFSIZE
];
2078 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
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
);
2086 is_string(tmp
, output
, MSG
);
2090 static void long_para15b(void)
2093 const struct MsgBuf msgbuf
= {
2101 .para
= { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", input
},
2103 char output
[OUTPUT_BUFSIZE
];
2105 /* make second-last char ' ' so that a ':' prefix is required */
2106 strcpy(input
, MKTEXT(398));
2107 input
[strlen(input
) - 2] = ' ';
2109 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
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
);
2117 is_string(tmp
, output
, MSG
);
2121 static void too_long_para15b(void)
2124 const struct MsgBuf msgbuf
= {
2132 .para
= { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", input
},
2134 char output
[OUTPUT_BUFSIZE
];
2136 /* make second-last char ' ' so that a ':' prefix is required */
2137 strcpy(input
, MKTEXT(399));
2138 input
[strlen(input
) - 3] = ' ';
2140 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
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
);
2149 is_string(tmp
, output
, MSG
);
2153 static const struct MsgBuf small_buffer_tags_msgbuf
= {
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 },
2178 .para
= { "test", "test", "test test" },
2181 static void small_buffer_tags_2_remaining_for_para(void)
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
);
2190 static void small_buffer_tags_1_remaining_for_para(void)
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
);
2199 static void small_buffer_tags_0_remaining_for_para(void)
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
);
2208 static void small_buffer_tags_X_remaining_for_para(void)
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
2215 is_string("@tag1=value1;tag2=value2;tag3=value3;tag4=value4;tag5=value5;tag6=value6;tag7=value7 :origin PRI", output
, MSG
);
2219 static const struct MsgBuf small_buffer_a_msgbuf
= {
2222 { .key
= "a", .value
= NULL
, .capmask
= 1 },
2223 { .key
= "c", .value
= "d", .capmask
= 1 },
2224 { .key
= "e", .value
= "f", .capmask
= 1 },
2232 .para
= { "test", "test", "test test" },
2235 static const struct MsgBuf small_buffer_b_msgbuf
= {
2238 { .key
= "a", .value
= "b", .capmask
= 1 },
2239 { .key
= "c", .value
= "d", .capmask
= 1 },
2240 { .key
= "e", .value
= "f", .capmask
= 1 },
2248 .para
= { "test", "test", "test test" },
2251 static void small_buffer1(void)
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
);
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
);
2268 static void small_buffer2(void)
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
);
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
);
2285 static void small_buffer3(void)
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
);
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
);
2302 static void small_buffer4(void)
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
);
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
);
2319 static void small_buffer5(void)
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
);
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
);
2336 static void small_buffer6(void)
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
);
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
);
2353 static void small_buffer7(void)
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
);
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
);
2370 static void small_buffer8(void)
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
);
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
);
2387 static void small_buffer9(void)
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
);
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
);
2404 static void small_buffer10(void)
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
);
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
);
2421 static void small_buffer11(void)
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
);
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
);
2438 static void small_buffer12(void)
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
);
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
);
2455 static void small_buffer13(void)
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
);
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
);
2472 static void small_buffer14(void)
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
);
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
);
2489 static void small_buffer15(void)
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
);
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
);
2506 static const struct MsgBuf long_tags_small_buffer_msgbuf
= {
2509 { .key
= MKTEXT(510), .value
= NULL
, .capmask
= 1 },
2517 .para
= { "test", "test", "test test" },
2520 #define LONG_TAGS "@10abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx"\
2521 "yzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcbaZYXWVUT"\
2522 "SRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"\
2523 "QRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ZYXWVUTSRQPONMLKJIHGFEDCB"\
2524 "AzyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210abcdefgh"\
2525 "ijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
2527 static void long_tags_small_buffer0(void)
2529 char output
[TAGSLEN
+ 0 + 1];
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
);
2538 static void long_tags_small_buffer1(void)
2540 char output
[TAGSLEN
+ 1 + 1];
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
);
2549 static void long_tags_small_buffer2(void)
2551 char output
[TAGSLEN
+ 2 + 1];
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
);
2560 static void long_tags_small_buffer3(void)
2562 char output
[TAGSLEN
+ 3 + 1];
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
);
2571 static void long_tags_small_buffer4(void)
2573 char output
[TAGSLEN
+ 4 + 1];
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
);
2582 static void long_tags_small_buffer5(void)
2584 char output
[TAGSLEN
+ 5 + 1];
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
);
2593 static const struct MsgBuf no_tags_small_buffer_msgbuf
= {
2601 .para
= { "test", "test", "test test" },
2604 static void no_tags_small_buffer1(void)
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
);
2615 static void no_tags_small_buffer2(void)
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
);
2626 static void no_tags_small_buffer3(void)
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
);
2637 static void no_tags_small_buffer4(void)
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
);
2648 static void no_tags_small_buffer5(void)
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
);
2659 static void no_tags_small_buffer6(void)
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
);
2670 static void para_no_origin(void)
2672 const struct MsgBuf msgbuf
= {
2680 .para
= { "test1", "test2", "test3 test4" },
2682 char output
[OUTPUT_BUFSIZE
];
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
);
2689 static void para_no_cmd(void)
2691 const struct MsgBuf msgbuf
= {
2699 .para
= { "test1", "test2", "test3 test4" },
2701 char output
[OUTPUT_BUFSIZE
];
2703 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2704 is_string(":origin #test test1 test2 :test3 test4", output
, MSG
);
2708 static void para_no_target(void)
2710 const struct MsgBuf msgbuf
= {
2718 .para
= { "test1", "test2", "test3 test4" },
2720 char output
[OUTPUT_BUFSIZE
];
2722 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2723 is_string(":origin PRIVMSG test1 test2 :test3 test4", output
, MSG
);
2727 static void para_no_origin_no_cmd(void)
2729 const struct MsgBuf msgbuf
= {
2737 .para
= { "test1", "test2", "test3 test4" },
2739 char output
[OUTPUT_BUFSIZE
];
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
);
2746 static void para_no_origin_no_target(void)
2748 const struct MsgBuf msgbuf
= {
2756 .para
= { "test1", "test2", "test3 test4" },
2758 char output
[OUTPUT_BUFSIZE
];
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
);
2765 static void para_no_cmd_no_target(void)
2767 const struct MsgBuf msgbuf
= {
2775 .para
= { "test1", "test2", "test3 test4" },
2777 char output
[OUTPUT_BUFSIZE
];
2779 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2780 is_string(":origin test1 test2 :test3 test4", output
, MSG
);
2784 static void para_no_origin_no_cmd_no_target(void)
2786 const struct MsgBuf msgbuf
= {
2794 .para
= { "test1", "test2", "test3 test4" },
2796 char output
[OUTPUT_BUFSIZE
];
2798 if (is_int(0, msgbuf_unparse(output
, sizeof(output
), &msgbuf
, 1), MSG
)) {
2799 is_string(":me.name. test1 test2 :test3 test4", output
, MSG
);
2803 int main(int argc
, char *argv
[])
2805 memset(&me
, 0, sizeof(me
));
2806 strcpy(me
.name
, "me.name.");
2810 is_int(512, TAGSLEN
, MSG
);
2811 is_int(510, DATALEN
, MSG
);
2812 is_int(512 + 510 + 1, EXT_BUFSIZE
, MSG
);
2817 basic_tags15_capmask1();
2818 basic_tags15_capmask2();
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();
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();
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();
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();
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();
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();
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