summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2015-03-19 17:05:59 +0000
committerMarshall Clow <mclow.lists@gmail.com>2015-03-19 17:05:59 +0000
commit8fa8e5fc74c604092707f35eb50859cdc886ae41 (patch)
treed935c2441da4d3c3b33b63b3c3d610878d9797d1 /libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp
parent9e8a0393183878dcc3e31d8c7905bfd916e7a7fb (diff)
downloadbcm5719-llvm-8fa8e5fc74c604092707f35eb50859cdc886ae41.tar.gz
bcm5719-llvm-8fa8e5fc74c604092707f35eb50859cdc886ae41.zip
Add code to honor the match_not_bol and match_not_eol regex flats. Fixes PR#22651. Thanks to Jim Porter for the report and suggested fix.
llvm-svn: 232733
Diffstat (limited to 'libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp')
-rw-r--r--libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp b/libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp
new file mode 100644
index 00000000000..594c9fb9845
--- /dev/null
+++ b/libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp
@@ -0,0 +1,50 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// match_not_eol:
+// The last character in the sequence [first,last) shall be treated as
+// though it is not at the end of a line, so the character "$" in
+// the regular expression shall not match [last,last).
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::string target = "foo";
+ std::regex re("foo$");
+ assert( std::regex_match(target, re));
+ assert(!std::regex_match(target, re, std::regex_constants::match_not_eol));
+ }
+
+ {
+ std::string target = "foo";
+ std::regex re("foo");
+ assert( std::regex_match(target, re));
+ assert( std::regex_match(target, re, std::regex_constants::match_not_eol));
+ }
+
+ {
+ std::string target = "refoo";
+ std::regex re("foo$");
+ assert( std::regex_search(target, re));
+ assert(!std::regex_search(target, re, std::regex_constants::match_not_eol));
+ }
+
+ {
+ std::string target = "refoo";
+ std::regex re("foo");
+ assert( std::regex_search(target, re));
+ assert( std::regex_search(target, re, std::regex_constants::match_not_eol));
+ }
+}
OpenPOWER on IntegriCloud