aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/28_regex
diff options
context:
space:
mode:
authorTim Shen <timshen91@gmail.com>2013-08-03 14:32:54 +0000
committerTim Shen <timshen@gcc.gnu.org>2013-08-03 14:32:54 +0000
commit399eeef9786cb661aa86981ee9e7a9f3dec373d6 (patch)
treecd6382282eec0df5837cd32d833217284b86cf42 /libstdc++-v3/testsuite/28_regex
parentcdaa808aedfc4b5363197ac119ef976a5d66e5a4 (diff)
downloadgcc-399eeef9786cb661aa86981ee9e7a9f3dec373d6.zip
gcc-399eeef9786cb661aa86981ee9e7a9f3dec373d6.tar.gz
gcc-399eeef9786cb661aa86981ee9e7a9f3dec373d6.tar.bz2
Implement bracket expression.
2013-08-03 Tim Shen <timshen91@gmail.com> Implement bracket expression. * include/bits/regex.h: Remove constexpr from "|=", etc. * include/bits/regex_compiler.h: Parse bracket expression. * include/bits/regex_nfa.h: _Comparator and _BracketMatcher(old _RangeMatcher). * include/bits/regex_nfa.tcc: Implement them. * testsuite/28_regex/algorithms/regex_match/extended/53622.cc: from regex_search to regex_match. * testsuite/28_regex/algorithms/regex_match/extended/ cstring_bracket_01.cc: New. From-SVN: r201465
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;
+}