container_access.cc: Remove 'test' variables.
[official-gcc.git] / libstdc++-v3 / testsuite / 28_regex / regression.cc
blobeffb356075e0cfb52a8fb494cd2ce7169257a4f9
1 // { dg-do run { target c++11 } }
3 //
4 // Copyright (C) 2015-2016 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 #include <testsuite_hooks.h>
22 #include <testsuite_regex.h>
24 using namespace __gnu_test;
25 using namespace std;
27 // PR libstdc++/67362
28 void
29 test01()
31 regex re("((.)", regex_constants::basic);
34 void
35 test02()
37 std::string re_str
39 "/abcd" "\n"
40 "/aecf" "\n"
41 "/ghci"
43 auto rx = std::regex(re_str, std::regex_constants::grep | std::regex_constants::icase);
44 VERIFY(regex_search_debug("/abcd", rx));
47 void
48 test03()
50 VERIFY(regex_match_debug("a.", regex(R"(a\b.)"), regex_constants::match_not_eow));
51 VERIFY(regex_match_debug(".a", regex(R"(.\ba)"), regex_constants::match_not_bow));
52 VERIFY(regex_search_debug("a", regex(R"(^\b)")));
53 VERIFY(regex_search_debug("a", regex(R"(\b$)")));
54 VERIFY(!regex_search_debug("a", regex(R"(^\b)"), regex_constants::match_not_bow));
55 VERIFY(!regex_search_debug("a", regex(R"(\b$)"), regex_constants::match_not_eow));
58 // PR libstdc++/77356
59 void
60 test04()
62 static const char* kNumericAnchor ="(\\$|usd)(usd|\\$|to|and|up to|[0-9,\\.\\-\\sk])+";
63 const std::regex re(kNumericAnchor);
64 (void)re;
67 void
68 test05()
70 VERIFY(regex_match_debug("!", std::regex("[![:alnum:]]")));
71 VERIFY(regex_match_debug("-", std::regex("[a-]", regex_constants::basic)));
72 VERIFY(regex_match_debug("-", std::regex("[a-]")));
75 int
76 main()
78 test01();
79 test02();
80 test03();
81 test04();
82 test05();
83 return 0;