mavtables  0.2.1
MAVLink router and firewall.
test_Rule_comparison.cpp
Go to the documentation of this file.
1 // MAVLink router and firewall.
2 // Copyright (C) 2018 Michael R. Shannon <mrshannon.aerospace@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 
18 #include <catch.hpp>
19 #include <fakeit.hpp>
20 
21 #include "Accept.hpp"
22 #include "Call.hpp"
23 #include "Chain.hpp"
24 #include "GoTo.hpp"
25 #include "Reject.hpp"
26 #include "Rule.hpp"
27 
28 #include "common.hpp"
29 
30 
31 TEST_CASE("Rule's are polymorphically comparable.", "[Rule]")
32 {
33  fakeit::Mock<Chain> mock;
34  std::shared_ptr<Chain> chain = mock_shared(mock);
35  SECTION("with ==")
36  {
37  REQUIRE_FALSE(Accept() == Reject());
38  REQUIRE_FALSE(Accept() == Call(chain));
39  REQUIRE_FALSE(Accept() == GoTo(chain));
40  REQUIRE_FALSE(Reject() == Accept());
41  REQUIRE_FALSE(Reject() == Call(chain));
42  REQUIRE_FALSE(Reject() == GoTo(chain));
43  REQUIRE_FALSE(Call(chain) == Accept());
44  REQUIRE_FALSE(Call(chain) == Reject());
45  REQUIRE_FALSE(Call(chain) == GoTo(chain));
46  REQUIRE_FALSE(GoTo(chain) == Accept());
47  REQUIRE_FALSE(GoTo(chain) == Reject());
48  REQUIRE_FALSE(GoTo(chain) == Call(chain));
49  }
50  SECTION("with !=")
51  {
52  REQUIRE(Accept() != Reject());
53  REQUIRE(Accept() != Call(chain));
54  REQUIRE(Accept() != GoTo(chain));
55  REQUIRE(Reject() != Accept());
56  REQUIRE(Reject() != Call(chain));
57  REQUIRE(Reject() != GoTo(chain));
58  REQUIRE(Call(chain) != Accept());
59  REQUIRE(Call(chain) != Reject());
60  REQUIRE(Call(chain) != GoTo(chain));
61  REQUIRE(GoTo(chain) != Accept());
62  REQUIRE(GoTo(chain) != Reject());
63  REQUIRE(GoTo(chain) != Call(chain));
64  }
65 }
Definition: Call.hpp:43
std::shared_ptr< T > mock_shared(fakeit::Mock< T > &mock)
Definition: common.hpp:33
Definition: GoTo.hpp:44
TEST_CASE("Rule's are polymorphically comparable.", "[Rule]")