diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-05-31 21:53:52 +0300 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-05-31 21:53:52 +0300 |
commit | 737d688e5b173ef5155db3e4fc9e8debf9b33a11 (patch) | |
tree | 3fe6cd4aade797fc0c3b18d458834befd43a91cf /staging/adblock/test/rule.cpp | |
parent | staging: smolblok (diff) | |
download | smolbote-737d688e5b173ef5155db3e4fc9e8debf9b33a11.tar.xz |
enable smolblokstaging-smolblok
Build both HostlistFilter and AdblockFitler plugins by default.
Diffstat (limited to 'staging/adblock/test/rule.cpp')
-rw-r--r-- | staging/adblock/test/rule.cpp | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/staging/adblock/test/rule.cpp b/staging/adblock/test/rule.cpp deleted file mode 100644 index 07186b9..0000000 --- a/staging/adblock/test/rule.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#define CATCH_CONFIG_MAIN -#include "rule.h" -#include <catch2/catch.hpp> - -using namespace AdblockPlus; - -SCENARIO("MatcherRule") -{ - GIVEN("options with case sensitive pattern") - { - const QString defaultUrl = ""; - - const Options opt { .matchcase=true }; - const QString patternContains("this string contains the pattern in it"); - const QString patternBegins("pattern starts this string"); - const QString patternEnds("this string ends with pattern"); - const QString patternMissing("and this one does not"); - - WHEN("contains") - { - MatcherRule rule("pattern", opt); - REQUIRE(rule.shouldBlock()); - - THEN("pattern is matched anywhere in the URL") - { - REQUIRE(rule.hasMatch(&patternContains, &defaultUrl, &defaultUrl)); - REQUIRE(rule.hasMatch(&patternBegins, &defaultUrl, &defaultUrl)); - REQUIRE(rule.hasMatch(&patternEnds, &defaultUrl, &defaultUrl)); - REQUIRE(!rule.hasMatch(&patternMissing, &defaultUrl, &defaultUrl)); - } - } - - WHEN("startsWith") - { - MatcherRule rule("pattern", opt, MatcherRule::UrlStartsWith); - REQUIRE(rule.shouldBlock()); - - THEN("pattern is matched if at the start of the URL") - { - REQUIRE(!rule.hasMatch(&patternContains, &defaultUrl, &defaultUrl)); - REQUIRE(rule.hasMatch(&patternBegins, &defaultUrl, &defaultUrl)); - REQUIRE(!rule.hasMatch(&patternEnds, &defaultUrl, &defaultUrl)); - REQUIRE(!rule.hasMatch(&patternMissing, &defaultUrl, &defaultUrl)); - } - } - - WHEN("endsWith") - { - MatcherRule rule("pattern", opt, MatcherRule::UrlEndsWith); - REQUIRE(rule.shouldBlock()); - - THEN("pattern is matched if at the end of the URL") - { - REQUIRE(!rule.hasMatch(&patternContains, &defaultUrl, &defaultUrl)); - REQUIRE(!rule.hasMatch(&patternBegins, &defaultUrl, &defaultUrl)); - REQUIRE(rule.hasMatch(&patternEnds, &defaultUrl, &defaultUrl)); - REQUIRE(!rule.hasMatch(&patternMissing, &defaultUrl, &defaultUrl)); - } - } - } -} - -SCENARIO("RegexRule") -{ - GIVEN("options with case sensitive pattern") - { - const QString defaultUrl; - - const Options opt { .matchcase=true }; - const QString patternContains("this string contains the pattern in it"); - const QString patternMissing("and this one does not"); - - WHEN("contains") - { - RegexRule rule("pattern", opt); - REQUIRE(rule.shouldBlock()); - - THEN("pattern is matched anywhere in the URL") - { - REQUIRE(rule.hasMatch(&patternContains, &defaultUrl, &defaultUrl)); - REQUIRE(!rule.hasMatch(&patternMissing, &defaultUrl, &defaultUrl)); - } - } - } -} - |