diff options
Diffstat (limited to 'gcc-4.9/libstdc++-v3/testsuite/28_regex')
9 files changed, 356 insertions, 1 deletions
diff --git a/gcc-4.9/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/63199.cc b/gcc-4.9/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/63199.cc new file mode 100644 index 000000000..cbb23f7de --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/63199.cc @@ -0,0 +1,69 @@ +// { dg-options "-std=gnu++11" } + +// +// Copyright (C) 2014 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/>. + +#include <regex> +#include <testsuite_hooks.h> +#include <testsuite_regex.h> + +using namespace __gnu_test; +using namespace std; + +// libstdc++/63199 +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::setlocale(LC_ALL, ""); + + std::wstring current_token(L"II."); + + std::vector<std::wregex> regex_vector; + + for (int i = 0; i < 4; ++i) + { + std::regex_constants::syntax_option_type flag; + flag = std::regex_constants::ECMAScript | std::regex_constants::icase; + + std::wregex reg; + reg.imbue(std::locale("")); + reg.assign(L"^(M*(?:CM|DC{1,3}|D|CD|C{1,3}){0,1}(?:XC|LX{1,3}|L|XL|X{1,3}){0,1}(?:IX|VI{0,3}|IV|I{1,3}){0,1}\\.)$", flag); + + regex_vector.emplace_back(reg); + } + + for (auto cit = regex_vector.cbegin(); cit != regex_vector.cend(); ++cit) + { + std::wstring::const_iterator it1 = current_token.begin(); + std::wstring::const_iterator it2 = current_token.end(); + std::wsmatch current_token_match; + + regex_match_debug(it1, it2, current_token_match, *cit); + VERIFY(current_token_match[0] == current_token); + VERIFY(current_token_match[1] == current_token); + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/string.cc b/gcc-4.9/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/string.cc index 0a32ab5e6..7d4db8f10 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/string.cc +++ b/gcc-4.9/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/string.cc @@ -1,4 +1,3 @@ -// { dg-do compile } // { dg-options "-std=gnu++0x" } // 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com> @@ -29,6 +28,7 @@ // Tests C++ string assignment of the basic_regex class. void test01() { + bool test __attribute__((unused)) = true; typedef std::basic_regex<char> test_type; std::string s("a*b"); @@ -36,9 +36,27 @@ void test01() re.assign(s); } +// libstdc++/64584 +void test02() +{ + bool test __attribute__((unused)) = true; + std::regex re("", std::regex_constants::extended); + auto flags = re.flags(); + try + { + re.assign("(", std::regex_constants::icase); + VERIFY(false); + } + catch (const std::regex_error& e) + { + VERIFY(flags == re.flags()); + } +} + int main() { test01(); + test02(); return 0; } diff --git a/gcc-4.9/libstdc++-v3/testsuite/28_regex/basic_regex/imbue/string.cc b/gcc-4.9/libstdc++-v3/testsuite/28_regex/basic_regex/imbue/string.cc new file mode 100644 index 000000000..d4d4f4705 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/28_regex/basic_regex/imbue/string.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2015 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.8.5] class template basic_regex locale + +#include <string> +#include <regex> +#include <testsuite_hooks.h> + +// libstdc++/64585 +void test01() +{ + bool test __attribute__((unused)) = true; + + static const char s[] = "a"; + std::regex re("a"); + VERIFY(std::regex_search(s, re)); + + auto loc = re.imbue(re.getloc()); + VERIFY(!std::regex_search(s, re)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/28_regex/iterators/regex_iterator/char/64140.cc b/gcc-4.9/libstdc++-v3/testsuite/28_regex/iterators/regex_iterator/char/64140.cc new file mode 100644 index 000000000..32b7e241c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/28_regex/iterators/regex_iterator/char/64140.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++11" } + +// +// Copyright (C) 2014 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/>. + +// libstdc++/64140 + +#include <regex> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::regex e("z*"); + const std::string s("ab"); + + auto it = std::sregex_iterator(s.begin(), s.end(), e); + auto end = std::sregex_iterator(); + VERIFY(it != end); + VERIFY(!it->prefix().matched); + ++it; + VERIFY(it != end); + VERIFY(it->prefix().matched); + ++it; + VERIFY(it != end); + VERIFY(it->prefix().matched); + ++it; + VERIFY(it == end); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/28_regex/iterators/regex_iterator/char/string_position_01.cc b/gcc-4.9/libstdc++-v3/testsuite/28_regex/iterators/regex_iterator/char/string_position_01.cc index 5fa4ea774..91aa06137 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/28_regex/iterators/regex_iterator/char/string_position_01.cc +++ b/gcc-4.9/libstdc++-v3/testsuite/28_regex/iterators/regex_iterator/char/string_position_01.cc @@ -24,6 +24,7 @@ // Tests iter->position() behavior #include <regex> +#include <tuple> #include <testsuite_hooks.h> void @@ -41,9 +42,53 @@ test01() } } +// PR libstdc++/64239 +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::regex re("\\w+"); + std::string s("-a-b-c-"); + + std::tuple<int, int, const char*> expected[] = + { + std::make_tuple(1, 1, "a"), + std::make_tuple(3, 1, "b"), + std::make_tuple(5, 1, "c"), + }; + + int i = 0; + for (auto it1 = std::sregex_iterator(s.begin(), s.end(), re), + end = std::sregex_iterator(); it1 != end; ++it1, i++) + { + auto it2 = it1; + VERIFY(it1->position() == std::get<0>(expected[i])); + VERIFY(it1->length() == std::get<1>(expected[i])); + VERIFY(it1->str() == std::get<2>(expected[i])); + VERIFY(it2->position() == std::get<0>(expected[i])); + VERIFY(it2->length() == std::get<1>(expected[i])); + VERIFY(it2->str() == std::get<2>(expected[i])); + } +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::smatch m; + std::string s = "abcde"; + std::regex_search(s, m, std::regex("bcd")); + VERIFY(m.position() == 1); + VERIFY(m.position() == m.prefix().length()); +} + int main() { test01(); + test02(); + test03(); return 0; } diff --git a/gcc-4.9/libstdc++-v3/testsuite/28_regex/iterators/regex_token_iterator/64303.cc b/gcc-4.9/libstdc++-v3/testsuite/28_regex/iterators/regex_token_iterator/64303.cc new file mode 100644 index 000000000..f09bbe1c9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/28_regex/iterators/regex_token_iterator/64303.cc @@ -0,0 +1,49 @@ +// { dg-do run } +// { dg-options "-std=gnu++11" } + +// +// Copyright (C) 2014 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.12.2 Class template regex_token_iterator + +#include <regex> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::string s(" 111 222 "); + const std::regex re("\\w+"); + + std::sregex_token_iterator it1(s.begin(), s.end(), re), it2(it1), end; + + for (; it1 != end; ++it1, ++it2) { + VERIFY(it1 == it2); + VERIFY(*it1 == *it2); + } + VERIFY(it2 == end); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/28_regex/match_results/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/28_regex/match_results/swap.cc new file mode 100644 index 000000000..18248c1c5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/28_regex/match_results/swap.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11" } + +// +// Copyright (C) 2015 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/>. + +#include <regex> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::cmatch m; + std::regex_match("a", m, std::regex("a")); + std::cmatch mm1 = m, mm2; + mm1.swap(mm2); + VERIFY(m == mm2); + std::swap(mm1, mm2); + VERIFY(m == mm1); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/28_regex/traits/char/lookup_classname.cc b/gcc-4.9/libstdc++-v3/testsuite/28_regex/traits/char/lookup_classname.cc index 48ab04375..f2a99ab4a 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/28_regex/traits/char/lookup_classname.cc +++ b/gcc-4.9/libstdc++-v3/testsuite/28_regex/traits/char/lookup_classname.cc @@ -26,6 +26,7 @@ // 28.7(9) Class template regex_traits [re.traits] #include <regex> +#include <forward_list> #include <testsuite_hooks.h> void @@ -47,8 +48,29 @@ test01() VERIFY( c2 == c3 ); } +// Test forward iterator +void +test02() +{ + const char strlit[] = "upper"; + std::forward_list<char> s(strlit, strlit + strlen(strlit)); + std::regex_traits<char> traits; + VERIFY(traits.isctype('C', traits.lookup_classname(s.begin(), s.end(), false))); +} + +// icase +void +test03() +{ + std::string s("lower"); + std::regex_traits<char> traits; + VERIFY(traits.isctype('C', traits.lookup_classname(s.begin(), s.end(), true))); +} + int main() { test01(); + test02(); + test03(); return 0; } diff --git a/gcc-4.9/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc b/gcc-4.9/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc index 825f2ba2b..698c18df7 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc +++ b/gcc-4.9/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc @@ -26,6 +26,7 @@ // 28.7 (8) Class template regex_traits [re.traits] #include <regex> +#include <forward_list> #include <testsuite_hooks.h> void @@ -40,8 +41,19 @@ test01() VERIFY(t.lookup_collatename(name, name+sizeof(name)-1) == "~"); } +// Test forward iterator. +void +test02() +{ + const char strlit[] = "tilde"; + std::forward_list<char> s(strlit, strlit + strlen(strlit)); + std::regex_traits<char> traits; + VERIFY(traits.lookup_collatename(s.begin(), s.end()) == "~"); +} + int main() { test01(); + test02(); return 0; } |