aboutsummaryrefslogtreecommitdiff
path: root/subprojects/plugin_hostlist/test
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-04-23 17:47:39 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-04-23 17:47:39 +0300
commitaa7e8fe1a90fbba289aec9b59a872170a0c593c2 (patch)
treef755844140350029b949a022be74570b3f1b1b70 /subprojects/plugin_hostlist/test
parentplugin_hostlist: add fuzzer (diff)
downloadsmolbote-aa7e8fe1a90fbba289aec9b59a872170a0c593c2.tar.xz
move subprojects/plugin_hostlist to plugins/smolblok_hostlist
Diffstat (limited to 'subprojects/plugin_hostlist/test')
-rw-r--r--subprojects/plugin_hostlist/test/filterlist.cpp29
-rw-r--r--subprojects/plugin_hostlist/test/hostlist.txt6
-rw-r--r--subprojects/plugin_hostlist/test/rule.cpp57
3 files changed, 0 insertions, 92 deletions
diff --git a/subprojects/plugin_hostlist/test/filterlist.cpp b/subprojects/plugin_hostlist/test/filterlist.cpp
deleted file mode 100644
index 4aa532b..0000000
--- a/subprojects/plugin_hostlist/test/filterlist.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#define CATCH_CONFIG_MAIN
-#include "filterlist.h"
-#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/subprojects/plugin_hostlist/test/hostlist.txt b/subprojects/plugin_hostlist/test/hostlist.txt
deleted file mode 100644
index a0b4e5c..0000000
--- a/subprojects/plugin_hostlist/test/hostlist.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# 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/subprojects/plugin_hostlist/test/rule.cpp b/subprojects/plugin_hostlist/test/rule.cpp
deleted file mode 100644
index b5ba6e0..0000000
--- a/subprojects/plugin_hostlist/test/rule.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#define CATCH_CONFIG_MAIN
-#include "filterlist.h"
-#include <catch2/catch.hpp>
-
-using namespace Hostlist;
-
-SCENARIO("Hostlist::Rule")
-{
- GIVEN("an invalid rule")
- {
- const auto rule = Filterlist::parseRule("0.0.0.0 ");
- REQUIRE(rule.empty());
- }
- GIVEN("127.0.0.1 localhost.localdomain")
- {
- auto rule = Filterlist::parseRule("127.0.0.1 localhost.localdomain");
-
- REQUIRE(!rule.empty());
- REQUIRE(rule.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");
- }
-
- GIVEN("0.0.0.0 blockeddomain.com")
- {
- auto rule = Filterlist::parseRule("0.0.0.0 blockeddomain.com");
-
- REQUIRE(!rule.empty());
- REQUIRE(rule.size() == 1);
-
- const auto index = qHash(QString("blockeddomain.com"), 0);
- REQUIRE(rule[index].domain == "blockeddomain.com");
- REQUIRE(rule[index].redirect.isEmpty());
- ;
- }
-
- 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());
- }
- }
-}