summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/re
diff options
context:
space:
mode:
authorTim Shen <timshen91@gmail.com>2016-10-27 21:40:34 +0000
committerTim Shen <timshen91@gmail.com>2016-10-27 21:40:34 +0000
commite776667441686a82f394fac401a9822bc7d63f6c (patch)
tree2d48d35e458ddf12a290546e9db3d521ce32c2ad /libcxx/test/std/re
parentf38e87fa48c66957a90ce41e4f41bbdc80ad6953 (diff)
downloadbcm5719-llvm-e776667441686a82f394fac401a9822bc7d63f6c.tar.gz
bcm5719-llvm-e776667441686a82f394fac401a9822bc7d63f6c.zip
[libcxx] Make regex_match backtrack when search fails
Summary: Fixes PR19851. alg.re.match/ecma.pass.cpp still XFAILS on linux, but after commenting out locale-related tests, it passes. I don't have a freebsd machine to produce a full pass. Reviewers: mclow.lists Subscribers: cfe-commits, emaste Differential Revision: https://reviews.llvm.org/D26026 llvm-svn: 285352
Diffstat (limited to 'libcxx/test/std/re')
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp62
1 files changed, 52 insertions, 10 deletions
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
index a4568f60167..bbe57adc619 100644
--- a/libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
+++ b/libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
@@ -371,16 +371,37 @@ int main()
}
{
std::cmatch m;
+ // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2273
const char s[] = "tournament";
- assert(!std::regex_match(s, m, std::regex("tour|to|tournament")));
- assert(m.size() == 0);
+ assert(std::regex_match(s, m, std::regex("tour|to|tournament")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
}
{
std::cmatch m;
+ // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2273
const char s[] = "tournamenttotour";
- assert(!std::regex_match(s, m, std::regex("(tour|to|tournament)+",
- std::regex_constants::nosubs)));
- assert(m.size() == 0);
+ assert(
+ std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
}
{
std::cmatch m;
@@ -1036,16 +1057,37 @@ int main()
}
{
std::wcmatch m;
+ // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2273
const wchar_t s[] = L"tournament";
- assert(!std::regex_match(s, m, std::wregex(L"tour|to|tournament")));
- assert(m.size() == 0);
+ assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
}
{
std::wcmatch m;
+ // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2273
const wchar_t s[] = L"tournamenttotour";
- assert(!std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
- std::regex_constants::nosubs)));
- assert(m.size() == 0);
+ assert(
+ std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
}
{
std::wcmatch m;
OpenPOWER on IntegriCloud