aboutsummaryrefslogtreecommitdiff
path: root/plugins/smolblok_hostlist/test/filterlist.cpp
blob: 4aa532b554f99c136246794c6b607013d60d689c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#define CATCH_CONFIG_MAIN
#include "filterlist.h"
#include <QFile>
#include <catch2/catch.hpp>

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);

    REQUIRE(list.findMatch("blockeddomain.first"));
    REQUIRE(list.findMatch("blockeddomain.second"));

    REQUIRE(list.findMatch("localhost.localdomain"));

    REQUIRE(!list.findMatch("other.domain"));
}