aboutsummaryrefslogtreecommitdiff
path: root/lib/smolblok/test
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-05-31 21:53:52 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-05-31 21:53:52 +0300
commit737d688e5b173ef5155db3e4fc9e8debf9b33a11 (patch)
tree3fe6cd4aade797fc0c3b18d458834befd43a91cf /lib/smolblok/test
parentstaging: smolblok (diff)
downloadsmolbote-737d688e5b173ef5155db3e4fc9e8debf9b33a11.tar.xz
enable smolblokstaging-smolblok
Build both HostlistFilter and AdblockFitler plugins by default.
Diffstat (limited to 'lib/smolblok/test')
-rw-r--r--lib/smolblok/test/loader.cpp25
-rw-r--r--lib/smolblok/test/main.cpp22
-rw-r--r--lib/smolblok/test/sample-filters.txt10
3 files changed, 57 insertions, 0 deletions
diff --git a/lib/smolblok/test/loader.cpp b/lib/smolblok/test/loader.cpp
new file mode 100644
index 0000000..9e27a26
--- /dev/null
+++ b/lib/smolblok/test/loader.cpp
@@ -0,0 +1,25 @@
+#include "smolblok.hpp"
+#include <spdlog/spdlog.h>
+
+int main(int argc, char** argv)
+{
+ if(argc != 2) {
+ spdlog::error("usage: {} path/to/plugin.so", argv[0]);
+ return -1;
+ }
+
+ smolblok filter;
+ {
+ const auto r = filter.registerFormatPlugin("unused", argv[1]);
+ if(r.loaded) {
+ spdlog::info("Loaded plugin {}", argv[1]);
+ } else {
+ spdlog::error("Failed loading plugin {}", argv[1]);
+ spdlog::error(qUtf8Printable(r.error));
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
diff --git a/lib/smolblok/test/main.cpp b/lib/smolblok/test/main.cpp
new file mode 100644
index 0000000..5624ee9
--- /dev/null
+++ b/lib/smolblok/test/main.cpp
@@ -0,0 +1,22 @@
+#define CATCH_CONFIG_MAIN
+
+#include "smolblok.hpp"
+#include <catch2/catch.hpp>
+
+SCENARIO("smolblok")
+{
+ smolblok s;
+
+ GIVEN("invalid plugins")
+ {
+ REQUIRE(!s.registerFormatPlugin("", ""));
+ REQUIRE(!s.registerFormatPlugin("Format", "missing.dll"));
+ }
+
+ GIVEN("invalid subscriptions")
+ {
+ REQUIRE(!s.addSubscriptions(""));
+ REQUIRE(!s.addSubscriptions("missing.txt"));
+ }
+}
+
diff --git a/lib/smolblok/test/sample-filters.txt b/lib/smolblok/test/sample-filters.txt
new file mode 100644
index 0000000..59e0e7b
--- /dev/null
+++ b/lib/smolblok/test/sample-filters.txt
@@ -0,0 +1,10 @@
+[easylist-noelemhide]
+Format = AdblockPlus
+File = easylist_noelemhide.txt
+Href = https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt
+
+[StevenBlack]
+Format = Hostlist
+File = stevenblack.txt
+Href = https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
+