aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/28_regex
diff options
context:
space:
mode:
authorTim Shen <timshen@google.com>2014-11-13 07:40:01 +0000
committerTim Shen <timshen@gcc.gnu.org>2014-11-13 07:40:01 +0000
commit79b576cc38fbb037993d56b9e5f7e1fca7ee5807 (patch)
tree68d467d9153828b89fbe9883b742b813cd151326 /libstdc++-v3/testsuite/28_regex
parent0a134b2aa3328e3707774661c7b727a8270758c3 (diff)
downloadgcc-79b576cc38fbb037993d56b9e5f7e1fca7ee5807.zip
gcc-79b576cc38fbb037993d56b9e5f7e1fca7ee5807.tar.gz
gcc-79b576cc38fbb037993d56b9e5f7e1fca7ee5807.tar.bz2
re PR libstdc++/63775 ([C++11] Regex range with leading dash (-) not working)
PR libstdc++/63775 * include/bits/regex_compiler.h (_Compiler<>::_M_expression_term, _BracketMatcher<>::_M_make_range): Throw regex_erorr on invalid range like [z-a]. Change _M_expression_term interface. * include/bits/regex_compiler.tcc ( _Compiler<>::_M_insert_bracket_matcher, _Compiler<>::_M_expression_term): Rewrite bracket expression parsing. * testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc: Add testcases and move file out of extended. From-SVN: r217461
Diffstat (limited to 'libstdc++-v3/testsuite/28_regex')
-rw-r--r--libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc (renamed from libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/cstring_bracket_01.cc)51
1 files changed, 51 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/cstring_bracket_01.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc
index ca2a5f5..e5cffc7 100644
--- a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/cstring_bracket_01.cc
+++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc
@@ -67,9 +67,60 @@ test01()
}
}
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ try
+ {
+ std::regex re("[-----]", std::regex::extended);
+ VERIFY(false);
+ }
+ catch (const std::regex_error& e)
+ {
+ VERIFY(e.code() == std::regex_constants::error_range);
+ }
+ std::regex re("[-----]", std::regex::ECMAScript);
+}
+
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ try
+ {
+ std::regex re("[z-a]", std::regex::extended);
+ VERIFY(false);
+ }
+ catch (const std::regex_error& e)
+ {
+ VERIFY(e.code() == std::regex_constants::error_range);
+ }
+}
+
+void
+test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re("[-0-9a-z]");
+ VERIFY(regex_match_debug("-", re));
+ VERIFY(regex_match_debug("1", re));
+ VERIFY(regex_match_debug("w", re));
+ re.assign("[-0-9a-z]", regex_constants::basic);
+ VERIFY(regex_match_debug("-", re));
+ VERIFY(regex_match_debug("1", re));
+ VERIFY(regex_match_debug("w", re));
+}
+
int
main()
{
test01();
+ test02();
+ test03();
+ test04();
return 0;
}