33 TEST_CASE(
"Accept's are constructable.",
"[Accept]")
35 SECTION(
"Without a condition (match all packet/address combinations) or a " 40 SECTION(
"Without a condition (match all packet/address combinations) but " 43 REQUIRE_NOTHROW(
Accept(3));
45 SECTION(
"With a condition and without a priority.")
48 REQUIRE_NOTHROW(
Accept(
If().type(
"PING")));
49 REQUIRE_NOTHROW(
Accept(
If().from(
"192.168")));
50 REQUIRE_NOTHROW(
Accept(
If().to(
"172.16")));
52 SECTION(
"With both a condition and a priority.")
55 REQUIRE_NOTHROW(
Accept(3,
If().type(
"PING")));
56 REQUIRE_NOTHROW(
Accept(3,
If().from(
"192.168")));
57 REQUIRE_NOTHROW(
Accept(3,
If().to(
"172.16")));
93 TEST_CASE(
"Accept's 'action' method determines what to do with a " 94 "packet/address combination.",
"[Accept]")
97 SECTION(
"Returns the accept action if there is no conditional.")
108 SECTION(
"Returns the accept action if the conditional is a match.")
119 Accept(3,
If().type(
"PING")).action(
122 Accept(3,
If().to(
"192.168")).action(
125 SECTION(
"Returns the continue action if the conditional does not match.")
129 Accept(
If().type(
"SET_MODE")).action(
136 Accept(3,
If().type(
"SET_MODE")).action(
139 Accept(3,
If().to(
"172.16")).action(
145 TEST_CASE(
"Accept's are printable (without a condition or a priority).",
151 SECTION(
"By direct type.")
153 REQUIRE(
str(accept) ==
"accept");
155 SECTION(
"By polymorphic type.")
157 REQUIRE(
str(
rule) ==
"accept");
162 TEST_CASE(
"Accept's are printable (without a condition but with a priority).",
168 SECTION(
"By direct type.")
170 REQUIRE(
str(accept) ==
"accept with priority -3");
172 SECTION(
"By polymorphic type.")
174 REQUIRE(
str(
rule) ==
"accept with priority -3");
179 TEST_CASE(
"Accept's are printable (with a condition but without a priority).",
183 Accept accept(
If().type(
"PING").from(
"192.168/8").to(
"172.16/4"));
185 SECTION(
"By direct type.")
187 REQUIRE(
str(accept) ==
"accept if PING from 192.168/8 to 172.16/4");
189 SECTION(
"By polymorphic type.")
191 REQUIRE(
str(
rule) ==
"accept if PING from 192.168/8 to 172.16/4");
196 TEST_CASE(
"Accept's are printable (with a condition and a priority).",
200 Accept accept(-3,
If().type(
"PING").from(
"192.168/8").to(
"172.16/4"));
202 SECTION(
"By direct type.")
206 "accept with priority -3 if PING from 192.168/8 to 172.16/4");
208 SECTION(
"By polymorphic type.")
212 "accept with priority -3 if PING from 192.168/8 to 172.16/4");
217 TEST_CASE(
"Accept's 'clone' method returns a polymorphic copy.",
"[Accept]")
219 SECTION(
"Without a priority.")
223 std::unique_ptr<Rule> polymorphic_copy =
rule.
clone();
224 REQUIRE(accept == *polymorphic_copy);
226 SECTION(
"With a priority.")
228 Accept accept(4,
If().type(
"PING"));
230 std::unique_ptr<Rule> polymorphic_copy =
rule.
clone();
231 REQUIRE(accept == *polymorphic_copy);
std::string str(const T &object)
static Action make_accept(std::optional< int > priority={})
virtual std::unique_ptr< Rule > clone() const =0
static Action make_continue()
TEST_CASE("Accept's are constructable.", "[Accept]")