diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-18 22:34:49 +0300 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-21 20:14:57 +0300 |
commit | f76ef20b832428aa1090d7f5df749909828f9bd8 (patch) | |
tree | 61fb6147cf772d3e70e6d21d8c7b43ec74e0cdf8 /staging/hostlist/test | |
parent | Add staging/hostlist (diff) | |
download | smolbote-f76ef20b832428aa1090d7f5df749909828f9bd8.tar.xz |
Hostlist: test list parsing
Diffstat (limited to 'staging/hostlist/test')
-rw-r--r-- | staging/hostlist/test/filterlist.cpp | 29 | ||||
-rw-r--r-- | staging/hostlist/test/hostlist.txt | 6 | ||||
-rw-r--r-- | staging/hostlist/test/rule.cpp | 2 |
3 files changed, 36 insertions, 1 deletions
diff --git a/staging/hostlist/test/filterlist.cpp b/staging/hostlist/test/filterlist.cpp new file mode 100644 index 0000000..fb71068 --- /dev/null +++ b/staging/hostlist/test/filterlist.cpp @@ -0,0 +1,29 @@ +#define CATCH_CONFIG_MAIN +#include "filterlist.hpp" +#include <QFile> +#include <catch2/catch.hpp> + +using namespace Hostlist; + +TEST_CASE("Hostlist") +{ + Filterlist list; + + const QString filename(qgetenv("HOSTLIST_TXT")); + REQUIRE(!filename.isEmpty()); + + QFile f(filename); + REQUIRE(f.open(QIODevice::ReadOnly | QIODevice::Text)); + + REQUIRE(list.load(f)); + f.close(); + + REQUIRE(list.count() == 4); + + REQUIRE(list.findMatch("blockeddomain.first")); + REQUIRE(list.findMatch("blockeddomain.second")); + + REQUIRE(list.findMatch("localhost.localdomain")); + + REQUIRE(!list.findMatch("other.domain")); +} diff --git a/staging/hostlist/test/hostlist.txt b/staging/hostlist/test/hostlist.txt new file mode 100644 index 0000000..a0b4e5c --- /dev/null +++ b/staging/hostlist/test/hostlist.txt @@ -0,0 +1,6 @@ +# This is a comment, and after it comes a blank line + +127.0.0.1 localhost.localdomain + +0.0.0.0 blockeddomain.com +0.0.0.0 blockeddomain.first blockeddomain.second diff --git a/staging/hostlist/test/rule.cpp b/staging/hostlist/test/rule.cpp index 6a16f86..6b1ea70 100644 --- a/staging/hostlist/test/rule.cpp +++ b/staging/hostlist/test/rule.cpp @@ -4,7 +4,7 @@ using namespace Hostlist; -SCENARIO("MatcherRule") +SCENARIO("Hostlist::Rule") { GIVEN("an invalid rule") { |