#define CATCH_CONFIG_MAIN #include "filterlist.h" #include #include // clazy:skip using namespace Hostlist; TEST_CASE("Hostlist") { Filterlist list; const QString filename(qgetenv("HOSTLIST_TXT")); REQUIRE(!filename.isEmpty()); QFile f(filename); REQUIRE(f.open(QIODevice::ReadOnly | QIODevice::Text)); REQUIRE(list.load(f)); f.close(); REQUIRE(list.count() == 4); QUrl first("http://blockeddomain.first"); REQUIRE(list.findMatch(first) == Filterlist::Block); QUrl second("http://blockeddomain.second/path/to/something"); REQUIRE(list.findMatch(second) == Filterlist::Block); QUrl localhost("http://localhost.localdomain"); REQUIRE(list.findMatch(localhost) == Filterlist::Redirect); REQUIRE(localhost.toString() == "http://127.0.0.1"); QUrl other("http://other.domain"); REQUIRE(list.findMatch(other) == Filterlist::NotFound); }