Regex: add unit test to check the ".*" construct
This commit is contained in:
parent
4010c44fc0
commit
ee42c6b0ba
|
@ -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());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user