diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-15 13:03:49 +0300 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-21 20:14:56 +0300 |
commit | f8e421c638efe04a5de36a730c97f05325140ee0 (patch) | |
tree | 35bf9968032bacb54dd8f011f3c9c58d82379789 /staging/adblock/test/filterlist.cpp | |
parent | Fix MatcherRule with DomainMatch (diff) | |
download | smolbote-f8e421c638efe04a5de36a730c97f05325140ee0.tar.xz |
Add tests for regex rules
Diffstat (limited to 'staging/adblock/test/filterlist.cpp')
-rw-r--r-- | staging/adblock/test/filterlist.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/staging/adblock/test/filterlist.cpp b/staging/adblock/test/filterlist.cpp index 4366489..262e84b 100644 --- a/staging/adblock/test/filterlist.cpp +++ b/staging/adblock/test/filterlist.cpp @@ -91,3 +91,18 @@ TEST_CASE("string ends with") REQUIRE(!rule->hasMatch(&allows)); delete rule; } + +TEST_CASE("regular expressions") +{ + 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)); + delete rule; +} + |