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

@@ -1367,6 +1367,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_match("FooBar", m, re));
assert(m.size() == 1);
assert(m[0] == "FooBar");
}
{
assert(std::regex_match("Foo", m, re));
assert(m.size() == 1);
assert(m[0] == "Foo");
}
{
assert(!std::regex_match("FooBarBaz", m, re));
assert(m.size() == 0);
assert(m.empty());
}
{
assert(!std::regex_match("FooBa", m, re));
assert(m.size() == 0);
assert(m.empty());
}
}
return 0;
}