aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-11-16 16:26:22 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-11-16 16:26:22 +0100
commit566abfa99120652fb1e9190d791fdbbba64d2e0d (patch)
tree86a6f71b926794298d922a9319b55909cf5a07b4 /test
parentAdd more regex benchmarks (diff)
downloadsmolbote-566abfa99120652fb1e9190d791fdbbba64d2e0d.tar.xz
Add adblockrule_parse
Diffstat (limited to 'test')
-rw-r--r--test/adblock/adblocktest.cpp6
-rw-r--r--test/hostlist/hostlisttest.cpp4
-rw-r--r--test/meson.build4
3 files changed, 9 insertions, 5 deletions
diff --git a/test/adblock/adblocktest.cpp b/test/adblock/adblocktest.cpp
index f4d9ce2..871b7ca 100644
--- a/test/adblock/adblocktest.cpp
+++ b/test/adblock/adblocktest.cpp
@@ -1,11 +1,15 @@
#include "adblocktest.h"
#include <QtTest/QtTest>
#include "formats/adblockrule.h"
+#include "formats/adblockrule_parse.h"
void AdBlockTest::parseRule()
{
- FilterLeaf *rule = loadRule("spamdomain");
+ auto *rule = loadRule("/spamdomain/$domain=spamdomain.com,image");
QCOMPARE(rule != nullptr, true);
+ QCOMPARE(rule->match(QUrl::fromUserInput("subdomain.spamdomain.com")), true);
+ QCOMPARE(rule->action().first == FilterLeaf::Block, true);
+ QCOMPARE(rule->option(QWebEngineUrlRequestInfo::ResourceTypeImage).value(), true);
}
/*void AdBlockTest::parseList()
diff --git a/test/hostlist/hostlisttest.cpp b/test/hostlist/hostlisttest.cpp
index 5270118..7f5c954 100644
--- a/test/hostlist/hostlisttest.cpp
+++ b/test/hostlist/hostlisttest.cpp
@@ -39,9 +39,9 @@ void HostlistTest::checkRules()
auto result = tree.match(domain, request);
QCOMPARE(result.length(), matches);
if(matches > 0)
- QCOMPARE(result.constFirst()->action(), action);
+ QCOMPARE(result.constFirst()->action().first, action);
if(action == FilterLeaf::Redirect)
- QCOMPARE(result.constFirst()->redirect(), QLatin1Literal("127.0.0.1"));
+ QCOMPARE(result.constFirst()->action().second, QLatin1Literal("127.0.0.1"));
}
void HostlistTest::benchmark_parse()
diff --git a/test/meson.build b/test/meson.build
index 9be99c9..df6a9c9 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -3,14 +3,14 @@ adblock = executable('AdblockTest',
dependencies: [dep_qt5, dep_urlfilter],
sources: ['adblock/adblocktest.cpp', qt5.preprocess(moc_headers: 'adblock/adblocktest.h', dependencies: dep_qt5)]
)
-test('urlfilter-adblock', adblock)
+test('urlfilter-adblock', adblock, workdir: meson.current_source_dir())
# Hostlist parsing test
hostlist = executable('HostlistTest',
dependencies: [dep_qt5, dep_urlfilter],
sources: ['hostlist/hostlisttest.cpp', qt5.preprocess(moc_headers: 'hostlist/hostlisttest.h', dependencies: dep_qt5)]
)
-test('urlfilter-hostlist', hostlist)
+test('urlfilter-hostlist', hostlist, workdir: meson.current_source_dir())
# matching algorithms benchmark
matcherbenchmark = executable('MatcherBenchmark',