diff options
author | Tim Shen <timshen91@gmail.com> | 2013-10-26 16:09:28 +0000 |
---|---|---|
committer | Tim Shen <timshen@gcc.gnu.org> | 2013-10-26 16:09:28 +0000 |
commit | 9f0d9611e7e420aa97837774053b0c8a11d0bfd7 (patch) | |
tree | ed9926c18c61592e28734e2226b4d5ab7fb3fcf0 /libstdc++-v3/testsuite/28_regex | |
parent | 5d905bb6131f34cc21461c111e1afc95fb85b7eb (diff) | |
download | gcc-9f0d9611e7e420aa97837774053b0c8a11d0bfd7.zip gcc-9f0d9611e7e420aa97837774053b0c8a11d0bfd7.tar.gz gcc-9f0d9611e7e420aa97837774053b0c8a11d0bfd7.tar.bz2 |
regex.h: Remove unnecessary friends.
2013-10-26 Tim Shen <timshen91@gmail.com>
* include/bits/regex.h: Remove unnecessary friends.
* include/bits/regex.tcc (__regex_algo_impl<>): Move __get_executor
to here.
* include/bits/regex_executor.h: Remove _DFSExecutor and _BFSExecutor;
they are merged into _Executor. Eliminate quantifier tracking part, so
it's faster.
* include/bits/regex_executor.tcc: Implement _Executor.
* testsuite/28_regex/algorithms/regex_match/ecma/char/ungreedy.cc: New.
* testsuite/28_regex/algorithms/regex_search/ecma/greedy.cc: Adjust
duplicate testcases.
* testsuite/performance/28_regex/split.h: New.
* testsuite/performance/28_regex/split_bfs.cc: New.
* testsuite/util/testsuite_regex.h: Adjust behavior of two-executors
agreement judger: do not compare match_results when executor return
false.
From-SVN: r204093
Diffstat (limited to 'libstdc++-v3/testsuite/28_regex')
3 files changed, 53 insertions, 75 deletions
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/ungreedy.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/ungreedy.cc new file mode 100644 index 0000000..ed26ebb --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/ungreedy.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++11" } + +// +// 2013-10-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.2 regex_match +// Tests ECMAScript ungreedy match. + +#include <regex> +#include <testsuite_hooks.h> +#include <testsuite_regex.h> + +using namespace __gnu_test; +using namespace std; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + regex re("(a*?)*?"); + cmatch m; + VERIFY(regex_match("a", m, re)); + VERIFY(m.size() == 2); + VERIFY(string(m[0].first, m[0].second) == "a"); +} + +int +main() +{ + test01(); + return 0; +} 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 deleted file mode 100644 index 50141f0..0000000 --- a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/string_dispatch_01.cc +++ /dev/null @@ -1,72 +0,0 @@ -// { dg-options "-std=gnu++11" } - -// -// 2013-07-29 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.2 regex_match -// Tests Extended automatic matcher dispatching against a std::string target. - -#include <regex> -#include <testsuite_hooks.h> - -using namespace std; - -template<typename _Bi_iter, typename _Alloc, - typename _Ch_type, typename _Rx_traits> - void - fake_match(_Bi_iter __s, - _Bi_iter __e, - match_results<_Bi_iter, _Alloc>& __m, - const basic_regex<_Ch_type, _Rx_traits>& __re, - regex_constants::match_flag_type __flags - = regex_constants::match_default) - { - using namespace __detail; - auto& __res = (vector<sub_match<_Bi_iter>, _Alloc>&)(__m); - VERIFY( (dynamic_cast - <_DFSExecutor<_Bi_iter, _Alloc, _Ch_type, _Rx_traits>*> - (&*__get_executor<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, - _RegexExecutorPolicy::_S_auto>(__s, __e, __res, __re, __flags)) - != nullptr) ); - } - -void -test01() -{ - bool test __attribute__((unused)) = true; - - regex re("()(one(.*))abc\\1"); // backref cause DFS - const string target("onetwoabc"); - smatch m; - fake_match(target.begin(), target.end(), m, re); - - regex_match(target, m, re); - VERIFY( m[2].matched ); - VERIFY( m[3].matched ); - VERIFY( std::string(m[2].first, m[2].second) == "onetwo" ); - VERIFY( std::string(m[3].first, m[3].second) == "two" ); -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/greedy.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/greedy.cc index 107ced0..5821bba 100644 --- a/libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/greedy.cc +++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/greedy.cc @@ -54,9 +54,9 @@ test01() VERIFY(regex_search_debug("aaaa", m, regex("(a+)(a+)"))); TEST(1, "aaa"); TEST(2, "a"); - VERIFY(regex_search_debug("aaaa", m, regex("(a+?)(a+)"))); - TEST(1, "a"); - TEST(2, "aaa"); + VERIFY(regex_search_debug("aaaa", m, regex("(a+)(a+?)"))); + TEST(1, "aaa"); + TEST(2, "a"); VERIFY(regex_search_debug("aaaa", m, regex("(a+?)(a+)"))); TEST(1, "a"); TEST(2, "aaa"); |