aboutsummaryrefslogtreecommitdiff
path: root/staging/adblock/test/filterlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'staging/adblock/test/filterlist.cpp')
-rw-r--r--staging/adblock/test/filterlist.cpp42
1 files changed, 26 insertions, 16 deletions
diff --git a/staging/adblock/test/filterlist.cpp b/staging/adblock/test/filterlist.cpp
index 262e84b..ca122ac 100644
--- a/staging/adblock/test/filterlist.cpp
+++ b/staging/adblock/test/filterlist.cpp
@@ -22,6 +22,8 @@ TEST_CASE("placeholder")
TEST_CASE("domain match")
{
+ const QString defaultUrl = "";
+
const QString block1 = "http://ads.example.com/foo.gif";
const QString block2 = "http://server1.ads.example.com/foo.gif";
const QString block3 = "https://ads.example.com:8000/";
@@ -34,19 +36,21 @@ TEST_CASE("domain match")
REQUIRE(rule->shouldBlock());
REQUIRE(!rule->shouldRedirect());
- REQUIRE(rule->hasMatch(&block1));
- REQUIRE(rule->hasMatch(&block2));
- REQUIRE(rule->hasMatch(&block3));
- REQUIRE(rule->hasMatch(&block4));
+ REQUIRE(rule->hasMatch(&block1, &defaultUrl, &defaultUrl));
+ REQUIRE(rule->hasMatch(&block2, &defaultUrl, &defaultUrl));
+ REQUIRE(rule->hasMatch(&block3, &defaultUrl, &defaultUrl));
+ REQUIRE(rule->hasMatch(&block4, &defaultUrl, &defaultUrl));
- REQUIRE(!rule->hasMatch(&allow1));
- REQUIRE(!rule->hasMatch(&allow2));
+ REQUIRE(!rule->hasMatch(&allow1, &defaultUrl, &defaultUrl));
+ REQUIRE(!rule->hasMatch(&allow2, &defaultUrl, &defaultUrl));
delete rule;
}
TEST_CASE("string equals")
{
+ const QString defaultUrl = "";
+
const QString block = "http://example.com/";
const QString allow1 = "http://example.com/foo.gif";
@@ -56,16 +60,18 @@ TEST_CASE("string equals")
REQUIRE(rule->shouldBlock());
REQUIRE(!rule->shouldRedirect());
- REQUIRE(rule->hasMatch(&block));
+ REQUIRE(rule->hasMatch(&block, &defaultUrl, &defaultUrl));
- REQUIRE(!rule->hasMatch(&allow1));
- REQUIRE(!rule->hasMatch(&allow2));
+ REQUIRE(!rule->hasMatch(&allow1, &defaultUrl, &defaultUrl));
+ REQUIRE(!rule->hasMatch(&allow2, &defaultUrl, &defaultUrl));
delete rule;
}
TEST_CASE("string starts with")
{
+ const QString defaultUrl = "";
+
auto *rule = FilterList::parseRule("|http://baddomain.example/");
REQUIRE(rule->shouldBlock());
REQUIRE(!rule->shouldRedirect());
@@ -73,13 +79,15 @@ TEST_CASE("string starts with")
const QString blocks = "http://baddomain.example/banner.gif";
const QString allows = "http://gooddomain.example/analyze?http://baddomain.example";
- REQUIRE(rule->hasMatch(&blocks));
- REQUIRE(!rule->hasMatch(&allows));
+ REQUIRE(rule->hasMatch(&blocks, &defaultUrl, &defaultUrl));
+ REQUIRE(!rule->hasMatch(&allows, &defaultUrl, &defaultUrl));
delete rule;
}
TEST_CASE("string ends with")
{
+ const QString defaultUrl = "";
+
auto *rule = FilterList::parseRule("swf|");
REQUIRE(rule->shouldBlock());
REQUIRE(!rule->shouldRedirect());
@@ -87,22 +95,24 @@ TEST_CASE("string ends with")
const QString blocks = "http://example.com/annoyingflash.swf";
const QString allows = "http://example.com/swf/index.html";
- REQUIRE(rule->hasMatch(&blocks));
- REQUIRE(!rule->hasMatch(&allows));
+ REQUIRE(rule->hasMatch(&blocks, &defaultUrl, &defaultUrl));
+ REQUIRE(!rule->hasMatch(&allows, &defaultUrl, &defaultUrl));
delete rule;
}
TEST_CASE("regular expressions")
{
+ const QString defaultUrl = "";
+
auto *rule = FilterList::parseRule("/banner\\d+/");
const QString matches1 = "banner123";
const QString matches2 = "banner321";
const QString ignores = "banners";
- REQUIRE(rule->hasMatch(&matches1));
- REQUIRE(rule->hasMatch(&matches2));
- REQUIRE(!rule->hasMatch(&ignores));
+ REQUIRE(rule->hasMatch(&matches1, &defaultUrl, &defaultUrl));
+ REQUIRE(rule->hasMatch(&matches2, &defaultUrl, &defaultUrl));
+ REQUIRE(!rule->hasMatch(&ignores, &defaultUrl, &defaultUrl));
delete rule;
}