From d1287f43964633035938f4f4d4133bb6d9da7b3e Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 10 Feb 2020 20:58:39 +0200 Subject: staging: smolblok smolblok is a replacement for the current lib/urlfilter AdBlockPlus and hostlist format filter parser. It is a library that uses plugins to provide support for different filter formats. staging/adblock: AdBlockPlus parser plugin plugins/smolblok_hostlist: hostlist format parser plugin Headers will be installed to include/smolbote/ Remove lib/urlfilter --- plugins/smolblok_hostlist/test/plugin.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 plugins/smolblok_hostlist/test/plugin.cpp (limited to 'plugins/smolblok_hostlist/test/plugin.cpp') 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 +#include + +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)); +} + -- cgit v1.2.1