diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-Regex.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test-Regex.cc b/tests/test-Regex.cc new file mode 100644 index 0000000..b656445 --- /dev/null +++ b/tests/test-Regex.cc @@ -0,0 +1,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"); +} |