Add tests for regex_match ambiguity (aka LWG2273). NFC. Reviewed as https://reviews.llvm.org/D63051

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@365080 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2019-07-03 20:32:35 +00:00
parent 78af2bfb2f
commit 7d00fc23cd
3 changed files with 50 additions and 2 deletions

View File

@@ -1547,6 +1547,30 @@ int main(int, char**)
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
{ // LWG 2273
std::regex re("Foo|FooBar");
std::cmatch m;
{
assert(std::regex_search("FooBar", m, re));
assert(m.size() == 1);
assert(m[0] == "Foo");
}
{
assert(std::regex_search("Foo", m, re));
assert(m.size() == 1);
assert(m[0] == "Foo");
}
{
assert(std::regex_search("FooBarBaz", m, re));
assert(m.size() == 1);
assert(m[0] == "Foo");
}
{
assert(std::regex_search("FooBa", m, re));
assert(m.size() == 1);
assert(m[0] == "Foo");
}
}
return 0;
}