aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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));
+}
+