diff options
author | Tim Shen <timshen@google.com> | 2015-01-22 05:02:38 +0000 |
---|---|---|
committer | Tim Shen <timshen@gcc.gnu.org> | 2015-01-22 05:02:38 +0000 |
commit | 77033d2668248d1050d27ea57a8e85a1b3740ac8 (patch) | |
tree | 90302357b43d6ab8e2367e5fa7e0b3b492326363 /libstdc++-v3/testsuite/28_regex | |
parent | fa3340ec8f4d26bba4efa5095c8a2a142f34b8bc (diff) | |
download | gcc-77033d2668248d1050d27ea57a8e85a1b3740ac8.zip gcc-77033d2668248d1050d27ea57a8e85a1b3740ac8.tar.gz gcc-77033d2668248d1050d27ea57a8e85a1b3740ac8.tar.bz2 |
re PR libstdc++/64649 (regex_traits::lookup_classname() only works with random access iterators)
PR libstdc++/64649
* include/bits/regex.tcc (regex_traits<>::lookup_collatename,
regex_traits<>::lookup_classname): Correctly narrow input chars.
* testsuite/28_regex/traits/wchar_t/user_defined.cc: New testcase.
From-SVN: r219986
Diffstat (limited to 'libstdc++-v3/testsuite/28_regex')
-rw-r--r-- | libstdc++-v3/testsuite/28_regex/traits/wchar_t/user_defined.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/28_regex/traits/wchar_t/user_defined.cc b/libstdc++-v3/testsuite/28_regex/traits/wchar_t/user_defined.cc index 16bcd6a..8c686be 100644 --- a/libstdc++-v3/testsuite/28_regex/traits/wchar_t/user_defined.cc +++ b/libstdc++-v3/testsuite/28_regex/traits/wchar_t/user_defined.cc @@ -55,8 +55,32 @@ test01() VERIFY(!regex_match(L"\u2029", re)); } +struct MyCtype : std::ctype<wchar_t> +{ + char + do_narrow(wchar_t c, char dflt) const override + { + if (c >= 256) + return dflt; + return ((char)c)+1; + } +}; + +void +test02() +{ + std::locale loc(std::locale(), new MyCtype); + std::regex_traits<wchar_t> traits; + traits.imbue(loc); + wchar_t wch = L'p'; + VERIFY(traits.lookup_collatename(&wch, &wch+1) == L"q"); + std::wstring ws = L"chfhs"; // chars of "digit" shifted by 1. + VERIFY(traits.lookup_classname(ws.begin(), ws.end()) != 0); +} + int main() { test01(); + test02(); return 0; } |