diff options
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() |