aboutsummaryrefslogtreecommitdiff
path: root/plugins/smolblok_hostlist/test/plugin.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-04-24 17:29:08 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-04-24 17:29:08 +0300
commit79b8dff70783b3bf08778c1f5ba6f238b2ed18d1 (patch)
treebdf1f544eb0869999fa5d21e519e386a194392c1 /plugins/smolblok_hostlist/test/plugin.cpp
parentAdd smolblok-load utility (diff)
downloadsmolbote-79b8dff70783b3bf08778c1f5ba6f238b2ed18d1.tar.xz
smolblok_hostlist: add plugin teststaging-adblock
Diffstat (limited to 'plugins/smolblok_hostlist/test/plugin.cpp')
-rw-r--r--plugins/smolblok_hostlist/test/plugin.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/smolblok_hostlist/test/plugin.cpp b/plugins/smolblok_hostlist/test/plugin.cpp
new file mode 100644
index 0000000..fad34f2
--- /dev/null
+++ b/plugins/smolblok_hostlist/test/plugin.cpp
@@ -0,0 +1,27 @@
+#define CATCH_CONFIG_MAIN
+#include "plugin/plugin.h"
+#include <QFile>
+#include <catch2/catch.hpp>
+
+TEST_CASE("Hostlist")
+{
+ HostlistFilterPlugin plugin;
+
+ const QString filename(qgetenv("HOSTLIST_TXT"));
+ REQUIRE(!filename.isEmpty());
+ QFile f(filename);
+
+ // shouldn't be able to load an unopened QIODevice
+ REQUIRE(plugin.load(f) == nullptr);
+
+ REQUIRE(f.open(QIODevice::ReadOnly | QIODevice::Text));
+
+ auto *list = plugin.load(f);
+ REQUIRE(list != nullptr);
+ f.seek(0);
+ REQUIRE_FALSE(plugin.parse(nullptr, f));
+ REQUIRE(plugin.parse(list, f));
+ f.close();
+ REQUIRE_FALSE(plugin.parse(list, f));
+}
+