diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-15 17:23:48 +0300 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-21 20:14:57 +0300 |
commit | f5a067e505c442618dc59d962fd6fa5d6cf16ab8 (patch) | |
tree | f401b839240659b558c84643d977d10c7a3f0d4e /staging/adblock/test/options.cpp | |
parent | Add tests for regex rules (diff) | |
download | smolbote-f5a067e505c442618dc59d962fd6fa5d6cf16ab8.tar.xz |
Add some Options tests
Diffstat (limited to 'staging/adblock/test/options.cpp')
-rw-r--r-- | staging/adblock/test/options.cpp | 43 |
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)); + } + } +} |