1 // { dg-do run { target c++11 } }
3 // Copyright (C) 2015-2018 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 #include <testsuite_hooks.h>
22 #include <testsuite_regex.h>
25 using namespace __gnu_test
;
31 const char s
[] = "abc";
32 const std::regex
re("(\\d+)|(\\w+)");
35 VERIFY(regex_search_debug(s
, m
, re
));
37 std::tuple
<bool, string
, int, int> expected
[] = {
38 make_tuple(true, "abc", 0, 3),
39 make_tuple(false, "", 3, 3),
40 make_tuple(true, "abc", 0, 3),
41 make_tuple(false, "", 3, 3),
43 for (size_t i
= 0, n
= m
.size(); i
<= n
; ++i
) {
45 VERIFY(sub
.matched
== std::get
<0>(expected
[i
]));
46 VERIFY(sub
.str() == std::get
<1>(expected
[i
]));
47 VERIFY((sub
.first
- s
) == std::get
<2>(expected
[i
]));
48 VERIFY((sub
.second
- s
) == std::get
<3>(expected
[i
]));
56 std::match_results
<const char*> m
;
58 VERIFY(regex_search_debug(s
, m
, std::regex("a")));
60 VERIFY(m
.size() == 1);
62 VERIFY(m
[0].first
== s
+0);
63 VERIFY(m
[0].second
== s
+1);
64 VERIFY(m
[0].matched
== true);
66 VERIFY(m
[42].first
== s
+1);
67 VERIFY(m
[42].second
== s
+1);
68 VERIFY(m
[42].matched
== false);