diff options
author | timshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-24 02:05:00 +0000 |
---|---|---|
committer | timshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-24 02:05:00 +0000 |
commit | 463f6239114ff5b2eaec0ff6d1996c280dbfc378 (patch) | |
tree | f337d8cd5418382592d93b47f24f42a62224bd74 /libstdc++-v3/testsuite/28_regex | |
parent | 4cac359414a2dc6f27d3068ef3f51f5f253125e9 (diff) | |
download | gcc-463f6239114ff5b2eaec0ff6d1996c280dbfc378.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202858 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/28_regex')
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 cb502eadfb4..4634c7d1d35 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 00000000000..ca3f16f7d23 --- /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 00000000000..be080162143 --- /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 7e0b259e0b7..dba0fc357e5 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 197bb9b4a78..3d20cfaf9a0 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() |