1 // { dg-options "-std=gnu++11" }
4 // 2013-08-01 Tim Shen <timshen91@gmail.com>
6 // Copyright (C) 2013-2015 Free Software Foundation, Inc.
8 // This file is part of the GNU ISO C++ Library. This library is free
9 // software; you can redistribute it and/or modify it under the
10 // terms of the GNU General Public License as published by the
11 // Free Software Foundation; either version 3, or (at your option)
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License along
20 // with this library; see the file COPYING3. If not see
21 // <http://www.gnu.org/licenses/>.
23 // 28.11.2 regex_match
24 // Tests Extended bracket expression against a C-string.
27 #include <testsuite_hooks.h>
28 #include <testsuite_regex.h>
30 using namespace __gnu_test
;
36 bool test
__attribute__((unused
)) = true;
39 std::regex
re("pre/[za-x]", std::regex::extended
);
40 VERIFY( regex_match_debug("pre/z", re
) );
41 VERIFY( regex_match_debug("pre/a", re
) );
42 VERIFY( !regex_match_debug("pre/y", re
) );
45 std::regex
re("pre/[[:uPPer:]]", std::regex::extended
);
46 VERIFY( regex_match_debug("pre/Z", re
) );
47 VERIFY( !regex_match_debug("pre/_", re
) );
48 VERIFY( !regex_match_debug("pre/a", re
) );
49 VERIFY( !regex_match_debug("pre/0", re
) );
52 std::regex
re("pre/[[:lOWer:]]", std::regex::extended
| std::regex::icase
);
53 VERIFY( regex_match_debug("pre/Z", re
) );
54 VERIFY( regex_match_debug("pre/a", re
) );
57 std::regex
re("pre/[[:w:][.tilde.]]", std::regex::extended
);
58 VERIFY( regex_match_debug("pre/~", re
) );
59 VERIFY( regex_match_debug("pre/_", re
) );
60 VERIFY( regex_match_debug("pre/a", re
) );
61 VERIFY( regex_match_debug("pre/0", re
) );
64 std::regex
re("pre/[[=a=]]", std::regex::extended
);
65 VERIFY( regex_match_debug("pre/a", re
) );
66 VERIFY( regex_match_debug("pre/A", re
) );
73 bool test
__attribute__((unused
)) = true;
77 std::regex
re("[-----]", std::regex::extended
);
80 catch (const std::regex_error
& e
)
82 VERIFY(e
.code() == std::regex_constants::error_range
);
84 std::regex
re("[-----]", std::regex::ECMAScript
);
90 bool test
__attribute__((unused
)) = true;
94 std::regex
re("[z-a]", std::regex::extended
);
97 catch (const std::regex_error
& e
)
99 VERIFY(e
.code() == std::regex_constants::error_range
);
106 bool test
__attribute__((unused
)) = true;
108 std::regex
re("[-0-9a-z]");
109 VERIFY(regex_match_debug("-", re
));
110 VERIFY(regex_match_debug("1", re
));
111 VERIFY(regex_match_debug("w", re
));
112 re
.assign("[-0-9a-z]", regex_constants::basic
);
113 VERIFY(regex_match_debug("-", re
));
114 VERIFY(regex_match_debug("1", re
));
115 VERIFY(regex_match_debug("w", re
));