diff options
Diffstat (limited to 'plugins/HostlistFilter/test/rule.cpp')
-rw-r--r-- | plugins/HostlistFilter/test/rule.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/plugins/HostlistFilter/test/rule.cpp b/plugins/HostlistFilter/test/rule.cpp index b5ba6e0..5ee9881 100644 --- a/plugins/HostlistFilter/test/rule.cpp +++ b/plugins/HostlistFilter/test/rule.cpp @@ -2,56 +2,56 @@ #include "filterlist.h" #include <catch2/catch.hpp> +// clazy:skip + using namespace Hostlist; SCENARIO("Hostlist::Rule") { GIVEN("an invalid rule") { - const auto rule = Filterlist::parseRule("0.0.0.0 "); - REQUIRE(rule.empty()); + QStringList b; + QHash<QString, QString> r; + parseRule("0.0.0.0 ", b, r); + + REQUIRE(b.empty()); + REQUIRE(r.empty()); } GIVEN("127.0.0.1 localhost.localdomain") { - auto rule = Filterlist::parseRule("127.0.0.1 localhost.localdomain"); + QStringList b; + QHash<QString, QString> r; + parseRule("127.0.0.1 localhost.localdomain", b, r); - REQUIRE(!rule.empty()); - REQUIRE(rule.size() == 1); + REQUIRE(b.empty()); + REQUIRE(r.size() == 1); - // note: you need to force it to hash a string, rather than the address itself - const auto index = qHash(QString("localhost.localdomain"), 0); - REQUIRE(rule[index].domain == "localhost.localdomain"); - REQUIRE(rule[index].redirect == "127.0.0.1"); + REQUIRE(r.value("localhost.localdomain") == "127.0.0.1"); } GIVEN("0.0.0.0 blockeddomain.com") { - auto rule = Filterlist::parseRule("0.0.0.0 blockeddomain.com"); + QStringList b; + QHash<QString, QString> r; + parseRule("0.0.0.0 blockeddomain.com", b, r); - REQUIRE(!rule.empty()); - REQUIRE(rule.size() == 1); + REQUIRE(b.size() == 1); + REQUIRE(r.empty()); - const auto index = qHash(QString("blockeddomain.com"), 0); - REQUIRE(rule[index].domain == "blockeddomain.com"); - REQUIRE(rule[index].redirect.isEmpty()); + REQUIRE(b.contains("blockeddomain.com")); ; } GIVEN("0.0.0.0 blockeddomain.first blockeddomain.second") { - auto rule = Filterlist::parseRule("0.0.0.0 blockeddomain.first blockeddomain.second"); - - REQUIRE(!rule.empty()); - REQUIRE(rule.size() == 2); - { - const auto index = qHash(QString("blockeddomain.first"), 0); - REQUIRE(rule[index].domain == "blockeddomain.first"); - REQUIRE(rule[index].redirect.isEmpty()); - } - { - const auto index = qHash(QString("blockeddomain.second"), 0); - REQUIRE(rule[index].domain == "blockeddomain.second"); - REQUIRE(rule[index].redirect.isEmpty()); - } + QStringList b; + QHash<QString, QString> r; + parseRule("0.0.0.0 blockeddomain.first blockeddomain.second", b, r); + + REQUIRE(b.size() == 2); + REQUIRE(r.empty()); + + REQUIRE(b.contains("blockeddomain.first")); + REQUIRE(b.contains("blockeddomain.second")); } } |