aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/28_regex
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/28_regex')
-rw-r--r--libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/53622.cc4
-rw-r--r--libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/cstring_bracket_01.cc66
2 files changed, 68 insertions, 2 deletions
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/53622.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/53622.cc
index 10e2ff4..aee1dbe 100644
--- a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/53622.cc
+++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/53622.cc
@@ -37,7 +37,7 @@ test01()
std::string target("zxcv/onetwoabc");
std::smatch m;
- VERIFY( std::regex_search(target, m, re) );
+ VERIFY( std::regex_match(target, m, re) );
VERIFY( m.size() == 2 );
VERIFY( m[0].matched == true );
VERIFY( std::string(m[0].first, m[0].second) == "zxcv/onetwoabc" );
@@ -50,7 +50,7 @@ test01()
std::string target("zxcv/onetwoabc");
std::smatch m;
- VERIFY( std::regex_search(target, m, re) );
+ VERIFY( std::regex_match(target, m, re) );
VERIFY( m.size() == 3 );
VERIFY( m[0].matched == true );
VERIFY( std::string(m[0].first, m[0].second) == "zxcv/onetwoabc" );
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/extended/cstring_bracket_01.cc
new file mode 100644
index 0000000..3a4ff31
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/cstring_bracket_01.cc
@@ -0,0 +1,66 @@
+// { dg-options "-std=gnu++11" }
+
+//
+// 2013-08-01 Tim Shen <timshen91@gmail.com>
+//
+// Copyright (C) 2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+// Tests Extended bracket expression against a C-string.
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ {
+ std::regex re("pre/[za-x]", std::regex::extended);
+ VERIFY( std::regex_match("pre/z", re) );
+ VERIFY( std::regex_match("pre/a", re) );
+ VERIFY( !std::regex_match("pre/y", re) );
+ }
+ {
+ std::regex re("pre/[[:uPPer:]]", std::regex::extended);
+ VERIFY( std::regex_match("pre/Z", re) );
+ VERIFY( !std::regex_match("pre/_", re) );
+ VERIFY( !std::regex_match("pre/a", re) );
+ VERIFY( !std::regex_match("pre/0", re) );
+ }
+ {
+ std::regex re("pre/[[:lOWer:]]", std::regex::extended | std::regex::icase);
+ VERIFY( std::regex_match("pre/Z", re) );
+ VERIFY( std::regex_match("pre/a", re) );
+ }
+ {
+ std::regex re("pre/[[:w:][.tilde.]]", std::regex::extended);
+ VERIFY( std::regex_match("pre/~", re) );
+ VERIFY( std::regex_match("pre/_", re) );
+ VERIFY( std::regex_match("pre/a", re) );
+ VERIFY( std::regex_match("pre/0", re) );
+ }
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}