1 // { dg-do run { target c++11 } }
4 // Copyright (C) 2015-2017 Free Software Foundation, Inc.
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)
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
;
31 regex
re("((.)", regex_constants::basic
);
43 auto rx
= std::regex(re_str
, std::regex_constants::grep
| std::regex_constants::icase
);
44 VERIFY(regex_search_debug("/abcd", rx
));
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
));
62 static const char* kNumericAnchor
="(\\$|usd)(usd|\\$|to|and|up to|[0-9,\\.\\-\\sk])+";
63 const std::regex
re(kNumericAnchor
);
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-]")));
79 char const s
[] = "afoo";
80 std::basic_regex
<char> r("(f+)");
82 std::cregex_iterator
i(s
, s
+sizeof(s
), r
);
83 std::cregex_iterator
j(s
, s
+sizeof(s
), r
);
86 // The iterator manipulation code must be repeated in the same scope
87 // to expose the undefined read during the execution of the ==
88 // operator (stack location reuse)
90 std::cregex_iterator
i(s
, s
+sizeof(s
), r
);
91 std::cregex_iterator j
;