aboutsummaryrefslogtreecommitdiff
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
parentAdd smolblok-load utility (diff)
downloadsmolbote-staging-adblock.tar.xz
smolblok_hostlist: add plugin teststaging-adblock
-rw-r--r--plugins/smolblok_hostlist/meson.build9
-rw-r--r--plugins/smolblok_hostlist/test/plugin.cpp27
2 files changed, 35 insertions, 1 deletions
diff --git a/plugins/smolblok_hostlist/meson.build b/plugins/smolblok_hostlist/meson.build
index 7dde699..c9ff303 100644
--- a/plugins/smolblok_hostlist/meson.build
+++ b/plugins/smolblok_hostlist/meson.build
@@ -28,8 +28,15 @@ test('filterlist', executable('filterlist',
env: 'HOSTLIST_TXT='+meson.current_source_dir()/'test/hostlist.txt',
suite: 'hostlist'
)
+test('plugin', executable('filterlist-plugin',
+ sources: [ 'test/plugin.cpp', 'plugin/plugin.cpp',
+ mod_qt5.preprocess(include_directories: smolbote_interfaces, moc_headers: 'plugin/plugin.h', dependencies: dep_qt5) ],
+ dependencies: [dep_qt5, dep_catch, dep_hostlistfilter]),
+ env: 'HOSTLIST_TXT='+meson.current_source_dir()/'test/hostlist.txt',
+ suite: 'hostlist'
+)
-test('plugin', smolblok_load, workdir: meson.build_root(), args: plugin.full_path(), suite: 'hostlist')
+test('smolblok-load', smolblok_load, workdir: meson.build_root(), args: plugin.full_path(), suite: 'hostlist')
# fuzzer
if meson.get_compiler('cpp').has_multi_arguments('-g', '-fsanitize=fuzzer')
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));
+}
+