30 TEST_CASE(
"A configuration string must have at least one valid statement " 31 "or block.",
"[config]")
33 tao::pegtl::string_input<> in(
"1337",
"");
34 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
37 ":1:0(0): expected at least one valid statement or block");
43 SECTION(
"Missing end of statement ';'.")
45 tao::pegtl::string_input<> in(
"invalid",
"");
46 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
49 ":1:7(7): expected end of statement ';' character");
51 SECTION(
"Invalid statement.")
53 tao::pegtl::string_input<> in(
"invalid;",
"");
54 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
61 TEST_CASE(
"Parse global 'default_action' statement.",
"[config]")
63 SECTION(
"Parses the 'accept' option.")
65 tao::pegtl::string_input<> in(
"default_action accept;",
"");
67 REQUIRE(root !=
nullptr);
70 ":001: default_action\n" 73 SECTION(
"Parses the 'accept' option (with comments).")
75 tao::pegtl::string_input<> in(
"default_action accept;# comment",
"");
77 REQUIRE(root !=
nullptr);
80 ":001: default_action\n" 83 SECTION(
"Parses the 'reject' option.")
85 tao::pegtl::string_input<> in(
"default_action reject;",
"");
87 REQUIRE(root !=
nullptr);
90 ":001: default_action\n" 93 SECTION(
"Parses the 'reject' option (with comments).")
95 tao::pegtl::string_input<> in(
"default_action reject;# comment",
"");
97 REQUIRE(root !=
nullptr);
100 ":001: default_action\n" 103 SECTION(
"Missing end of statement.")
105 tao::pegtl::string_input<> in(
"default_action accept",
"");
106 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
109 ":1:21(21): expected end of statement ';' character");
111 SECTION(
"Invalid default action.")
113 tao::pegtl::string_input<> in(
"default_action invalid;",
"");
114 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
116 config::parse(in),
":1:15(15): expected 'accept' or 'reject'");
118 SECTION(
"Missing default action value.")
120 tao::pegtl::string_input<> in(
"default_action;",
"");
121 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
123 config::parse(in),
":1:14(14): expected 'accept' or 'reject'");
130 SECTION(
"Empty UDP blocks are allowed (single line).")
132 tao::pegtl::string_input<> in(
"udp {}",
"");
134 REQUIRE(root !=
nullptr);
135 REQUIRE(
str(*root) ==
":001: udp\n");
137 SECTION(
"Empty UDP blocks are allowed (single line with comments).")
139 tao::pegtl::string_input<> in(
"udp {}# comment",
"");
141 REQUIRE(root !=
nullptr);
142 REQUIRE(
str(*root) ==
":001: udp\n");
144 SECTION(
"Empty UDP blocks are allowed (1TBS style).")
146 tao::pegtl::string_input<> in(
"udp {\n}",
"");
148 REQUIRE(root !=
nullptr);
149 REQUIRE(
str(*root) ==
":001: udp\n");
151 SECTION(
"Empty UDP blocks are allowed (1TBS style with comments).")
153 tao::pegtl::string_input<> in(
"udp {# comment\n}# comment",
"");
155 REQUIRE(root !=
nullptr);
156 REQUIRE(
str(*root) ==
":001: udp\n");
158 SECTION(
"Empty UDP blocks are allowed (Allman style).")
160 tao::pegtl::string_input<> in(
"udp\n{\n}",
"");
162 REQUIRE(root !=
nullptr);
163 REQUIRE(
str(*root) ==
":001: udp\n");
165 SECTION(
"Empty UDP blocks are allowed (Allman style with commentd).")
167 tao::pegtl::string_input<> in(
168 "udp# comment \n{# comment\n}# comment",
"");
170 REQUIRE(root !=
nullptr);
171 REQUIRE(
str(*root) ==
":001: udp\n");
173 SECTION(
"Missing opening brace (closing brace exists).")
175 tao::pegtl::string_input<> in(
"udp }",
"");
176 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
180 SECTION(
"Missing opening brace (closing brace missing).")
182 tao::pegtl::string_input<> in(
"udp",
"");
183 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
187 SECTION(
"Missing closing brace.")
189 tao::pegtl::string_input<> in(
"udp {",
"");
190 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
199 SECTION(
"Parses port number setting.")
201 tao::pegtl::string_input<> in(
206 REQUIRE(root !=
nullptr);
210 ":002: | port 14500\n");
212 SECTION(
"Parses port number setting (with comments).")
214 tao::pegtl::string_input<> in(
216 " port 14500;# comment\n" 219 REQUIRE(root !=
nullptr);
223 ":002: | port 14500\n");
225 SECTION(
"Missing end of statement.")
227 tao::pegtl::string_input<> in(
231 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
234 ":3:0(21): expected end of statement ';' character");
236 SECTION(
"Invalid port number.")
238 tao::pegtl::string_input<> in(
242 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
244 config::parse(in),
":2:9(15): expected a valid port number");
246 SECTION(
"Missing port number.")
248 tao::pegtl::string_input<> in(
252 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
254 config::parse(in),
":2:8(14): expected a valid port number");
261 SECTION(
"Parses IP address setting.")
263 tao::pegtl::string_input<> in(
265 " address 127.0.0.1;\n" 268 REQUIRE(root !=
nullptr);
272 ":002: | address 127.0.0.1\n");
274 SECTION(
"Parses IP address setting (with comments).")
276 tao::pegtl::string_input<> in(
278 " address 127.0.0.1;# comment\n" 281 REQUIRE(root !=
nullptr);
285 ":002: | address 127.0.0.1\n");
287 SECTION(
"Missing end of statement.")
289 tao::pegtl::string_input<> in(
291 " address 127.0.0.1\n" 293 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
296 ":3:0(28): expected end of statement ';' character");
298 SECTION(
"Invalid IP address [1].")
300 tao::pegtl::string_input<> in(
302 " address 127.0.0.1.;\n" 304 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
307 ":2:21(27): expected end of statement ';' character");
309 SECTION(
"Invalid IP address [2].")
311 tao::pegtl::string_input<> in(
313 " address 127.0.0.;\n" 315 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
317 config::parse(in),
":2:20(26): expected a valid IP address");
319 SECTION(
"Invalid IP address [3].")
321 tao::pegtl::string_input<> in(
323 " address 127.0.0;\n" 325 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
327 config::parse(in),
":2:19(25): expected a valid IP address");
329 SECTION(
"Invalid IP address [4].")
331 tao::pegtl::string_input<> in(
335 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
337 config::parse(in),
":2:18(24): expected a valid IP address");
339 SECTION(
"Invalid IP address [5].")
341 tao::pegtl::string_input<> in(
345 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
347 config::parse(in),
":2:17(23): expected a valid IP address");
349 SECTION(
"Invalid IP address [6].")
351 tao::pegtl::string_input<> in(
355 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
357 config::parse(in),
":2:16(22): expected a valid IP address");
359 SECTION(
"Invalid IP address [7].")
361 tao::pegtl::string_input<> in(
365 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
367 config::parse(in),
":2:15(21): expected a valid IP address");
369 SECTION(
"Invalid IP address [8].")
371 tao::pegtl::string_input<> in(
373 " address 127:0:0:1;\n" 375 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
377 config::parse(in),
":2:15(21): expected a valid IP address");
379 SECTION(
"Invalid IP address [9].")
381 tao::pegtl::string_input<> in(
383 " address 127.a.0.1;\n" 385 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
387 config::parse(in),
":2:16(22): expected a valid IP address");
389 SECTION(
"Missing IP address.")
391 tao::pegtl::string_input<> in(
395 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
397 config::parse(in),
":2:11(17): expected a valid IP address");
404 SECTION(
"Parses max bitrate setting.")
406 tao::pegtl::string_input<> in(
408 " max_bitrate 8192;\n" 411 REQUIRE(root !=
nullptr);
415 ":002: | max_bitrate 8192\n");
417 SECTION(
"Parses max bitrate setting (with comments).")
419 tao::pegtl::string_input<> in(
421 " max_bitrate 8192;# comment\n" 424 REQUIRE(root !=
nullptr);
428 ":002: | max_bitrate 8192\n");
430 SECTION(
"Missing end of statement.")
432 tao::pegtl::string_input<> in(
434 " max_bitrate 8192\n" 436 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
439 ":3:0(27): expected end of statement ';' character");
441 SECTION(
"Invalid bitrate.")
443 tao::pegtl::string_input<> in(
445 " max_bitrate a512;\n" 447 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
451 SECTION(
"Missing bitrate.")
453 tao::pegtl::string_input<> in(
457 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
464 TEST_CASE(
"Serial port configuration block.",
"[config]")
466 SECTION(
"Empty serial port blocks are allowed (single line).")
468 tao::pegtl::string_input<> in(
"serial {}",
"");
470 REQUIRE(root !=
nullptr);
471 REQUIRE(
str(*root) ==
":001: serial\n");
473 SECTION(
"Empty serial port blocks are allowed (single line with comments).")
475 tao::pegtl::string_input<> in(
"serial {}# comment",
"");
477 REQUIRE(root !=
nullptr);
478 REQUIRE(
str(*root) ==
":001: serial\n");
480 SECTION(
"Empty serial port blocks are allowed (1TBS style).")
482 tao::pegtl::string_input<> in(
"serial {\n}",
"");
484 REQUIRE(root !=
nullptr);
485 REQUIRE(
str(*root) ==
":001: serial\n");
487 SECTION(
"Empty serial port blocks are allowed (1TBS style with comments).")
489 tao::pegtl::string_input<> in(
"serial {# comment\n}# comment",
"");
491 REQUIRE(root !=
nullptr);
492 REQUIRE(
str(*root) ==
":001: serial\n");
494 SECTION(
"Empty serial port blocks are allowed (Allman style).")
496 tao::pegtl::string_input<> in(
"serial\n{\n}",
"");
498 REQUIRE(root !=
nullptr);
499 REQUIRE(
str(*root) ==
":001: serial\n");
501 SECTION(
"Empty serial port blocks are allowed " 502 "(Allman style with comments).")
504 tao::pegtl::string_input<> in(
505 "serial# comment\n{# comment\n}# comment",
"");
507 REQUIRE(root !=
nullptr);
508 REQUIRE(
str(*root) ==
":001: serial\n");
510 SECTION(
"Missing opening brace (closing brace exists).")
512 tao::pegtl::string_input<> in(
"serial }",
"");
513 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
517 SECTION(
"Missing opening brace (closing brace missing).")
519 tao::pegtl::string_input<> in(
"serial",
"");
520 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
524 SECTION(
"Missing closing brace.")
526 tao::pegtl::string_input<> in(
"serial {",
"");
527 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
536 SECTION(
"Parses device string setting [1].")
538 tao::pegtl::string_input<> in(
540 " device /dev/tty_USB0;\n" 543 REQUIRE(root !=
nullptr);
547 ":002: | device /dev/tty_USB0\n");
549 SECTION(
"Parses device string setting (with comments) [1].")
551 tao::pegtl::string_input<> in(
552 "serial {# comment\n" 553 " device /dev/tty_USB0;# comment\n" 556 REQUIRE(root !=
nullptr);
560 ":002: | device /dev/tty_USB0\n");
562 SECTION(
"Parses device string setting [2].")
564 tao::pegtl::string_input<> in(
569 REQUIRE(root !=
nullptr);
573 ":002: | device COM1\n");
575 SECTION(
"Parses device string setting (with comment) [2].")
577 tao::pegtl::string_input<> in(
578 "serial {# comment\n" 579 " device COM1;# comment\n" 582 REQUIRE(root !=
nullptr);
586 ":002: | device COM1\n");
588 SECTION(
"Missing end of statement.")
590 tao::pegtl::string_input<> in(
594 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
597 ":3:0(28): expected end of statement ';' character");
599 SECTION(
"Invalid device string.")
601 tao::pegtl::string_input<> in(
605 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
608 ":2:11(20): expected a valid serial port device name");
610 SECTION(
"Missing device string.")
612 tao::pegtl::string_input<> in(
616 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
619 ":2:10(19): expected a valid serial port device name");
626 SECTION(
"Parses baud rate setting.")
628 tao::pegtl::string_input<> in(
633 REQUIRE(root !=
nullptr);
637 ":002: | baudrate 9600\n");
639 SECTION(
"Parses device string setting (with comments).")
641 tao::pegtl::string_input<> in(
642 "serial {# comment\n" 643 " baudrate 9600;# comment\n" 646 REQUIRE(root !=
nullptr);
650 ":002: | baudrate 9600\n");
652 SECTION(
"Missing end of statement.")
654 tao::pegtl::string_input<> in(
658 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
661 ":3:0(27): expected end of statement ';' character");
663 SECTION(
"Invalid baud rate.")
665 tao::pegtl::string_input<> in(
669 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
672 ":2:13(22): expected a valid baud rate");
674 SECTION(
"Missing baud rate value.")
676 tao::pegtl::string_input<> in(
680 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
683 ":2:12(21): expected a valid baud rate");
688 TEST_CASE(
"Serial port flow control setting.",
"[config]")
690 SECTION(
"Parses flow control setting (yes).")
692 tao::pegtl::string_input<> in(
694 " flow_control yes;\n" 697 REQUIRE(root !=
nullptr);
701 ":002: | flow_control yes\n");
703 SECTION(
"Parses flow control setting (yes with comments).")
705 tao::pegtl::string_input<> in(
706 "serial {# comments\n" 707 " flow_control yes;# comments\n" 710 REQUIRE(root !=
nullptr);
714 ":002: | flow_control yes\n");
716 SECTION(
"Parses flow control setting (no).")
718 tao::pegtl::string_input<> in(
720 " flow_control no;\n" 723 REQUIRE(root !=
nullptr);
727 ":002: | flow_control no\n");
729 SECTION(
"Parses flow control setting (no with comments).")
731 tao::pegtl::string_input<> in(
732 "serial {# comments\n" 733 " flow_control no;# comments\n" 736 REQUIRE(root !=
nullptr);
740 ":002: | flow_control no\n");
742 SECTION(
"Missing end of statement.")
744 tao::pegtl::string_input<> in(
746 " flow_control yes\n" 748 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
751 ":3:0(30): expected end of statement ';' character");
753 SECTION(
"Invalid flow control setting.")
755 tao::pegtl::string_input<> in(
757 " flow_control maybe;\n" 759 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
762 ":2:17(26): expected 'yes' or 'no'");
764 SECTION(
"Missing flow control setting.")
766 tao::pegtl::string_input<> in(
770 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
773 ":2:16(25): expected 'yes' or 'no'");
780 SECTION(
"Parses a preload address.")
782 tao::pegtl::string_input<> in(
787 REQUIRE(root !=
nullptr);
791 ":002: | preload 62.34\n");
793 SECTION(
"Parses multiple preload address.")
795 tao::pegtl::string_input<> in(
801 REQUIRE(root !=
nullptr);
805 ":002: | preload 1.1\n" 806 ":003: | preload 62.34\n");
808 SECTION(
"Parses a preload address (with comments).")
810 tao::pegtl::string_input<> in(
811 "serial {# comment\n" 812 " preload 62.34;# comment\n" 815 REQUIRE(root !=
nullptr);
819 ":002: | preload 62.34\n");
821 SECTION(
"Missing end of statement.")
823 tao::pegtl::string_input<> in(
827 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
830 ":3:0(27): expected end of statement ';' character");
832 SECTION(
"Invalid MAVLink address.")
834 tao::pegtl::string_input<> in(
838 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
841 ":2:14(23): expected a valid MAVLink address");
843 SECTION(
"Missing MAVLink address.")
845 tao::pegtl::string_input<> in(
849 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
852 ":2:11(20): expected a valid MAVLink address");
859 SECTION(
"Empty chain blocks are allowed (single line).")
861 tao::pegtl::string_input<> in(
"chain some_name10 {}",
"");
863 REQUIRE(root !=
nullptr);
864 REQUIRE(
str(*root) ==
":001: chain some_name10\n");
866 SECTION(
"Empty chain blocks are allowed (single line with comments).")
868 tao::pegtl::string_input<> in(
"chain some_name10 {}# comment",
"");
870 REQUIRE(root !=
nullptr);
871 REQUIRE(
str(*root) ==
":001: chain some_name10\n");
873 SECTION(
"Empty chain blocks are allowed (1TBS style).")
875 tao::pegtl::string_input<> in(
"chain some_name10 {\n}",
"");
877 REQUIRE(root !=
nullptr);
878 REQUIRE(
str(*root) ==
":001: chain some_name10\n");
880 SECTION(
"Empty chain blocks are allowed (1TBS style with comments).")
882 tao::pegtl::string_input<> in(
883 "chain some_name10 {# comment\n}# comment",
"");
885 REQUIRE(root !=
nullptr);
886 REQUIRE(
str(*root) ==
":001: chain some_name10\n");
888 SECTION(
"Empty chain blocks are allowed (Allman style).")
890 tao::pegtl::string_input<> in(
"chain some_name10\n{\n}",
"");
892 REQUIRE(root !=
nullptr);
893 REQUIRE(
str(*root) ==
":001: chain some_name10\n");
895 SECTION(
"Empty chain blocks are allowed (Allman style with comments).")
897 tao::pegtl::string_input<> in(
898 "chain some_name10# comment\n{# comment\n}# comment",
"");
900 REQUIRE(root !=
nullptr);
901 REQUIRE(
str(*root) ==
":001: chain some_name10\n");
903 SECTION(
"Chains must have a name.")
905 tao::pegtl::string_input<> in(
"chain {}",
"");
906 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
910 SECTION(
"Chain names must be valid.")
912 tao::pegtl::string_input<> in(
"chain 1nv@l1d {}",
"");
913 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
917 SECTION(
"Missing opening brace (closing brace exists).")
919 tao::pegtl::string_input<> in(
"chain some_name10 }",
"");
920 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
924 SECTION(
"Missing opening brace (closing brace missing).")
926 tao::pegtl::string_input<> in(
"chain some_name10",
"");
927 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
931 SECTION(
"Missing closing brace.")
933 tao::pegtl::string_input<> in(
"chain some_name10 {",
"");
934 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
943 SECTION(
"Parses 'reject' rule.")
945 tao::pegtl::string_input<> in(
949 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
952 ":3:0(29): expected a valid rule");
959 SECTION(
"Parses 'accept' rule.")
961 tao::pegtl::string_input<> in(
966 REQUIRE(root !=
nullptr);
969 ":001: chain default\n" 972 SECTION(
"Parses 'accept' rule (with comments).")
974 tao::pegtl::string_input<> in(
975 "chain default {# comment\n" 976 " accept;# comment\n" 979 REQUIRE(root !=
nullptr);
982 ":001: chain default\n" 985 SECTION(
"Missing end of statement.")
987 tao::pegtl::string_input<> in(
991 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
994 ":2:10(26): expected end of statement ';' character");
1001 SECTION(
"Parses 'reject' rule.")
1003 tao::pegtl::string_input<> in(
1008 REQUIRE(root !=
nullptr);
1011 ":001: chain default\n" 1012 ":002: | reject\n");
1014 SECTION(
"Parses 'reject' rule (with comments).")
1016 tao::pegtl::string_input<> in(
1017 "chain default {# comment\n" 1018 " reject;# comment\n" 1021 REQUIRE(root !=
nullptr);
1024 ":001: chain default\n" 1025 ":002: | reject\n");
1027 SECTION(
"Missing end of statement.")
1029 tao::pegtl::string_input<> in(
1033 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1034 REQUIRE_THROWS_WITH(
1036 ":2:10(26): expected end of statement ';' character");
1043 SECTION(
"Parses 'call' rule.")
1045 tao::pegtl::string_input<> in(
1047 " call some_name10;\n" 1050 REQUIRE(root !=
nullptr);
1053 ":001: chain default\n" 1054 ":002: | call some_name10\n");
1056 SECTION(
"Parses 'call' rule (with comments).")
1058 tao::pegtl::string_input<> in(
1059 "chain default {# comment\n" 1060 " call some_name10;# comment\n" 1063 REQUIRE(root !=
nullptr);
1066 ":001: chain default\n" 1067 ":002: | call some_name10\n");
1069 SECTION(
"Missing end of statement.")
1071 tao::pegtl::string_input<> in(
1073 " call some_name10\n" 1075 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1076 REQUIRE_THROWS_WITH(
1078 ":3:0(37): expected end of statement ';' character");
1080 SECTION(
"Invalid chain name.")
1082 tao::pegtl::string_input<> in(
1086 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1087 REQUIRE_THROWS_WITH(
1089 ":2:9(25): expected a valid chain name");
1091 SECTION(
"Missing chain name.")
1093 tao::pegtl::string_input<> in(
1097 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1098 REQUIRE_THROWS_WITH(
1100 ":2:8(24): expected a valid chain name");
1107 SECTION(
"Parses 'goto' rule.")
1109 tao::pegtl::string_input<> in(
1111 " goto some_name10;\n" 1114 REQUIRE(root !=
nullptr);
1117 ":001: chain default\n" 1118 ":002: | goto some_name10\n");
1120 SECTION(
"Parses 'goto' rule (with comments).")
1122 tao::pegtl::string_input<> in(
1123 "chain default {# comment\n" 1124 " goto some_name10;# comment\n" 1127 REQUIRE(root !=
nullptr);
1130 ":001: chain default\n" 1131 ":002: | goto some_name10\n");
1133 SECTION(
"Missing end of statement.")
1135 tao::pegtl::string_input<> in(
1137 " goto some_name10\n" 1139 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1140 REQUIRE_THROWS_WITH(
1142 ":3:0(37): expected end of statement ';' character");
1144 SECTION(
"Invalid chain name.")
1146 tao::pegtl::string_input<> in(
1150 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1151 REQUIRE_THROWS_WITH(
1153 ":2:9(25): expected a valid chain name");
1155 SECTION(
"Missing chain name.")
1157 tao::pegtl::string_input<> in(
1161 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1162 REQUIRE_THROWS_WITH(
1164 ":2:8(24): expected a valid chain name");
1171 SECTION(
"Conditions must have at least one restriction.")
1173 tao::pegtl::string_input<> in(
1177 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1178 REQUIRE_THROWS_WITH(
1180 ":2:13(29): condition is empty or invalid");
1187 SECTION(
"Parses packet type condition.")
1189 tao::pegtl::string_input<> in(
1191 " accept if PING;\n" 1194 REQUIRE(root !=
nullptr);
1197 ":001: chain default\n" 1199 ":002: | | condition\n" 1200 ":002: | | | packet_type PING\n");
1202 SECTION(
"Parses packet type condition (with number).")
1204 tao::pegtl::string_input<> in(
1206 " accept if SCALED_PRESSURE3;\n" 1209 REQUIRE(root !=
nullptr);
1212 ":001: chain default\n" 1214 ":002: | | condition\n" 1215 ":002: | | | packet_type SCALED_PRESSURE3\n");
1217 SECTION(
"Parses packet type condition (with comments).")
1219 tao::pegtl::string_input<> in(
1220 "chain default {# comment\n" 1221 " accept if PING;# comment\n" 1224 REQUIRE(root !=
nullptr);
1227 ":001: chain default\n" 1229 ":002: | | condition\n" 1230 ":002: | | | packet_type PING\n");
1232 SECTION(
"Invalid packet type [1].")
1234 tao::pegtl::string_input<> in(
1236 " accept if ping;\n" 1238 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1239 REQUIRE_THROWS_WITH(
1241 ":2:14(30): condition is empty or invalid");
1243 SECTION(
"Invalid packet type [2].")
1245 tao::pegtl::string_input<> in(
1249 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1250 REQUIRE_THROWS_WITH(
1252 ":2:14(30): condition is empty or invalid");
1259 SECTION(
"Parses source condition [1].")
1261 tao::pegtl::string_input<> in(
1263 " accept if from 192.0;\n" 1266 REQUIRE(root !=
nullptr);
1269 ":001: chain default\n" 1271 ":002: | | condition\n" 1272 ":002: | | | source 192.0\n");
1274 SECTION(
"Parses source condition (with comments) [1].")
1276 tao::pegtl::string_input<> in(
1277 "chain default {# comment\n" 1278 " accept if from 192.0;# comment\n" 1281 REQUIRE(root !=
nullptr);
1284 ":001: chain default\n" 1286 ":002: | | condition\n" 1287 ":002: | | | source 192.0\n");
1289 SECTION(
"Parses source condition [2].")
1291 tao::pegtl::string_input<> in(
1293 " accept if from 192.0/8;\n" 1296 REQUIRE(root !=
nullptr);
1299 ":001: chain default\n" 1301 ":002: | | condition\n" 1302 ":002: | | | source 192.0/8\n");
1304 SECTION(
"Parses source condition (with comments) [2].")
1306 tao::pegtl::string_input<> in(
1307 "chain default {# comment\n" 1308 " accept if from 192.0/8;# comment\n" 1311 REQUIRE(root !=
nullptr);
1314 ":001: chain default\n" 1316 ":002: | | condition\n" 1317 ":002: | | | source 192.0/8\n");
1319 SECTION(
"Parses source condition [3].")
1321 tao::pegtl::string_input<> in(
1323 " accept if from 192.0\\4;\n" 1326 REQUIRE(root !=
nullptr);
1329 ":001: chain default\n" 1331 ":002: | | condition\n" 1332 ":002: | | | source 192.0\\4\n");
1334 SECTION(
"Parses source condition (with comments) [3].")
1336 tao::pegtl::string_input<> in(
1337 "chain default {# comment\n" 1338 " accept if from 192.0\\4;# comment\n" 1341 REQUIRE(root !=
nullptr);
1344 ":001: chain default\n" 1346 ":002: | | condition\n" 1347 ":002: | | | source 192.0\\4\n");
1349 SECTION(
"Parses source condition [4].")
1351 tao::pegtl::string_input<> in(
1353 " accept if from 192.0:255.255;\n" 1356 REQUIRE(root !=
nullptr);
1359 ":001: chain default\n" 1361 ":002: | | condition\n" 1362 ":002: | | | source 192.0:255.255\n");
1364 SECTION(
"Parses source condition (with comments) [4].")
1366 tao::pegtl::string_input<> in(
1367 "chain default {# comment\n" 1368 " accept if from 192.0:255.255;# comment\n" 1371 REQUIRE(root !=
nullptr);
1374 ":001: chain default\n" 1376 ":002: | | condition\n" 1377 ":002: | | | source 192.0:255.255\n");
1379 SECTION(
"Invalid source condition [1].")
1381 tao::pegtl::string_input<> in(
1383 " accept if from 192;\n" 1385 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1386 REQUIRE_THROWS_WITH(
1388 ":2:22(38): expected a valid MAVLink subnet");
1390 SECTION(
"Invalid source condition [2].")
1392 tao::pegtl::string_input<> in(
1394 " accept if from 192/8;\n" 1396 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1397 REQUIRE_THROWS_WITH(
1399 ":2:22(38): expected a valid MAVLink subnet");
1401 SECTION(
"Invalid source condition [3].")
1403 tao::pegtl::string_input<> in(
1405 " accept if from 192\\8;\n" 1407 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1408 REQUIRE_THROWS_WITH(
1410 ":2:22(38): expected a valid MAVLink subnet");
1412 SECTION(
"Invalid source condition [4].")
1414 tao::pegtl::string_input<> in(
1416 " accept if from 192:255.255;\n" 1418 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1419 REQUIRE_THROWS_WITH(
1421 ":2:22(38): expected a valid MAVLink subnet");
1428 SECTION(
"Parses destination condition [1].")
1430 tao::pegtl::string_input<> in(
1432 " accept if to 192.0;\n" 1435 REQUIRE(root !=
nullptr);
1438 ":001: chain default\n" 1440 ":002: | | condition\n" 1441 ":002: | | | dest 192.0\n");
1443 SECTION(
"Parses destination condition (with comments) [1].")
1445 tao::pegtl::string_input<> in(
1446 "chain default {# comment\n" 1447 " accept if to 192.0;# comment\n" 1450 REQUIRE(root !=
nullptr);
1453 ":001: chain default\n" 1455 ":002: | | condition\n" 1456 ":002: | | | dest 192.0\n");
1458 SECTION(
"Parses destination condition [2].")
1460 tao::pegtl::string_input<> in(
1462 " accept if to 192.0/8;\n" 1465 REQUIRE(root !=
nullptr);
1468 ":001: chain default\n" 1470 ":002: | | condition\n" 1471 ":002: | | | dest 192.0/8\n");
1473 SECTION(
"Parses destination condition (with comments) [2].")
1475 tao::pegtl::string_input<> in(
1476 "chain default {# comment\n" 1477 " accept if to 192.0/8;# comment\n" 1480 REQUIRE(root !=
nullptr);
1483 ":001: chain default\n" 1485 ":002: | | condition\n" 1486 ":002: | | | dest 192.0/8\n");
1488 SECTION(
"Parses destination condition [3].")
1490 tao::pegtl::string_input<> in(
1492 " accept if to 192.0\\4;\n" 1495 REQUIRE(root !=
nullptr);
1498 ":001: chain default\n" 1500 ":002: | | condition\n" 1501 ":002: | | | dest 192.0\\4\n");
1503 SECTION(
"Parses destination condition (with comments) [3].")
1505 tao::pegtl::string_input<> in(
1506 "chain default {# comment\n" 1507 " accept if to 192.0\\4;# comment\n" 1510 REQUIRE(root !=
nullptr);
1513 ":001: chain default\n" 1515 ":002: | | condition\n" 1516 ":002: | | | dest 192.0\\4\n");
1518 SECTION(
"Parses destination condition [4].")
1520 tao::pegtl::string_input<> in(
1522 " accept if to 192.0:255.255;\n" 1525 REQUIRE(root !=
nullptr);
1528 ":001: chain default\n" 1530 ":002: | | condition\n" 1531 ":002: | | | dest 192.0:255.255\n");
1533 SECTION(
"Parses destination condition (with comments) [4].")
1535 tao::pegtl::string_input<> in(
1536 "chain default {# comment\n" 1537 " accept if to 192.0:255.255;# comment\n" 1540 REQUIRE(root !=
nullptr);
1543 ":001: chain default\n" 1545 ":002: | | condition\n" 1546 ":002: | | | dest 192.0:255.255\n");
1548 SECTION(
"Invalid destination condition [1].")
1550 tao::pegtl::string_input<> in(
1552 " accept if to 192;\n" 1554 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1555 REQUIRE_THROWS_WITH(
1557 ":2:20(36): expected a valid MAVLink subnet");
1559 SECTION(
"Invalid destination condition [2].")
1561 tao::pegtl::string_input<> in(
1563 " accept if to 192/8;\n" 1565 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1566 REQUIRE_THROWS_WITH(
1568 ":2:20(36): expected a valid MAVLink subnet");
1570 SECTION(
"Invalid destination condition [3].")
1572 tao::pegtl::string_input<> in(
1574 " accept if to 192\\8;\n" 1576 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1577 REQUIRE_THROWS_WITH(
1579 ":2:20(36): expected a valid MAVLink subnet");
1581 SECTION(
"Invalid destination condition [4].")
1583 tao::pegtl::string_input<> in(
1585 " accept if to 192:255.255;\n" 1587 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1588 REQUIRE_THROWS_WITH(
1590 ":2:20(36): expected a valid MAVLink subnet");
1597 SECTION(
"Parses priority (no sign).")
1599 tao::pegtl::string_input<> in(
1601 " accept with priority 99;\n" 1604 REQUIRE(root !=
nullptr);
1607 ":001: chain default\n" 1609 ":002: | | priority 99\n");
1611 SECTION(
"Parses priority (no sign with comments).")
1613 tao::pegtl::string_input<> in(
1614 "chain default {# comment\n" 1615 " accept with priority 99;# comment\n" 1618 REQUIRE(root !=
nullptr);
1621 ":001: chain default\n" 1623 ":002: | | priority 99\n");
1625 SECTION(
"Parses priority (positive).")
1627 tao::pegtl::string_input<> in(
1629 " accept with priority +99;\n" 1632 REQUIRE(root !=
nullptr);
1635 ":001: chain default\n" 1637 ":002: | | priority +99\n");
1639 SECTION(
"Parses priority (positive with comments).")
1641 tao::pegtl::string_input<> in(
1642 "chain default {# comment\n" 1643 " accept with priority +99;# comment\n" 1646 REQUIRE(root !=
nullptr);
1649 ":001: chain default\n" 1651 ":002: | | priority +99\n");
1653 SECTION(
"Parses priority (negative).")
1655 tao::pegtl::string_input<> in(
1657 " accept with priority -99;\n" 1660 REQUIRE(root !=
nullptr);
1663 ":001: chain default\n" 1665 ":002: | | priority -99\n");
1667 SECTION(
"Parses priority (negative with comments).")
1669 tao::pegtl::string_input<> in(
1670 "chain default {# comment\n" 1671 " accept with priority -99;# comment\n" 1674 REQUIRE(root !=
nullptr);
1677 ":001: chain default\n" 1679 ":002: | | priority -99\n");
1681 SECTION(
"'with priority' must be followed by a valid priority.")
1683 tao::pegtl::string_input<> in(
1685 " accept with priority *99;\n" 1687 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1688 REQUIRE_THROWS_WITH(
1690 ":2:25(41): expected priority level");
1692 SECTION(
"'with priority' must be followed by a priority.")
1694 tao::pegtl::string_input<> in(
1696 " accept with priority;\n" 1698 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1699 REQUIRE_THROWS_WITH(
1701 ":2:24(40): expected priority level");
1703 SECTION(
"'with' must be followed by 'priority'.")
1705 tao::pegtl::string_input<> in(
1709 REQUIRE_THROWS_AS(
config::parse(in), tao::pegtl::parse_error);
1710 REQUIRE_THROWS_WITH(
1712 ":2:15(31): 'with' keyword must be followed by the " 1713 "'priority' keyword");
1722 tao::pegtl::string_input<> in(
1727 REQUIRE(root !=
nullptr);
1730 ":001: chain default\n" 1731 ":002: | accept\n");
1733 SECTION(
"accept if PING")
1735 tao::pegtl::string_input<> in(
1737 " accept if PING;\n" 1740 REQUIRE(root !=
nullptr);
1743 ":001: chain default\n" 1745 ":002: | | condition\n" 1746 ":002: | | | packet_type PING\n");
1748 SECTION(
"accept if PING from 127.1")
1750 tao::pegtl::string_input<> in(
1752 " accept if PING from 127.1;\n" 1755 REQUIRE(root !=
nullptr);
1758 ":001: chain default\n" 1760 ":002: | | condition\n" 1761 ":002: | | | packet_type PING\n" 1762 ":002: | | | source 127.1\n");
1764 SECTION(
"accept if PING to 192.0")
1766 tao::pegtl::string_input<> in(
1768 " accept if PING to 192.0;\n" 1771 REQUIRE(root !=
nullptr);
1774 ":001: chain default\n" 1776 ":002: | | condition\n" 1777 ":002: | | | packet_type PING\n" 1778 ":002: | | | dest 192.0\n");
1780 SECTION(
"accept if PING from 127.1 to 192.0")
1782 tao::pegtl::string_input<> in(
1784 " accept if PING from 127.1 to 192.0;\n" 1787 REQUIRE(root !=
nullptr);
1790 ":001: chain default\n" 1792 ":002: | | condition\n" 1793 ":002: | | | packet_type PING\n" 1794 ":002: | | | source 127.1\n" 1795 ":002: | | | dest 192.0\n");
1797 SECTION(
"accept if from 127.1")
1799 tao::pegtl::string_input<> in(
1801 " accept if from 127.1;\n" 1804 REQUIRE(root !=
nullptr);
1807 ":001: chain default\n" 1809 ":002: | | condition\n" 1810 ":002: | | | source 127.1\n");
1812 SECTION(
"accept if to 192.0")
1814 tao::pegtl::string_input<> in(
1816 " accept if to 192.0;\n" 1819 REQUIRE(root !=
nullptr);
1822 ":001: chain default\n" 1824 ":002: | | condition\n" 1825 ":002: | | | dest 192.0\n");
1827 SECTION(
"accept if from 127.1 to 192.0")
1829 tao::pegtl::string_input<> in(
1831 " accept if from 127.1 to 192.0;\n" 1834 REQUIRE(root !=
nullptr);
1837 ":001: chain default\n" 1839 ":002: | | condition\n" 1840 ":002: | | | source 127.1\n" 1841 ":002: | | | dest 192.0\n");
1843 SECTION(
"accept with priority 99")
1845 tao::pegtl::string_input<> in(
1847 " accept with priority 99 if to 192.0;\n" 1850 REQUIRE(root !=
nullptr);
1853 ":001: chain default\n" 1855 ":002: | | priority 99\n" 1856 ":002: | | condition\n" 1857 ":002: | | | dest 192.0\n");
1859 SECTION(
"accept with priority 99 if PING")
1861 tao::pegtl::string_input<> in(
1863 " accept with priority 99 if PING;\n" 1866 REQUIRE(root !=
nullptr);
1869 ":001: chain default\n" 1871 ":002: | | priority 99\n" 1872 ":002: | | condition\n" 1873 ":002: | | | packet_type PING\n");
1875 SECTION(
"accept with priority 99 if PING from 127.1")
1877 tao::pegtl::string_input<> in(
1879 " accept with priority 99 if PING from 127.1;\n" 1882 REQUIRE(root !=
nullptr);
1885 ":001: chain default\n" 1887 ":002: | | priority 99\n" 1888 ":002: | | condition\n" 1889 ":002: | | | packet_type PING\n" 1890 ":002: | | | source 127.1\n");
1892 SECTION(
"accept with priority 99 if PING to 192.0")
1894 tao::pegtl::string_input<> in(
1896 " accept with priority 99 if PING to 192.0;\n" 1899 REQUIRE(root !=
nullptr);
1902 ":001: chain default\n" 1904 ":002: | | priority 99\n" 1905 ":002: | | condition\n" 1906 ":002: | | | packet_type PING\n" 1907 ":002: | | | dest 192.0\n");
1909 SECTION(
"accept with priority 99 if PING from 127.1 to 192.0")
1911 tao::pegtl::string_input<> in(
1913 " accept with priority 99 if PING from 127.1 to 192.0;\n" 1916 REQUIRE(root !=
nullptr);
1919 ":001: chain default\n" 1921 ":002: | | priority 99\n" 1922 ":002: | | condition\n" 1923 ":002: | | | packet_type PING\n" 1924 ":002: | | | source 127.1\n" 1925 ":002: | | | dest 192.0\n");
1927 SECTION(
"accept with priority 99 if from 127.1")
1929 tao::pegtl::string_input<> in(
1931 " accept with priority 99 if from 127.1;\n" 1934 REQUIRE(root !=
nullptr);
1937 ":001: chain default\n" 1939 ":002: | | priority 99\n" 1940 ":002: | | condition\n" 1941 ":002: | | | source 127.1\n");
1943 SECTION(
"accept with priority 99 if to 192.0")
1945 tao::pegtl::string_input<> in(
1947 " accept with priority 99 if to 192.0;\n" 1950 REQUIRE(root !=
nullptr);
1953 ":001: chain default\n" 1955 ":002: | | priority 99\n" 1956 ":002: | | condition\n" 1957 ":002: | | | dest 192.0\n");
1959 SECTION(
"accept with priority 99 if from 127.1 to 192.0")
1961 tao::pegtl::string_input<> in(
1963 " accept with priority 99 if from 127.1 to 192.0;\n" 1966 REQUIRE(root !=
nullptr);
1969 ":001: chain default\n" 1971 ":002: | | priority 99\n" 1972 ":002: | | condition\n" 1973 ":002: | | | source 127.1\n" 1974 ":002: | | | dest 192.0\n");
1983 tao::pegtl::string_input<> in(
1988 REQUIRE(root !=
nullptr);
1991 ":001: chain default\n" 1992 ":002: | reject\n");
1994 SECTION(
"reject if PING.")
1996 tao::pegtl::string_input<> in(
1998 " reject if PING;\n" 2001 REQUIRE(root !=
nullptr);
2004 ":001: chain default\n" 2006 ":002: | | condition\n" 2007 ":002: | | | packet_type PING\n");
2009 SECTION(
"reject if PING from 127.1")
2011 tao::pegtl::string_input<> in(
2013 " reject if PING from 127.1;\n" 2016 REQUIRE(root !=
nullptr);
2019 ":001: chain default\n" 2021 ":002: | | condition\n" 2022 ":002: | | | packet_type PING\n" 2023 ":002: | | | source 127.1\n");
2025 SECTION(
"reject if PING to 192.0")
2027 tao::pegtl::string_input<> in(
2029 " reject if PING to 192.0;\n" 2032 REQUIRE(root !=
nullptr);
2035 ":001: chain default\n" 2037 ":002: | | condition\n" 2038 ":002: | | | packet_type PING\n" 2039 ":002: | | | dest 192.0\n");
2041 SECTION(
"reject if PING from 127.1 to 192.0")
2043 tao::pegtl::string_input<> in(
2045 " reject if PING from 127.1 to 192.0;\n" 2048 REQUIRE(root !=
nullptr);
2051 ":001: chain default\n" 2053 ":002: | | condition\n" 2054 ":002: | | | packet_type PING\n" 2055 ":002: | | | source 127.1\n" 2056 ":002: | | | dest 192.0\n");
2058 SECTION(
"reject if from 127.1")
2060 tao::pegtl::string_input<> in(
2062 " reject if from 127.1;\n" 2065 REQUIRE(root !=
nullptr);
2068 ":001: chain default\n" 2070 ":002: | | condition\n" 2071 ":002: | | | source 127.1\n");
2073 SECTION(
"reject if to 192.0")
2075 tao::pegtl::string_input<> in(
2077 " reject if to 192.0;\n" 2080 REQUIRE(root !=
nullptr);
2083 ":001: chain default\n" 2085 ":002: | | condition\n" 2086 ":002: | | | dest 192.0\n");
2088 SECTION(
"reject if from 127.1 to 192.0")
2090 tao::pegtl::string_input<> in(
2092 " reject if from 127.1 to 192.0;\n" 2095 REQUIRE(root !=
nullptr);
2098 ":001: chain default\n" 2100 ":002: | | condition\n" 2101 ":002: | | | source 127.1\n" 2102 ":002: | | | dest 192.0\n");
2104 SECTION(
"reject with priority 99")
2106 tao::pegtl::string_input<> in(
2108 " reject with priority 99 if to 192.0;\n" 2111 REQUIRE(root !=
nullptr);
2114 ":001: chain default\n" 2116 ":002: | | priority 99\n" 2117 ":002: | | condition\n" 2118 ":002: | | | dest 192.0\n");
2120 SECTION(
"reject with priority 99 if PING")
2122 tao::pegtl::string_input<> in(
2124 " reject with priority 99 if PING;\n" 2127 REQUIRE(root !=
nullptr);
2130 ":001: chain default\n" 2132 ":002: | | priority 99\n" 2133 ":002: | | condition\n" 2134 ":002: | | | packet_type PING\n");
2136 SECTION(
"reject with priority 99 if PING from 127.1")
2138 tao::pegtl::string_input<> in(
2140 " reject with priority 99 if PING from 127.1;\n" 2143 REQUIRE(root !=
nullptr);
2146 ":001: chain default\n" 2148 ":002: | | priority 99\n" 2149 ":002: | | condition\n" 2150 ":002: | | | packet_type PING\n" 2151 ":002: | | | source 127.1\n");
2153 SECTION(
"reject with priority 99 if PING to 192.0")
2155 tao::pegtl::string_input<> in(
2157 " reject with priority 99 if PING to 192.0;\n" 2160 REQUIRE(root !=
nullptr);
2163 ":001: chain default\n" 2165 ":002: | | priority 99\n" 2166 ":002: | | condition\n" 2167 ":002: | | | packet_type PING\n" 2168 ":002: | | | dest 192.0\n");
2170 SECTION(
"reject with priority 99 if PING from 127.1 to 192.0")
2172 tao::pegtl::string_input<> in(
2174 " reject with priority 99 if PING from 127.1 to 192.0;\n" 2177 REQUIRE(root !=
nullptr);
2180 ":001: chain default\n" 2182 ":002: | | priority 99\n" 2183 ":002: | | condition\n" 2184 ":002: | | | packet_type PING\n" 2185 ":002: | | | source 127.1\n" 2186 ":002: | | | dest 192.0\n");
2188 SECTION(
"reject with priority 99 if from 127.1")
2190 tao::pegtl::string_input<> in(
2192 " reject with priority 99 if from 127.1;\n" 2195 REQUIRE(root !=
nullptr);
2198 ":001: chain default\n" 2200 ":002: | | priority 99\n" 2201 ":002: | | condition\n" 2202 ":002: | | | source 127.1\n");
2204 SECTION(
"reject with priority 99 if to 192.0")
2206 tao::pegtl::string_input<> in(
2208 " reject with priority 99 if to 192.0;\n" 2211 REQUIRE(root !=
nullptr);
2214 ":001: chain default\n" 2216 ":002: | | priority 99\n" 2217 ":002: | | condition\n" 2218 ":002: | | | dest 192.0\n");
2220 SECTION(
"reject with priority 99 if from 127.1 to 192.0")
2222 tao::pegtl::string_input<> in(
2224 " reject with priority 99 if from 127.1 to 192.0;\n" 2227 REQUIRE(root !=
nullptr);
2230 ":001: chain default\n" 2232 ":002: | | priority 99\n" 2233 ":002: | | condition\n" 2234 ":002: | | | source 127.1\n" 2235 ":002: | | | dest 192.0\n");
2242 SECTION(
"call some_name10")
2244 tao::pegtl::string_input<> in(
2246 " call some_name10;\n" 2249 REQUIRE(root !=
nullptr);
2252 ":001: chain default\n" 2253 ":002: | call some_name10\n");
2255 SECTION(
"call some_name10 if PING.")
2257 tao::pegtl::string_input<> in(
2259 " call some_name10 if PING;\n" 2262 REQUIRE(root !=
nullptr);
2265 ":001: chain default\n" 2266 ":002: | call some_name10\n" 2267 ":002: | | condition\n" 2268 ":002: | | | packet_type PING\n");
2270 SECTION(
"call some_name10 if PING from 127.1")
2272 tao::pegtl::string_input<> in(
2274 " call some_name10 if PING from 127.1;\n" 2277 REQUIRE(root !=
nullptr);
2280 ":001: chain default\n" 2281 ":002: | call some_name10\n" 2282 ":002: | | condition\n" 2283 ":002: | | | packet_type PING\n" 2284 ":002: | | | source 127.1\n");
2286 SECTION(
"call some_name10 if PING to 192.0")
2288 tao::pegtl::string_input<> in(
2290 " call some_name10 if PING to 192.0;\n" 2293 REQUIRE(root !=
nullptr);
2296 ":001: chain default\n" 2297 ":002: | call some_name10\n" 2298 ":002: | | condition\n" 2299 ":002: | | | packet_type PING\n" 2300 ":002: | | | dest 192.0\n");
2302 SECTION(
"call some_name10 if PING from 127.1 to 192.0")
2304 tao::pegtl::string_input<> in(
2306 " call some_name10 if PING from 127.1 to 192.0;\n" 2309 REQUIRE(root !=
nullptr);
2312 ":001: chain default\n" 2313 ":002: | call some_name10\n" 2314 ":002: | | condition\n" 2315 ":002: | | | packet_type PING\n" 2316 ":002: | | | source 127.1\n" 2317 ":002: | | | dest 192.0\n");
2319 SECTION(
"call some_name10 if from 127.1")
2321 tao::pegtl::string_input<> in(
2323 " call some_name10 if from 127.1;\n" 2326 REQUIRE(root !=
nullptr);
2329 ":001: chain default\n" 2330 ":002: | call some_name10\n" 2331 ":002: | | condition\n" 2332 ":002: | | | source 127.1\n");
2334 SECTION(
"call some_name10 if to 192.0")
2336 tao::pegtl::string_input<> in(
2338 " call some_name10 if to 192.0;\n" 2341 REQUIRE(root !=
nullptr);
2344 ":001: chain default\n" 2345 ":002: | call some_name10\n" 2346 ":002: | | condition\n" 2347 ":002: | | | dest 192.0\n");
2349 SECTION(
"call some_name10 if from 127.1 to 192.0")
2351 tao::pegtl::string_input<> in(
2353 " call some_name10 if from 127.1 to 192.0;\n" 2356 REQUIRE(root !=
nullptr);
2359 ":001: chain default\n" 2360 ":002: | call some_name10\n" 2361 ":002: | | condition\n" 2362 ":002: | | | source 127.1\n" 2363 ":002: | | | dest 192.0\n");
2365 SECTION(
"call some_name10 with priority 99")
2367 tao::pegtl::string_input<> in(
2369 " call some_name10 with priority 99 if to 192.0;\n" 2372 REQUIRE(root !=
nullptr);
2375 ":001: chain default\n" 2376 ":002: | call some_name10\n" 2377 ":002: | | priority 99\n" 2378 ":002: | | condition\n" 2379 ":002: | | | dest 192.0\n");
2381 SECTION(
"call some_name10 with priority 99 if PING")
2383 tao::pegtl::string_input<> in(
2385 " call some_name10 with priority 99 if PING;\n" 2388 REQUIRE(root !=
nullptr);
2391 ":001: chain default\n" 2392 ":002: | call some_name10\n" 2393 ":002: | | priority 99\n" 2394 ":002: | | condition\n" 2395 ":002: | | | packet_type PING\n");
2397 SECTION(
"call some_name10 with priority 99 if PING from 127.1")
2399 tao::pegtl::string_input<> in(
2401 " call some_name10 with priority 99 if PING from 127.1;\n" 2404 REQUIRE(root !=
nullptr);
2407 ":001: chain default\n" 2408 ":002: | call some_name10\n" 2409 ":002: | | priority 99\n" 2410 ":002: | | condition\n" 2411 ":002: | | | packet_type PING\n" 2412 ":002: | | | source 127.1\n");
2414 SECTION(
"call some_name10 with priority 99 if PING to 192.0")
2416 tao::pegtl::string_input<> in(
2418 " call some_name10 with priority 99 if PING to 192.0;\n" 2421 REQUIRE(root !=
nullptr);
2424 ":001: chain default\n" 2425 ":002: | call some_name10\n" 2426 ":002: | | priority 99\n" 2427 ":002: | | condition\n" 2428 ":002: | | | packet_type PING\n" 2429 ":002: | | | dest 192.0\n");
2431 SECTION(
"call some_name10 with priority 99 if PING from 127.1 to 192.0")
2433 tao::pegtl::string_input<> in(
2435 " call some_name10 with priority 99 " 2436 "if PING from 127.1 to 192.0;\n" 2439 REQUIRE(root !=
nullptr);
2442 ":001: chain default\n" 2443 ":002: | call some_name10\n" 2444 ":002: | | priority 99\n" 2445 ":002: | | condition\n" 2446 ":002: | | | packet_type PING\n" 2447 ":002: | | | source 127.1\n" 2448 ":002: | | | dest 192.0\n");
2450 SECTION(
"call some_name10 with priority 99 if from 127.1")
2452 tao::pegtl::string_input<> in(
2454 " call some_name10 with priority 99 if from 127.1;\n" 2457 REQUIRE(root !=
nullptr);
2460 ":001: chain default\n" 2461 ":002: | call some_name10\n" 2462 ":002: | | priority 99\n" 2463 ":002: | | condition\n" 2464 ":002: | | | source 127.1\n");
2466 SECTION(
"call some_name10 with priority 99 if to 192.0")
2468 tao::pegtl::string_input<> in(
2470 " call some_name10 with priority 99 if to 192.0;\n" 2473 REQUIRE(root !=
nullptr);
2476 ":001: chain default\n" 2477 ":002: | call some_name10\n" 2478 ":002: | | priority 99\n" 2479 ":002: | | condition\n" 2480 ":002: | | | dest 192.0\n");
2482 SECTION(
"call some_name10 with priority 99 if from 127.1 to 192.0")
2484 tao::pegtl::string_input<> in(
2486 " call some_name10 with priority 99 if from 127.1 to 192.0;\n" 2489 REQUIRE(root !=
nullptr);
2492 ":001: chain default\n" 2493 ":002: | call some_name10\n" 2494 ":002: | | priority 99\n" 2495 ":002: | | condition\n" 2496 ":002: | | | source 127.1\n" 2497 ":002: | | | dest 192.0\n");
2504 SECTION(
"goto some_name10")
2506 tao::pegtl::string_input<> in(
2508 " goto some_name10;\n" 2511 REQUIRE(root !=
nullptr);
2514 ":001: chain default\n" 2515 ":002: | goto some_name10\n");
2517 SECTION(
"goto some_name10 if PING.")
2519 tao::pegtl::string_input<> in(
2521 " goto some_name10 if PING;\n" 2524 REQUIRE(root !=
nullptr);
2527 ":001: chain default\n" 2528 ":002: | goto some_name10\n" 2529 ":002: | | condition\n" 2530 ":002: | | | packet_type PING\n");
2532 SECTION(
"goto some_name10 if PING from 127.1")
2534 tao::pegtl::string_input<> in(
2536 " goto some_name10 if PING from 127.1;\n" 2539 REQUIRE(root !=
nullptr);
2542 ":001: chain default\n" 2543 ":002: | goto some_name10\n" 2544 ":002: | | condition\n" 2545 ":002: | | | packet_type PING\n" 2546 ":002: | | | source 127.1\n");
2548 SECTION(
"goto some_name10 if PING to 192.0")
2550 tao::pegtl::string_input<> in(
2552 " goto some_name10 if PING to 192.0;\n" 2555 REQUIRE(root !=
nullptr);
2558 ":001: chain default\n" 2559 ":002: | goto some_name10\n" 2560 ":002: | | condition\n" 2561 ":002: | | | packet_type PING\n" 2562 ":002: | | | dest 192.0\n");
2564 SECTION(
"goto some_name10 if PING from 127.1 to 192.0")
2566 tao::pegtl::string_input<> in(
2568 " goto some_name10 if PING from 127.1 to 192.0;\n" 2571 REQUIRE(root !=
nullptr);
2574 ":001: chain default\n" 2575 ":002: | goto some_name10\n" 2576 ":002: | | condition\n" 2577 ":002: | | | packet_type PING\n" 2578 ":002: | | | source 127.1\n" 2579 ":002: | | | dest 192.0\n");
2581 SECTION(
"goto some_name10 if from 127.1")
2583 tao::pegtl::string_input<> in(
2585 " goto some_name10 if from 127.1;\n" 2588 REQUIRE(root !=
nullptr);
2591 ":001: chain default\n" 2592 ":002: | goto some_name10\n" 2593 ":002: | | condition\n" 2594 ":002: | | | source 127.1\n");
2596 SECTION(
"goto some_name10 if to 192.0")
2598 tao::pegtl::string_input<> in(
2600 " goto some_name10 if to 192.0;\n" 2603 REQUIRE(root !=
nullptr);
2606 ":001: chain default\n" 2607 ":002: | goto some_name10\n" 2608 ":002: | | condition\n" 2609 ":002: | | | dest 192.0\n");
2611 SECTION(
"goto some_name10 if from 127.1 to 192.0")
2613 tao::pegtl::string_input<> in(
2615 " goto some_name10 if from 127.1 to 192.0;\n" 2618 REQUIRE(root !=
nullptr);
2621 ":001: chain default\n" 2622 ":002: | goto some_name10\n" 2623 ":002: | | condition\n" 2624 ":002: | | | source 127.1\n" 2625 ":002: | | | dest 192.0\n");
2627 SECTION(
"goto some_name10 with priority 99")
2629 tao::pegtl::string_input<> in(
2631 " goto some_name10 with priority 99 if to 192.0;\n" 2634 REQUIRE(root !=
nullptr);
2637 ":001: chain default\n" 2638 ":002: | goto some_name10\n" 2639 ":002: | | priority 99\n" 2640 ":002: | | condition\n" 2641 ":002: | | | dest 192.0\n");
2643 SECTION(
"goto some_name10 with priority 99 if PING")
2645 tao::pegtl::string_input<> in(
2647 " goto some_name10 with priority 99 if PING;\n" 2650 REQUIRE(root !=
nullptr);
2653 ":001: chain default\n" 2654 ":002: | goto some_name10\n" 2655 ":002: | | priority 99\n" 2656 ":002: | | condition\n" 2657 ":002: | | | packet_type PING\n");
2659 SECTION(
"goto some_name10 with priority 99 if PING from 127.1")
2661 tao::pegtl::string_input<> in(
2663 " goto some_name10 with priority 99 if PING from 127.1;\n" 2666 REQUIRE(root !=
nullptr);
2669 ":001: chain default\n" 2670 ":002: | goto some_name10\n" 2671 ":002: | | priority 99\n" 2672 ":002: | | condition\n" 2673 ":002: | | | packet_type PING\n" 2674 ":002: | | | source 127.1\n");
2676 SECTION(
"goto some_name10 with priority 99 if PING to 192.0")
2678 tao::pegtl::string_input<> in(
2680 " goto some_name10 with priority 99 if PING to 192.0;\n" 2683 REQUIRE(root !=
nullptr);
2686 ":001: chain default\n" 2687 ":002: | goto some_name10\n" 2688 ":002: | | priority 99\n" 2689 ":002: | | condition\n" 2690 ":002: | | | packet_type PING\n" 2691 ":002: | | | dest 192.0\n");
2693 SECTION(
"goto some_name10 with priority 99 if PING from 127.1 to 192.0")
2695 tao::pegtl::string_input<> in(
2697 " goto some_name10 with priority 99 " 2698 "if PING from 127.1 to 192.0;\n" 2701 REQUIRE(root !=
nullptr);
2704 ":001: chain default\n" 2705 ":002: | goto some_name10\n" 2706 ":002: | | priority 99\n" 2707 ":002: | | condition\n" 2708 ":002: | | | packet_type PING\n" 2709 ":002: | | | source 127.1\n" 2710 ":002: | | | dest 192.0\n");
2712 SECTION(
"goto some_name10 with priority 99 if from 127.1")
2714 tao::pegtl::string_input<> in(
2716 " goto some_name10 with priority 99 if from 127.1;\n" 2719 REQUIRE(root !=
nullptr);
2722 ":001: chain default\n" 2723 ":002: | goto some_name10\n" 2724 ":002: | | priority 99\n" 2725 ":002: | | condition\n" 2726 ":002: | | | source 127.1\n");
2728 SECTION(
"goto some_name10 with priority 99 if to 192.0")
2730 tao::pegtl::string_input<> in(
2732 " goto some_name10 with priority 99 if to 192.0;\n" 2735 REQUIRE(root !=
nullptr);
2738 ":001: chain default\n" 2739 ":002: | goto some_name10\n" 2740 ":002: | | priority 99\n" 2741 ":002: | | condition\n" 2742 ":002: | | | dest 192.0\n");
2744 SECTION(
"goto some_name10 with priority 99 if from 127.1 to 192.0")
2746 tao::pegtl::string_input<> in(
2748 " goto some_name10 with priority 99 if from 127.1 to 192.0;\n" 2751 REQUIRE(root !=
nullptr);
2754 ":001: chain default\n" 2755 ":002: | goto some_name10\n" 2756 ":002: | | priority 99\n" 2757 ":002: | | condition\n" 2758 ":002: | | | source 127.1\n" 2759 ":002: | | | dest 192.0\n");
2764 TEST_CASE(
"'print_node' method prints an abstract syntax tree.",
"[config]")
2766 SECTION(
"Print without line information.")
2768 tao::pegtl::string_input<> in(
2770 " call some_name10 with priority 99 " 2771 "if PING from 127.1 to 192.0;\n" 2774 REQUIRE(root !=
nullptr);
2775 std::stringstream ss;
2780 "| call some_name10\n" 2783 "| | | packet_type PING\n" 2784 "| | | source 127.1\n" 2785 "| | | dest 192.0\n");
2787 SECTION(
"Print with line information.")
2789 tao::pegtl::string_input<> in(
2791 " call some_name10 with priority 99 " 2792 "if PING from 127.1 to 192.0;\n" 2795 REQUIRE(root !=
nullptr);
2796 std::stringstream ss;
2800 ":001: chain default\n" 2801 ":002: | call some_name10\n" 2802 ":002: | | priority 99\n" 2803 ":002: | | condition\n" 2804 ":002: | | | packet_type PING\n" 2805 ":002: | | | source 127.1\n" 2806 ":002: | | | dest 192.0\n");
std::string str(const T &object)
std::ostream & print_node(std::ostream &os, const config::parse_tree::node &node, bool print_location, const std::string &prefix)
std::unique_ptr< config::parse_tree::node > parse(Input &in)
TEST_CASE("A configuration string must have at least one valid statement " "or block.", "[config]")