diff options
author | Tim Shen <timshen91@gmail.com> | 2013-09-24 02:05:00 +0000 |
---|---|---|
committer | Tim Shen <timshen@gcc.gnu.org> | 2013-09-24 02:05:00 +0000 |
commit | c2669da93de6bb84df96b14167429f2046acf4b8 (patch) | |
tree | f337d8cd5418382592d93b47f24f42a62224bd74 /libstdc++-v3/testsuite | |
parent | 5704e0224012d70573d27f7934b672ee5ff99549 (diff) | |
download | gcc-c2669da93de6bb84df96b14167429f2046acf4b8.zip gcc-c2669da93de6bb84df96b14167429f2046acf4b8.tar.gz gcc-c2669da93de6bb84df96b14167429f2046acf4b8.tar.bz2 |
Makefile.am: Add regex.tcc.
2013-09-24 Tim Shen <timshen91@gmail.com>
* include/Makefile.am: Add regex.tcc.
* include/Makefile.in: Regenerate.
* include/bits/regex.h: Remove definitions to regex.tcc.
* include/bits/regex.tcc: New.
(match_results::format, regex_replace): Implement;
* include/bits/regex_compiler.h: Move _M_flags to the top of class
member list, because other members' initialization depend on it.
* include/bits/regex_compiler.tcc
(_Compiler<>::_Compiler): Adjust member initializations.
(_Compiler<>::_M_quantifier): Fix ungreedy interval quantifier.
* include/bits/regex_executor.h: Remove _RegexT from _*Executor classes.
In the future, all regex classes may refactor to *Impl style.
* include/bits/regex_executor.tcc (_Executor::_M_set_results):
Merge identical code from _*Executor classes.
* testsuite/28_regex/algorithms/regex_match/extended/
string_dispatch_01.cc (fake_match<>): Adjust the hacking-style testcase
caller for new __get_executors interface.
* testsuite/28_regex/algorithms/regex_replace/char/basic_replace.cc:
New.
* testsuite/28_regex/match_results/format.cc: New.
* testsuite/28_regex/traits/char/lookup_collatename.cc: Remove digraph
testcase.
* testsuite/28_regex/traits/wchar_t/lookup_collatename.cc: Likewise.
From-SVN: r202858
Diffstat (limited to 'libstdc++-v3/testsuite')
5 files changed, 110 insertions, 14 deletions
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/string_dispatch_01.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/string_dispatch_01.cc index cb502ea..4634c7d 100644 --- a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/string_dispatch_01.cc +++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/string_dispatch_01.cc @@ -38,9 +38,10 @@ template<typename _Bi_iter, typename _Alloc, regex_constants::match_flag_type __flags = regex_constants::match_default) { + auto& __res = (vector<sub_match<_Bi_iter>, _Alloc>&)(__m); VERIFY( (dynamic_cast <__detail::_DFSExecutor<_Bi_iter, _Alloc, _Ch_type, _Rx_traits>*> - (&*__detail::__get_executor(__s, __e, __m, __re, __flags)) + (&*__detail::__get_executor(__s, __e, __res, __re, __flags)) != nullptr) ); } diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/basic_replace.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/basic_replace.cc new file mode 100644 index 0000000..ca3f16f --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/basic_replace.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } + +// +// 2013-09-24 Tim Shen <timshen91@gmail.com> +// +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 28.11.4 regex_replace +// Tests ECMAScript regex_replace. + +#include <regex> +#include <testsuite_hooks.h> + +using namespace std; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY(regex_replace(string("This is a string"), regex("\\b\\w*\\b"), "|$0|") + == "|This||| |is||| |a||| |string|||"); + VERIFY(regex_replace(string("This is a string"), regex("\\b\\w*\\b"), "|$0|", + regex_constants::format_no_copy) + == "|This||||is||||a||||string|||"); + VERIFY(regex_replace(string("This is a string"), regex("\\b\\w*\\b"), "|$0|", + regex_constants::format_first_only) + == "|This| is a string"); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/28_regex/match_results/format.cc b/libstdc++-v3/testsuite/28_regex/match_results/format.cc new file mode 100644 index 0000000..be08016 --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/match_results/format.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } + +// +// 2013-09-24 Tim Shen <timshen91@gmail.com> +// +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 28.10.5 formatting +// Tests ECMAScript format() + +#include <regex> +#include <testsuite_hooks.h> + +using namespace std; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + cmatch m; + VERIFY(regex_search("*** this is a string !!!", m, + regex("(\\w+) (\\w+) (\\w+) (\\w+)"))); + VERIFY(m.format("$&|$`|$3|$4|$2|$1|$'$$$") + == "this is a string|*** |a|string|is|this| !!!$$"); + VERIFY(m.format("&|\\3|\\4|\\2|\\1|\\", + regex_constants::format_sed) + == "this is a string|a|string|is|this|\\"); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc b/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc index 7e0b259..dba0fc3 100644 --- a/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc +++ b/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc @@ -35,12 +35,9 @@ test01() typedef char CharT; typedef std::regex_traits<CharT> traits; - char name[] = "ll"; - traits t; - - traits::string_type sname = t.lookup_collatename(name, name+sizeof(name)-1); - - VERIFY( !sname.empty() ); + traits t; + CharT name[] = "tilde"; + VERIFY(t.lookup_collatename(name, name+sizeof(name)-1) == "~"); } int main() diff --git a/libstdc++-v3/testsuite/28_regex/traits/wchar_t/lookup_collatename.cc b/libstdc++-v3/testsuite/28_regex/traits/wchar_t/lookup_collatename.cc index 197bb9b..3d20cfa 100644 --- a/libstdc++-v3/testsuite/28_regex/traits/wchar_t/lookup_collatename.cc +++ b/libstdc++-v3/testsuite/28_regex/traits/wchar_t/lookup_collatename.cc @@ -33,13 +33,9 @@ test01() typedef wchar_t CharT; typedef std::regex_traits<CharT> traits; - wchar_t name[] = L"ll"; - traits t; - - traits::string_type sname = - t.lookup_collatename(name, name+sizeof(name)/sizeof(*name)-1); - - VERIFY( !sname.empty() ); + traits t; + CharT name[] = L"tilde"; + VERIFY(t.lookup_collatename(name, name+sizeof(name)/sizeof(*name)-1) == L"~"); } int main() |