Regex: add unit test to check the ".*" construct

This commit is contained in:
Maxime Coste 2017-09-17 20:12:46 +09:00
parent 4010c44fc0
commit ee42c6b0ba

View File

@ -392,6 +392,18 @@ auto test_regex = UnitTest{[]{
kak_assert(not exec.match(program, "acb")); kak_assert(not exec.match(program, "acb"));
kak_assert(not exec.match(program, "")); kak_assert(not exec.match(program, ""));
} }
{
StringView re = "^a.*b$";
auto program = RegexCompiler::compile(re.begin(), re.end());
RegexProgram::dump(program);
Exec exec{program};
kak_assert(exec.match(program, "afoob"));
kak_assert(exec.match(program, "ab"));
kak_assert(not exec.match(program, "bab"));
kak_assert(not exec.match(program, ""));
}
{ {
StringView re = "^(foo|qux|baz)+(bar)?baz$"; StringView re = "^(foo|qux|baz)+(bar)?baz$";
auto program = RegexCompiler::compile(re.begin(), re.end()); auto program = RegexCompiler::compile(re.begin(), re.end());