summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/re/re.regex
diff options
context:
space:
mode:
authorHubert Tong <hubert.reinterpretcast@gmail.com>2016-08-07 22:26:04 +0000
committerHubert Tong <hubert.reinterpretcast@gmail.com>2016-08-07 22:26:04 +0000
commit2fdf202493fcef9a3cf7c1b14843090d9eef2539 (patch)
tree15d8784c2e0a349d797d96d8101077240a904938 /libcxx/test/std/re/re.regex
parentfaf3149df62ab1f98e21526b68686a7c62a11062 (diff)
downloadbcm5719-llvm-2fdf202493fcef9a3cf7c1b14843090d9eef2539.tar.gz
bcm5719-llvm-2fdf202493fcef9a3cf7c1b14843090d9eef2539.zip
[libcxx] Add "flag" default arg: basic_regex ptr_size_flag ctor
Summary: The synopsis in C++11 subclause 28.8 [re.regex] has: ``` basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript); ``` The default argument is added to libc++ by this change. Reviewers: mclow.lists, rsmith, hubert.reinterpretcast Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D22702 Reapplies r277966. Patch by Jason Liu! llvm-svn: 277968
Diffstat (limited to 'libcxx/test/std/re/re.regex')
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/ptr_size.pass.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size.pass.cpp
new file mode 100644
index 00000000000..90a091a21c2
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const charT* p, size_t len);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, std::size_t len, unsigned mc)
+{
+ std::basic_regex<CharT> r(p, len);
+ assert(r.flags() == std::regex_constants::ECMAScript);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test("\\(a\\)", 5, 0);
+ test("\\(a[bc]\\)", 9, 0);
+ test("\\(a\\([bc]\\)\\)", 13, 0);
+ test("(a([bc]))", 9, 2);
+
+ test("(\0)(b)(c)(d)", 12, 4);
+ test("(\0)(b)(c)(d)", 9, 3);
+ test("(\0)(b)(c)(d)", 3, 1);
+ test("(\0)(b)(c)(d)", 0, 0);
+}
OpenPOWER on IntegriCloud