aboutsummaryrefslogtreecommitdiff
path: root/staging/adblock/test/options.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-04-15 17:23:48 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-04-21 20:14:57 +0300
commitf5a067e505c442618dc59d962fd6fa5d6cf16ab8 (patch)
treef401b839240659b558c84643d977d10c7a3f0d4e /staging/adblock/test/options.cpp
parentAdd tests for regex rules (diff)
downloadsmolbote-f5a067e505c442618dc59d962fd6fa5d6cf16ab8.tar.xz
Add some Options tests
Diffstat (limited to 'staging/adblock/test/options.cpp')
-rw-r--r--staging/adblock/test/options.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/staging/adblock/test/options.cpp b/staging/adblock/test/options.cpp
new file mode 100644
index 0000000..d0ad4a0
--- /dev/null
+++ b/staging/adblock/test/options.cpp
@@ -0,0 +1,43 @@
+#define CATCH_CONFIG_MAIN
+#include "options.h"
+#include <catch2/catch.hpp>
+
+using namespace AdblockPlus;
+
+SCENARIO("parsing adblock options")
+{
+ Options opt;
+
+ GIVEN("an unknown option")
+ {
+ const QString unknown = "unknown";
+ THEN("the option is not parsed")
+ {
+ QStringRef unknown_ref(&unknown);
+ REQUIRE(!opt.parseAbp(unknown_ref));
+ }
+ }
+
+ GIVEN("various options in a QString")
+ {
+ const QString options = "match-case,document,~subdocument";
+
+ for(auto &i : splitOptions(&options)) {
+ REQUIRE(opt.parseAbp(i));
+ }
+
+ WHEN("match-case")
+ {
+ REQUIRE(opt.matchcase);
+ }
+
+ WHEN("document")
+ {
+ REQUIRE(opt.resource_options.value(QWebEngineUrlRequestInfo::ResourceTypeMainFrame));
+ }
+ WHEN("~subdocument")
+ {
+ REQUIRE(!opt.resource_options.value(QWebEngineUrlRequestInfo::ResourceTypeSubFrame));
+ }
+ }
+}