summaryrefslogtreecommitdiff
path: root/tests/test-Regex.cc
blob: 082afd21f9ac2bfa69ff932c535d915a5d0aff79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <Main.h>
#include <BRegex.h>

using namespace Balau;

void MainTask::Do() {
    Printer::log(M_STATUS, "Test::Regex running");

    Regex reg("http://([^/ ]+)/([^? ]+)(\\?([^ ]+))?");
    Regex::Captures c = reg.match("some url: http://www.test.com/uri?var1=val1 that should match");

    TAssert(c[0] == "http://www.test.com/uri?var1=val1");
    TAssert(c[1] == "www.test.com");
    TAssert(c[2] == "uri");
    TAssert(c[3] == "?var1=val1");
    TAssert(c[4] == "var1=val1");

    Printer::log(M_STATUS, "Test::Regex passed");
}