aboutsummaryrefslogtreecommitdiff
path: root/staging/hostlist/test
diff options
context:
space:
mode:
Diffstat (limited to 'staging/hostlist/test')
-rw-r--r--staging/hostlist/test/filterlist.cpp29
-rw-r--r--staging/hostlist/test/hostlist.txt6
-rw-r--r--staging/hostlist/test/rule.cpp2
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")
{