From f8e421c638efe04a5de36a730c97f05325140ee0 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Wed, 15 Apr 2020 13:03:49 +0300 Subject: Add tests for regex rules --- staging/adblock/test/filterlist.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'staging/adblock/test/filterlist.cpp') 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; +} + -- cgit v1.2.1