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

BALAU_STARTUP;

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

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

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