summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/re
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/re')
-rw-r--r--libcxx/test/std/re/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/re/re.alg/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp1389
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.match/basic.fail.cpp38
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp1366
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp1348
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.match/egrep.pass.cpp81
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp1362
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.match/grep.pass.cpp49
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp98
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp72
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.replace/test1.pass.cpp107
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.replace/test2.pass.cpp107
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.replace/test3.pass.cpp73
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.replace/test4.pass.cpp72
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.replace/test5.pass.cpp73
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.replace/test6.pass.cpp73
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.search/awk.pass.cpp1573
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.search/backup.pass.cpp63
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.search/basic.fail.cpp38
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.search/basic.pass.cpp1546
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.search/ecma.pass.cpp1588
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.search/egrep.pass.cpp90
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp1542
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.search/grep.pass.cpp58
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp28
-rw-r--r--libcxx/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp38
-rw-r--r--libcxx/test/std/re/re.alg/re.except/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/re/re.badexp/regex_error.pass.cpp96
-rw-r--r--libcxx/test/std/re/re.const/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/std/re/re.const/re.err/error_type.pass.cpp143
-rw-r--r--libcxx/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp128
-rw-r--r--libcxx/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp114
-rw-r--r--libcxx/test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/std/re/re.def/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/std/re/re.general/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/std/re/re.grammar/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/re/re.iter/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp38
-rw-r--r--libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp44
-rw-r--r--libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp32
-rw-r--r--libcxx/test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp19
-rw-r--r--libcxx/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp42
-rw-r--r--libcxx/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp97
-rw-r--r--libcxx/test/std/re/re.iter/re.regiter/types.pass.cpp45
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp41
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp64
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp32
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp38
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp64
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp37
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp75
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp42
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp128
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp36
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp72
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp135
-rw-r--r--libcxx/test/std/re/re.iter/re.tokiter/types.pass.cpp45
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp33
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.assign/assign.pass.cpp26
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp46
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp29
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp25
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp31
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.assign/copy.pass.cpp26
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.assign/il.pass.cpp27
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp25
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.assign/string.pass.cpp26
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.const/constants.pass.cpp65
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp28
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp45
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp25
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp32
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp70
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp43
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp69
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp34
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp59
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp60
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp35
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp61
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp31
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp29
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp12
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.swap/swap.pass.cpp28
-rw-r--r--libcxx/test/std/re/re.regex/types.pass.cpp35
-rw-r--r--libcxx/test/std/re/re.req/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/std/re/re.results/re.results.acc/begin_end.pass.cpp38
-rw-r--r--libcxx/test/std/re/re.results/re.results.acc/cbegin_cend.pass.cpp38
-rw-r--r--libcxx/test/std/re/re.results/re.results.acc/index.pass.cpp50
-rw-r--r--libcxx/test/std/re/re.results/re.results.acc/length.pass.cpp36
-rw-r--r--libcxx/test/std/re/re.results/re.results.acc/position.pass.cpp36
-rw-r--r--libcxx/test/std/re/re.results/re.results.acc/prefix.pass.cpp34
-rw-r--r--libcxx/test/std/re/re.results/re.results.acc/str.pass.cpp36
-rw-r--r--libcxx/test/std/re/re.results/re.results.acc/suffix.pass.cpp34
-rw-r--r--libcxx/test/std/re/re.results/re.results.all/get_allocator.pass.cpp35
-rw-r--r--libcxx/test/std/re/re.results/re.results.const/allocator.pass.cpp35
-rw-r--r--libcxx/test/std/re/re.results/re.results.const/default.pass.cpp33
-rw-r--r--libcxx/test/std/re/re.results/re.results.form/form1.pass.cpp103
-rw-r--r--libcxx/test/std/re/re.results/re.results.form/form2.pass.cpp102
-rw-r--r--libcxx/test/std/re/re.results/re.results.form/form3.pass.cpp85
-rw-r--r--libcxx/test/std/re/re.results/re.results.form/form4.pass.cpp80
-rw-r--r--libcxx/test/std/re/re.results/re.results.nonmember/equal.pass.cpp46
-rw-r--r--libcxx/test/std/re/re.results/re.results.size/empty.pass.cpp36
-rw-r--r--libcxx/test/std/re/re.results/re.results.size/max_size.pass.cpp31
-rw-r--r--libcxx/test/std/re/re.results/re.results.state/ready.pass.cpp43
-rw-r--r--libcxx/test/std/re/re.results/re.results.swap/member_swap.pass.cpp39
-rw-r--r--libcxx/test/std/re/re.results/re.results.swap/non_member_swap.pass.cpp41
-rw-r--r--libcxx/test/std/re/re.results/types.pass.cpp51
-rw-r--r--libcxx/test/std/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp49
-rw-r--r--libcxx/test/std/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp53
-rw-r--r--libcxx/test/std/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp47
-rw-r--r--libcxx/test/std/re/re.submatch/re.submatch.members/default.pass.cpp33
-rw-r--r--libcxx/test/std/re/re.submatch/re.submatch.members/length.pass.cpp43
-rw-r--r--libcxx/test/std/re/re.submatch/re.submatch.members/operator_string.pass.cpp47
-rw-r--r--libcxx/test/std/re/re.submatch/re.submatch.members/str.pass.cpp47
-rw-r--r--libcxx/test/std/re/re.submatch/re.submatch.op/compare.pass.cpp287
-rw-r--r--libcxx/test/std/re/re.submatch/re.submatch.op/stream.pass.cpp42
-rw-r--r--libcxx/test/std/re/re.submatch/types.pass.cpp64
-rw-r--r--libcxx/test/std/re/re.syn/cmatch.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/cregex_iterator.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/cregex_token_iterator.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/csub_match.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/regex.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/smatch.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/sregex_iterator.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/sregex_token_iterator.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/ssub_match.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/wcmatch.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/wcregex_iterator.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/wcregex_token_iterator.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/wcsub_match.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/wregex.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/wsmatch.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/wsregex_iterator.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/wsregex_token_iterator.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.syn/wssub_match.pass.cpp20
-rw-r--r--libcxx/test/std/re/re.traits/default.pass.cpp37
-rw-r--r--libcxx/test/std/re/re.traits/getloc.pass.cpp36
-rw-r--r--libcxx/test/std/re/re.traits/imbue.pass.cpp30
-rw-r--r--libcxx/test/std/re/re.traits/isctype.pass.cpp279
-rw-r--r--libcxx/test/std/re/re.traits/length.pass.cpp31
-rw-r--r--libcxx/test/std/re/re.traits/lookup_classname.pass.cpp211
-rw-r--r--libcxx/test/std/re/re.traits/lookup_collatename.pass.cpp190
-rw-r--r--libcxx/test/std/re/re.traits/transform.pass.cpp44
-rw-r--r--libcxx/test/std/re/re.traits/transform_primary.pass.cpp49
-rw-r--r--libcxx/test/std/re/re.traits/translate.pass.cpp34
-rw-r--r--libcxx/test/std/re/re.traits/translate_nocase.pass.cpp72
-rw-r--r--libcxx/test/std/re/re.traits/types.pass.cpp32
-rw-r--r--libcxx/test/std/re/re.traits/value.pass.cpp125
157 files changed, 19053 insertions, 0 deletions
diff --git a/libcxx/test/std/re/nothing_to_do.pass.cpp b/libcxx/test/std/re/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/re/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.alg/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.alg/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp
new file mode 100644
index 00000000000..d2065a033d3
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp
@@ -0,0 +1,1389 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator, class Allocator, class charT,
+// class traits>
+// bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags
+// = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+/* {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_match(s, m, std::regex("-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+*/ {
+ std::cmatch m;
+ const char s[] = "m";
+ /* assert(std::regex_match(s, m,*/ std::regex("[a[=M=]z]"/*,
+ std::regex_constants::awk*/);//));
+/* assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+*/ }
+/* {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "\n\n\n";
+ assert(std::regex_match(s, m, std::regex("[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"\n\n\n";
+ assert(std::regex_match(s, m, std::wregex(L"[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+*/}
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/basic.fail.cpp b/libcxx/test/std/re/re.alg/re.alg.match/basic.fail.cpp
new file mode 100644
index 00000000000..d3b922c0782
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.match/basic.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 ST, class SA, class Allocator, class charT, class traits>
+// bool regex_match(const basic_string<charT, ST, SA>&&,
+// match_results<
+// typename basic_string<charT, ST, SA>::const_iterator,
+// Allocator>&,
+// const basic_regex<charT, traits>&,
+// regex_constants::match_flag_type =
+// regex_constants::match_default) = delete;
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::smatch m;
+ std::regex re{"*"};
+ std::regex_match(std::string("abcde"), m, re);
+ }
+}
+#endif
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp
new file mode 100644
index 00000000000..4139cea35f8
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp
@@ -0,0 +1,1366 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ assert(!std::regex_match("a", m, std::regex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbabb";
+ assert(std::regex_match(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbab";
+ assert(!std::regex_match(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(std::regex_match(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "Abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(!std::regex_match(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ assert(!std::regex_match(L"a", m, std::wregex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbabb";
+ assert(std::regex_match(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbab";
+ assert(!std::regex_match(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(std::regex_match(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"Abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(!std::regex_match(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
new file mode 100644
index 00000000000..38540560452
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
@@ -0,0 +1,1348 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("(a*)*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(!std::regex_match(s, m, std::regex("tour|to|tournament")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(!std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_match(s, m, std::regex("-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "foobar";
+ assert(std::regex_match(s, m, std::regex("[^\\0]*")));
+ assert(m.size() == 1);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "foo\0bar";
+ assert(std::regex_match(s, s+7, m, std::regex("[abfor\\0]*")));
+ assert(m.size() == 1);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]+")));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeff Jeffs ";
+ assert(!std::regex_match(s, m, std::regex("Jeff(?=s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeffs Jeff";
+ assert(!std::regex_match(s, m, std::regex("Jeff(?!s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "5%k";
+ assert(std::regex_match(s, m, std::regex("\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"(a*)*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(!std::regex_match(s, m, std::wregex(L"tour|to|tournament")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(!std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+")));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeff Jeffs ";
+ assert(!std::regex_match(s, m, std::wregex(L"Jeff(?=s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeffs Jeff";
+ assert(!std::regex_match(s, m, std::wregex(L"Jeff(?!s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"5%k";
+ assert(std::regex_match(s, m, std::wregex(L"\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/egrep.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/egrep.pass.cpp
new file mode 100644
index 00000000000..dd2e6038dc3
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.match/egrep.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(!std::regex_match(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tourna";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tourna");
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp
new file mode 100644
index 00000000000..c54825de584
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp
@@ -0,0 +1,1362 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_match(s, m, std::regex("-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/grep.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/grep.pass.cpp
new file mode 100644
index 00000000000..2dc0966d6b8
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.match/grep.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(!std::regex_match(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 0);
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp
new file mode 100644
index 00000000000..949739b992c
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// std::regex in ECMAScript mode should not ignore capture groups inside lookahead assertions.
+// For example, matching /(?=(a))(a)/ to "a" should yield two captures: \1 = "a", \2 = "a"
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::regex re("^(?=(.))a$");
+ assert(re.mark_count() == 1);
+
+ std::string s("a");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 2);
+ assert(m[0] == "a");
+ assert(m[1] == "a");
+ }
+
+ {
+ std::regex re("^(a)(?=(.))(b)$");
+ assert(re.mark_count() == 3);
+
+ std::string s("ab");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 4);
+ assert(m[0] == "ab");
+ assert(m[1] == "a");
+ assert(m[2] == "b");
+ assert(m[3] == "b");
+ }
+
+ {
+ std::regex re("^(.)(?=(.)(?=.(.)))(...)$");
+ assert(re.mark_count() == 4);
+
+ std::string s("abcd");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 5);
+ assert(m[0] == "abcd");
+ assert(m[1] == "a");
+ assert(m[2] == "b");
+ assert(m[3] == "d");
+ assert(m[4] == "bcd");
+ }
+
+ {
+ std::regex re("^(a)(?!([^b]))(.c)$");
+ assert(re.mark_count() == 3);
+
+ std::string s("abc");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 4);
+ assert(m[0] == "abc");
+ assert(m[1] == "a");
+ assert(m[2] == "");
+ assert(m[3] == "bc");
+ }
+
+ {
+ std::regex re("^(?!((b)))(?=(.))(?!(abc)).b$");
+ assert(re.mark_count() == 4);
+
+ std::string s("ab");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 5);
+ assert(m[0] == "ab");
+ assert(m[1] == "");
+ assert(m[2] == "");
+ assert(m[3] == "a");
+ assert(m[4] == "");
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp
new file mode 100644
index 00000000000..0b4c6948140
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16135
+
+#include <string>
+#include <regex>
+#include <cassert>
+
+void
+test1()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test2()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re, std::regex::extended);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test3()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re, std::regex::awk);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test4()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re, std::regex::egrep);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+int
+main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.replace/test1.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.replace/test1.pass.cpp
new file mode 100644
index 00000000000..9fd84fdc1f6
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.replace/test1.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 OutputIterator, class BidirectionalIterator,
+// class traits, class charT, class ST, class SA>
+// OutputIterator
+// regex_replace(OutputIterator out,
+// BidirectionalIterator first, BidirectionalIterator last,
+// const basic_regex<charT, traits>& e,
+// const basic_string<charT, ST, SA>& fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"));
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+43);
+ assert(buf == std::string("123-$555-1234, 123-$555-2345, 123-$555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-&"),
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+36);
+ assert(buf == std::string("123-555-1234123-555-2345123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only);
+ assert(r.base() == buf+32);
+ assert(buf == std::string("123-555-1234, 555-2345, 555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+12);
+ assert(buf == std::string("123-555-1234"));
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.replace/test2.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.replace/test2.pass.cpp
new file mode 100644
index 00000000000..63a4ed56933
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.replace/test2.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 OutputIterator, class BidirectionalIterator,
+// class traits, class charT, class ST, class SA>
+// OutputIterator
+// regex_replace(OutputIterator out,
+// BidirectionalIterator first, BidirectionalIterator last,
+// const basic_regex<charT, traits>& e,
+// const charT* fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&");
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+43);
+ assert(buf == std::string("123-$555-1234, 123-$555-2345, 123-$555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-&",
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+36);
+ assert(buf == std::string("123-555-1234123-555-2345123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only);
+ assert(r.base() == buf+32);
+ assert(buf == std::string("123-555-1234, 555-2345, 555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+12);
+ assert(buf == std::string("123-555-1234"));
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.replace/test3.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.replace/test3.pass.cpp
new file mode 100644
index 00000000000..d1167860646
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.replace/test3.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 traits, class charT, class ST, class SA, class FST, class FSA>>
+// basic_string<charT, ST, SA>
+// regex_replace(const basic_string<charT, ST, SA>& s,
+// const basic_regex<charT, traits>& e,
+// const basic_string<charT, FST, FSA>& fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"));
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.replace/test4.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.replace/test4.pass.cpp
new file mode 100644
index 00000000000..fba1bc19546
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.replace/test4.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 traits, class charT, class ST, class SA>
+// basic_string<charT, ST, SA>
+// regex_replace(const basic_string<charT, ST, SA>& s,
+// const basic_regex<charT, traits>& e, const charT* fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&");
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-&",
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.replace/test5.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.replace/test5.pass.cpp
new file mode 100644
index 00000000000..7190e41d522
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.replace/test5.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 traits, class charT, class ST, class SA>
+// basic_string<charT>
+// regex_replace(const charT* s,
+// const basic_regex<charT, traits>& e,
+// const basic_string<charT, ST, SA>& fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"));
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.replace/test6.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.replace/test6.pass.cpp
new file mode 100644
index 00000000000..b0178007730
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.replace/test6.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 traits, class charT>
+// basic_string<charT>
+// regex_replace(const charT* s,
+// const basic_regex<charT, traits>& e,
+// const charT* fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&");
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-&",
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/awk.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/awk.pass.cpp
new file mode 100644
index 00000000000..521e98b3a88
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.search/awk.pass.cpp
@@ -0,0 +1,1573 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_search(s, m, std::regex("-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "\n\n\n";
+ assert(std::regex_search(s, m, std::regex("[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"\n\n\n";
+ assert(std::regex_search(s, m, std::wregex(L"[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/backup.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/backup.pass.cpp
new file mode 100644
index 00000000000..7da58608705
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.search/backup.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <string>
+#include <list>
+#include <cassert>
+
+int main()
+{
+ // This regex_iterator uses regex_search(__wrap_iter<_Iter> __first, ...)
+ // Test for http://llvm.org/bugs/show_bug.cgi?id=16240 fixed in r185273.
+ {
+ std::string s("aaaa a");
+ std::regex re("\\ba");
+ std::sregex_iterator it(s.begin(), s.end(), re);
+ std::sregex_iterator end = std::sregex_iterator();
+
+ assert(it->position(0) == 0);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it->position(0) == 5);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it == end);
+ }
+
+ // This regex_iterator uses regex_search(_BidirectionalIterator __first, ...)
+ {
+ std::string s("aaaa a");
+ std::list<char> l(s.begin(), s.end());
+ std::regex re("\\ba");
+ std::regex_iterator<std::list<char>::iterator> it(l.begin(), l.end(), re);
+ std::regex_iterator<std::list<char>::iterator> end = std::regex_iterator<std::list<char>::iterator>();
+
+ assert(it->position(0) == 0);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it->position(0) == 5);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it == end);
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/basic.fail.cpp b/libcxx/test/std/re/re.alg/re.alg.search/basic.fail.cpp
new file mode 100644
index 00000000000..692ee94d944
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.search/basic.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 ST, class SA, class Allocator, class charT, class traits>
+// bool regex_search(const basic_string<charT, ST, SA>&&,
+// match_results<
+// typename basic_string<charT, ST, SA>::const_iterator,
+// Allocator>&,
+// const basic_regex<charT, traits>&,
+// regex_constants::match_flag_type =
+// regex_constants::match_default) = delete;
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::smatch m;
+ std::regex re{"*"};
+ std::regex_search(std::string("abcde"), m, re);
+ }
+}
+#endif
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/basic.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/basic.pass.cpp
new file mode 100644
index 00000000000..838294e984c
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.search/basic.pass.cpp
@@ -0,0 +1,1546 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ assert(!std::regex_search("a", m, std::regex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbabb";
+ assert(std::regex_search(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbab";
+ assert(!std::regex_search(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(std::regex_search(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "Abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(!std::regex_search(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ assert(!std::regex_search(L"a", m, std::wregex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbabb";
+ assert(std::regex_search(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbab";
+ assert(!std::regex_search(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(std::regex_search(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"Abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(!std::regex_search(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/ecma.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/ecma.pass.cpp
new file mode 100644
index 00000000000..2796850fbd5
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.search/ecma.pass.cpp
@@ -0,0 +1,1588 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("(a*)*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour|to|tournament")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_search(s, m, std::regex("-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]+")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeff Jeffs ";
+ assert(std::regex_search(s, m, std::regex("Jeff(?=s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 5);
+ assert(m.str(0) == "Jeff");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeffs Jeff";
+ assert(std::regex_search(s, m, std::regex("Jeff(?!s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 6);
+ assert(m.str(0) == "Jeff");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "5%k";
+ assert(std::regex_search(s, m, std::regex("\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"(a*)*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeff Jeffs ";
+ assert(std::regex_search(s, m, std::wregex(L"Jeff(?=s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 5);
+ assert(m.str(0) == L"Jeff");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeffs Jeff";
+ assert(std::regex_search(s, m, std::wregex(L"Jeff(?!s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 6);
+ assert(m.str(0) == L"Jeff");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"5%k";
+ assert(std::regex_search(s, m, std::wregex(L"\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/egrep.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/egrep.pass.cpp
new file mode 100644
index 00000000000..1dffed44f22
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.search/egrep.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(std::regex_search(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tourna";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tourna");
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp
new file mode 100644
index 00000000000..a8a121bdd45
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp
@@ -0,0 +1,1542 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_search(s, m, std::regex("-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/grep.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/grep.pass.cpp
new file mode 100644
index 00000000000..113243ecd34
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.search/grep.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(std::regex_search(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp
new file mode 100644
index 00000000000..9f5f9540165
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// http://llvm.org/bugs/show_bug.cgi?id=11118
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(!std::regex_search("ab", std::regex("(?=^)b")));
+ assert(!std::regex_search("ab", std::regex("a(?=^)b")));
+}
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp
new file mode 100644
index 00000000000..ef9cec5f736
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ // Iterating over /^a/ should yield one instance at the beginning
+ // of the text.
+
+ const char *text = "aaa\naa";
+ std::regex re("^a");
+ std::cregex_iterator it(text, text+6, re);
+ std::cregex_iterator end = std::cregex_iterator();
+
+ assert(it->str() == "a");
+ assert(it->position(0) == 0);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it == end);
+}
diff --git a/libcxx/test/std/re/re.alg/re.except/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.alg/re.except/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/re/re.alg/re.except/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.badexp/regex_error.pass.cpp b/libcxx/test/std/re/re.badexp/regex_error.pass.cpp
new file mode 100644
index 00000000000..02fecbda2d9
--- /dev/null
+++ b/libcxx/test/std/re/re.badexp/regex_error.pass.cpp
@@ -0,0 +1,96 @@
+// -*- 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>
+
+// class regex_error
+// : public runtime_error
+// {
+// public:
+// explicit regex_error(regex_constants::error_type ecode);
+// regex_constants::error_type code() const;
+// };
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex_error e(std::regex_constants::error_collate);
+ assert(e.code() == std::regex_constants::error_collate);
+ assert(e.what() == std::string("The expression contained an invalid collating element name."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_ctype);
+ assert(e.code() == std::regex_constants::error_ctype);
+ assert(e.what() == std::string("The expression contained an invalid character class name."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_escape);
+ assert(e.code() == std::regex_constants::error_escape);
+ assert(e.what() == std::string("The expression contained an invalid escaped character, or a "
+ "trailing escape."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_backref);
+ assert(e.code() == std::regex_constants::error_backref);
+ assert(e.what() == std::string("The expression contained an invalid back reference."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_brack);
+ assert(e.code() == std::regex_constants::error_brack);
+ assert(e.what() == std::string("The expression contained mismatched [ and ]."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_paren);
+ assert(e.code() == std::regex_constants::error_paren);
+ assert(e.what() == std::string("The expression contained mismatched ( and )."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_brace);
+ assert(e.code() == std::regex_constants::error_brace);
+ assert(e.what() == std::string("The expression contained mismatched { and }."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_badbrace);
+ assert(e.code() == std::regex_constants::error_badbrace);
+ assert(e.what() == std::string("The expression contained an invalid range in a {} expression."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_range);
+ assert(e.code() == std::regex_constants::error_range);
+ assert(e.what() == std::string("The expression contained an invalid character range, "
+ "such as [b-a] in most encodings."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_space);
+ assert(e.code() == std::regex_constants::error_space);
+ assert(e.what() == std::string("There was insufficient memory to convert the expression into "
+ "a finite state machine."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_badrepeat);
+ assert(e.code() == std::regex_constants::error_badrepeat);
+ assert(e.what() == std::string("One of *?+{ was not preceded by a valid regular expression."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_complexity);
+ assert(e.code() == std::regex_constants::error_complexity);
+ assert(e.what() == std::string("The complexity of an attempted match against a regular "
+ "expression exceeded a pre-set level."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_stack);
+ assert(e.code() == std::regex_constants::error_stack);
+ assert(e.what() == std::string("There was insufficient memory to determine whether the regular "
+ "expression could match the specified character sequence."));
+ }
+}
diff --git a/libcxx/test/std/re/re.const/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.const/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/std/re/re.const/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.const/re.err/error_type.pass.cpp b/libcxx/test/std/re/re.const/re.err/error_type.pass.cpp
new file mode 100644
index 00000000000..150855beb0a
--- /dev/null
+++ b/libcxx/test/std/re/re.const/re.err/error_type.pass.cpp
@@ -0,0 +1,143 @@
+// -*- 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>
+
+// namespace regex_constants
+// {
+//
+// enum error_type
+// {
+// error_collate = unspecified,
+// error_ctype = unspecified,
+// error_escape = unspecified,
+// error_backref = unspecified,
+// error_brack = unspecified,
+// error_paren = unspecified,
+// error_brace = unspecified,
+// error_badbrace = unspecified,
+// error_range = unspecified,
+// error_space = unspecified,
+// error_badrepeat = unspecified,
+// error_complexity = unspecified,
+// error_stack = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(std::regex_constants::error_collate != 0);
+ assert(std::regex_constants::error_ctype != 0);
+ assert(std::regex_constants::error_escape != 0);
+ assert(std::regex_constants::error_backref != 0);
+ assert(std::regex_constants::error_brack != 0);
+ assert(std::regex_constants::error_paren != 0);
+ assert(std::regex_constants::error_brace != 0);
+ assert(std::regex_constants::error_badbrace != 0);
+ assert(std::regex_constants::error_range != 0);
+ assert(std::regex_constants::error_space != 0);
+ assert(std::regex_constants::error_badrepeat != 0);
+ assert(std::regex_constants::error_complexity != 0);
+ assert(std::regex_constants::error_stack != 0);
+
+ assert(std::regex_constants::error_collate != std::regex_constants::error_ctype);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_escape);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_backref);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_range);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_space);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_escape);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_backref);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_range);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_space);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_escape != std::regex_constants::error_backref);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_range);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_space);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_backref != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_range);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_space);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_brack != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_range);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_space);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_paren != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_range);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_space);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_brace != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_range);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_space);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_range);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_space);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_range != std::regex_constants::error_space);
+ assert(std::regex_constants::error_range != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_range != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_range != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_space != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_space != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_space != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_badrepeat != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_badrepeat != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_complexity != std::regex_constants::error_stack);
+}
diff --git a/libcxx/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp b/libcxx/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp
new file mode 100644
index 00000000000..b48703c7579
--- /dev/null
+++ b/libcxx/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp
@@ -0,0 +1,128 @@
+// -*- 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>
+
+// namespace regex_constants
+// {
+//
+// emum match_flag_type // bitmask type
+// {
+// match_default = 0,
+// match_not_bol = unspecified,
+// match_not_eol = unspecified,
+// match_not_bow = unspecified,
+// match_not_eow = unspecified,
+// match_any = unspecified,
+// match_not_null = unspecified,
+// match_continuous = unspecified,
+// match_prev_avail = unspecified,
+// format_default = 0,
+// format_sed = unspecified,
+// format_no_copy = unspecified,
+// format_first_only = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(std::regex_constants::match_default == 0);
+ assert(std::regex_constants::match_not_bol != 0);
+ assert(std::regex_constants::match_not_eol != 0);
+ assert(std::regex_constants::match_not_bow != 0);
+ assert(std::regex_constants::match_not_eow != 0);
+ assert(std::regex_constants::match_any != 0);
+ assert(std::regex_constants::match_not_null != 0);
+ assert(std::regex_constants::match_continuous != 0);
+ assert(std::regex_constants::match_prev_avail != 0);
+ assert(std::regex_constants::format_default == 0);
+ assert(std::regex_constants::format_sed != 0);
+ assert(std::regex_constants::format_no_copy != 0);
+ assert(std::regex_constants::format_first_only != 0);
+
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_eol) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_bow) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_eow) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_bow) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_eow) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_not_eow) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_any & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_null & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_continuous & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_continuous & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_continuous & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_continuous & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_prev_avail & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_prev_avail & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_prev_avail & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::format_sed & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::format_sed & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::format_no_copy & std::regex_constants::format_first_only) == 0);
+
+ std::regex_constants::match_flag_type e1 = std::regex_constants::match_not_bol;
+ std::regex_constants::match_flag_type e2 = std::regex_constants::match_not_eol;
+ e1 = ~e1;
+ e1 = e1 & e2;
+ e1 = e1 | e2;
+ e1 = e1 ^ e2;
+ e1 &= e2;
+ e1 |= e2;
+ e1 ^= e2;
+}
diff --git a/libcxx/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp b/libcxx/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp
new file mode 100644
index 00000000000..1c4f824448a
--- /dev/null
+++ b/libcxx/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp
@@ -0,0 +1,114 @@
+// -*- 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>
+
+// namespace regex_constants
+// {
+//
+// emum syntax_option_type // bitmask type
+// {
+// icase = unspecified,
+// nosubs = unspecified,
+// optimize = unspecified,
+// collate = unspecified,
+// ECMAScript = unspecified,
+// basic = unspecified,
+// extended = unspecified,
+// awk = unspecified,
+// grep = unspecified,
+// egrep = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(std::regex_constants::icase != 0);
+ assert(std::regex_constants::nosubs != 0);
+ assert(std::regex_constants::optimize != 0);
+ assert(std::regex_constants::collate != 0);
+ assert(std::regex_constants::ECMAScript == 0);
+ assert(std::regex_constants::basic != 0);
+ assert(std::regex_constants::extended != 0);
+ assert(std::regex_constants::awk != 0);
+ assert(std::regex_constants::grep != 0);
+ assert(std::regex_constants::egrep != 0);
+
+ assert((std::regex_constants::icase & std::regex_constants::nosubs) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::optimize) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::collate) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::nosubs & std::regex_constants::optimize) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::collate) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::optimize & std::regex_constants::collate) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::collate & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::ECMAScript & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::basic & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::basic & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::basic & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::basic & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::extended & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::extended & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::extended & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::awk & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::awk & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::grep & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::icase | std::regex_constants::nosubs) != 0);
+ assert((std::regex_constants::icase ^ std::regex_constants::nosubs) != 0);
+
+ std::regex_constants::syntax_option_type e1 = std::regex_constants::icase;
+ std::regex_constants::syntax_option_type e2 = std::regex_constants::nosubs;
+ e1 = ~e1;
+ e1 = e1 & e2;
+ e1 = e1 | e2;
+ e1 = e1 ^ e2;
+ e1 &= e2;
+ e1 |= e2;
+ e1 ^= e2;
+}
diff --git a/libcxx/test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.def/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.def/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/std/re/re.def/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.general/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.general/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/std/re/re.general/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.grammar/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.grammar/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/re/re.grammar/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.iter/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.iter/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp
new file mode 100644
index 00000000000..9c17287cdb8
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// int submatch = 0,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default) = delete;
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(
+ std::begin(phone_book), std::end(phone_book),
+ std::regex("\\d{3}-\\d{4}"));
+ }
+}
+#endif
diff --git a/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp
new file mode 100644
index 00000000000..c9fc7a3cd1c
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// regex_constants::match_flag_type m = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 0);
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 10);
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 20);
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_iterator());
+ }
+}
diff --git a/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp
new file mode 100644
index 00000000000..9d4766dc876
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_iterator<const CharT*> I;
+ I i1;
+ assert(i1 == I());
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/libcxx/test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp
new file mode 100644
index 00000000000..16d1fa9904b
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// bool operator==(const regex_iterator& right) const;
+// bool operator!=(const regex_iterator& right) const;
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp
new file mode 100644
index 00000000000..e4933fe16f8
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// const value_type& operator*() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 0);
+ assert((*i).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 10);
+ assert((*i).str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 20);
+ assert((*i).str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_iterator());
+ }
+}
diff --git a/libcxx/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
new file mode 100644
index 00000000000..3ec0d6c0c3b
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator operator++(int);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ std::cregex_iterator i2 = i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 0);
+ assert((*i).str() == "555-1234");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ i++;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 10);
+ assert((*i).str() == "555-2345");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ i++;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 20);
+ assert((*i).str() == "555-3456");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ i++;
+ assert(i == std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ std::cregex_iterator i2 = i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 0);
+ assert((*i).str() == "555-1234");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 10);
+ assert((*i).str() == "555-2345");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 20);
+ assert((*i).str() == "555-3456");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ ++i;
+ assert(i == std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ }
+}
diff --git a/libcxx/test/std/re/re.iter/re.regiter/types.pass.cpp b/libcxx/test/std/re/re.iter/re.regiter/types.pass.cpp
new file mode 100644
index 00000000000..db1d3eb958b
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.regiter/types.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator,
+// class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+// class traits = regex_traits<charT>>
+// class regex_iterator
+// {
+// public:
+// typedef basic_regex<charT, traits> regex_type;
+// typedef match_results<BidirectionalIterator> value_type;
+// typedef ptrdiff_t difference_type;
+// typedef const value_type* pointer;
+// typedef const value_type& reference;
+// typedef forward_iterator_tag iterator_category;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_iterator<const CharT*> I;
+ static_assert((std::is_same<typename I::regex_type, std::basic_regex<CharT> >::value), "");
+ static_assert((std::is_same<typename I::value_type, std::match_results<const CharT*> >::value), "");
+ static_assert((std::is_same<typename I::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<typename I::pointer, const std::match_results<const CharT*>*>::value), "");
+ static_assert((std::is_same<typename I::reference, const std::match_results<const CharT*>&>::value), "");
+ static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp
new file mode 100644
index 00000000000..ed3c9feaa34
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// template <size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// const int (&submatches)[N],
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ const int indices[] = {-1, 0, 1};
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), indices);
+ }
+}
+#endif
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp
new file mode 100644
index 00000000000..a51b8274bdd
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// template <size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// const int (&submatches)[N],
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ const int indices[] = {-1, 0, 1};
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, indices);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp
new file mode 100644
index 00000000000..382815e0c1c
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_token_iterator<const CharT*> I;
+ I i1;
+ assert(i1 == I());
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp
new file mode 100644
index 00000000000..13120f36e40
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// initializer_list<int> submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), {-1, 0, 1});
+ }
+}
+#endif
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp
new file mode 100644
index 00000000000..b40d7eb9224
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// initializer_list<int> submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, {-1, 0, 1});
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
new file mode 100644
index 00000000000..dba11c27536
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re, int submatch = 0,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), -1);
+ }
+}
+#endif
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp
new file mode 100644
index 00000000000..d8111363c17
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re, int submatch = 0,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, 1);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp
new file mode 100644
index 00000000000..fd75a8b6854
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// template <std::size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// const std::vector<int>& submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(-1);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), v);
+ }
+}
+#endif
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp
new file mode 100644
index 00000000000..b04f5804509
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// const std::vector<int>& submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(-1);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, v);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(0);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, v);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(0);
+ v.push_back(1);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, v);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp
new file mode 100644
index 00000000000..d6399f1148b
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// bool operator==(const regex_token_iterator& right) const;
+// bool operator!=(const regex_token_iterator& right) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ assert(i != std::cregex_token_iterator());
+ assert(!(i == std::cregex_token_iterator()));
+ std::cregex_token_iterator i2 = i;
+ assert(i2 == i);
+ assert(!(i2 != i));
+ ++i;
+ assert(!(i2 == i));
+ assert(i2 != i);
+ }
+}
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp
new file mode 100644
index 00000000000..b096e3c0827
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// const value_type& operator*() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers);
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, 1);
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp
new file mode 100644
index 00000000000..727ab7af937
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp
@@ -0,0 +1,135 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator& operator++(int);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ std::cregex_token_iterator i2 = i;
+ std::cregex_token_iterator i3;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ assert(i2->str() == "start ");
+ i3 = i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == "start ");
+ i3 = i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i++;
+ assert(i == std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i2->str() == "start ");
+ assert(i3->str() == " end");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ std::cregex_token_iterator i2 = i;
+ std::cregex_token_iterator i3;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ assert(i2->str() == "start ");
+ i3 = i;
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == "start ");
+ i3 = i;
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i;
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i;
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i2->str() == "start ");
+ assert(i3->str() == " end");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ i++;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, 1);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ i++;
+ assert(i == std::cregex_token_iterator());
+ }
+}
diff --git a/libcxx/test/std/re/re.iter/re.tokiter/types.pass.cpp b/libcxx/test/std/re/re.iter/re.tokiter/types.pass.cpp
new file mode 100644
index 00000000000..89287bdd1d0
--- /dev/null
+++ b/libcxx/test/std/re/re.iter/re.tokiter/types.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator,
+// class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+// class traits = regex_traits<charT>>
+// class regex_token_iterator
+// {
+// public:
+// typedef basic_regex<charT, traits> regex_type;
+// typedef sub_match<BidirectionalIterator> value_type;
+// typedef ptrdiff_t difference_type;
+// typedef const value_type* pointer;
+// typedef const value_type& reference;
+// typedef forward_iterator_tag iterator_category;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_token_iterator<const CharT*> I;
+ static_assert((std::is_same<typename I::regex_type, std::basic_regex<CharT> >::value), "");
+ static_assert((std::is_same<typename I::value_type, std::sub_match<const CharT*> >::value), "");
+ static_assert((std::is_same<typename I::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<typename I::pointer, const std::sub_match<const CharT*>*>::value), "");
+ static_assert((std::is_same<typename I::reference, const std::sub_match<const CharT*>&>::value), "");
+ static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp
new file mode 100644
index 00000000000..96cadf16600
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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&
+// assign(initializer_list<charT> il,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::regex r2;
+ r2.assign({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'});
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.assign/assign.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.assign/assign.pass.cpp
new file mode 100644
index 00000000000..1bd0022edbc
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.assign/assign.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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& assign(const basic_regex& that);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2;
+ r2.assign(r1);
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp
new file mode 100644
index 00000000000..529a64a239a
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// template <class InputIterator>
+// basic_regex&
+// assign(InputIterator first, InputIterator last,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ typedef input_iterator<std::string::const_iterator> I;
+ typedef forward_iterator<std::string::const_iterator> F;
+ std::string s4("(a([bc]))");
+ std::regex r2;
+
+ r2.assign(I(s4.begin()), I(s4.end()));
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(I(s4.begin()), I(s4.end()), std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(F(s4.begin()), F(s4.end()));
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(F(s4.begin()), F(s4.end()), std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp
new file mode 100644
index 00000000000..dd39dee13ff
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2.assign("(a([bc]))");
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign("(a([bc]))", std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp
new file mode 100644
index 00000000000..679cd9df17f
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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& assign(const charT* ptr, size_t len, flag_type f);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2.assign("(a([bc]))", 9, std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp
new file mode 100644
index 00000000000..46f984da04d
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// template <class string_traits, class A>
+// basic_regex& assign(const basic_string<charT, string_traits, A>& s,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2.assign(std::string("(a([bc]))"));
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(std::string("(a([bc]))"), std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.assign/copy.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.assign/copy.pass.cpp
new file mode 100644
index 00000000000..2a616ff012c
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.assign/copy.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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& operator=(const basic_regex& e);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2;
+ r2 = r1;
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.assign/il.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.assign/il.pass.cpp
new file mode 100644
index 00000000000..a9d8ada4ff0
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.assign/il.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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& operator=(initializer_list<charT> il);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::regex r2;
+ r2 = {'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'};
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp
new file mode 100644
index 00000000000..4c42f822a1e
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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& operator=(const charT* ptr);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2 = "(a([bc]))";
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.assign/string.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.assign/string.pass.cpp
new file mode 100644
index 00000000000..7f09e5364ac
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.assign/string.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// template <class ST, class SA>
+// basic_regex& operator=(const basic_string<charT, ST, SA>& p);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2 = std::string("(a([bc]))");
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.const/constants.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.const/constants.pass.cpp
new file mode 100644
index 00000000000..85297b91f43
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.const/constants.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+// {
+// public:
+// // constants:
+// static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
+// static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
+// static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
+// static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
+// static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
+// static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
+// static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
+// static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
+// static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
+// static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
+
+#include <regex>
+#include <type_traits>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+template <class CharT>
+void
+test()
+{
+ typedef std::basic_regex<CharT> BR;
+ static_assert((BR::icase == std::regex_constants::icase), "");
+ static_assert((BR::nosubs == std::regex_constants::nosubs), "");
+ static_assert((BR::optimize == std::regex_constants::optimize), "");
+ static_assert((BR::collate == std::regex_constants::collate), "");
+ static_assert((BR::ECMAScript == std::regex_constants::ECMAScript), "");
+ static_assert((BR::basic == std::regex_constants::basic), "");
+ static_assert((BR::extended == std::regex_constants::extended), "");
+ static_assert((BR::awk == std::regex_constants::awk), "");
+ static_assert((BR::grep == std::regex_constants::grep), "");
+ static_assert((BR::egrep == std::regex_constants::egrep), "");
+ where(BR::icase);
+ where(BR::nosubs);
+ where(BR::optimize);
+ where(BR::collate);
+ where(BR::ECMAScript);
+ where(BR::basic);
+ where(BR::extended);
+ where(BR::awk);
+ where(BR::grep);
+ where(BR::egrep);
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp
new file mode 100644
index 00000000000..4b7e5e62929
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ using std::regex_constants::awk;
+
+ assert(std::regex_match("\4", std::regex("\\4", awk)));
+ assert(std::regex_match("\41", std::regex("\\41", awk)));
+ assert(std::regex_match("\141", std::regex("\\141", awk)));
+ assert(std::regex_match("\1411", std::regex("\\1411", awk)));
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
new file mode 100644
index 00000000000..9455527412b
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+static bool error_escape_thrown(const char *pat)
+{
+ bool result = false;
+ try {
+ std::regex re(pat);
+ } catch (std::regex_error &ex) {
+ result = (ex.code() == std::regex_constants::error_escape);
+ }
+ return result;
+}
+
+int main()
+{
+ assert(error_escape_thrown("[\\a]"));
+ assert(error_escape_thrown("\\a"));
+
+ assert(error_escape_thrown("[\\e]"));
+ assert(error_escape_thrown("\\e"));
+
+ assert(error_escape_thrown("[\\c:]"));
+ assert(error_escape_thrown("\\c:"));
+ assert(error_escape_thrown("\\c"));
+ assert(!error_escape_thrown("[\\cA]"));
+ assert(!error_escape_thrown("\\cA"));
+
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp
new file mode 100644
index 00000000000..c2788f0fa2c
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 basic_regex& e);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2 = r1;
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp
new file mode 100644
index 00000000000..d959c1ec582
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ std::basic_regex<CharT> r;
+ assert(r.flags() == 0);
+ assert(r.mark_count() == 0);
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
new file mode 100644
index 00000000000..70d28df370d
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// 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(initializer_list<charT> il,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+void
+test(std::initializer_list<char> il, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<char> r(il, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::string s1("\\(a\\)");
+ std::string s2("\\(a[bc]\\)");
+ std::string s3("\\(a\\([bc]\\)\\)");
+ std::string s4("(a([bc]))");
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::basic, 1);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::basic, 1);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::basic, 2);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::basic, 0);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::extended, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::extended, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::extended, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::extended, 2);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::ECMAScript, 2);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::awk, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::awk, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::awk, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::awk, 2);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::grep, 1);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::grep, 1);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::grep, 2);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::grep, 0);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::egrep, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::egrep, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::egrep, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::egrep, 2);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp
new file mode 100644
index 00000000000..a38e1623419
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// template <class ForwardIterator>
+// basic_regex(ForwardIterator first, ForwardIterator last);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last, unsigned mc)
+{
+ std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last);
+ assert(r.flags() == std::regex_constants::ECMAScript);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ typedef forward_iterator<std::string::const_iterator> F;
+ std::string s1("\\(a\\)");
+ std::string s2("\\(a[bc]\\)");
+ std::string s3("\\(a\\([bc]\\)\\)");
+ std::string s4("(a([bc]))");
+
+ test(F(s1.begin()), F(s1.end()), 0);
+ test(F(s2.begin()), F(s2.end()), 0);
+ test(F(s3.begin()), F(s3.end()), 0);
+ test(F(s4.begin()), F(s4.end()), 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
new file mode 100644
index 00000000000..c4c440e6d24
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// template <class ForwardIterator>
+// basic_regex(ForwardIterator first, ForwardIterator last,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ typedef forward_iterator<std::string::const_iterator> F;
+ std::string s1("\\(a\\)");
+ std::string s2("\\(a[bc]\\)");
+ std::string s3("\\(a\\([bc]\\)\\)");
+ std::string s4("(a([bc]))");
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::basic, 1);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::basic, 1);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::basic, 2);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::basic, 0);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::extended, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::extended, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::extended, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::extended, 2);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::ECMAScript, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::ECMAScript, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::ECMAScript, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::ECMAScript, 2);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::awk, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::awk, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::awk, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::awk, 2);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::grep, 1);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::grep, 1);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::grep, 2);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::grep, 0);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::egrep, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::egrep, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::egrep, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::egrep, 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp
new file mode 100644
index 00000000000..b99b58b469c
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, unsigned mc)
+{
+ std::basic_regex<CharT> r(p);
+ assert(r.flags() == std::regex_constants::ECMAScript);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test("\\(a\\)", 0);
+ test("\\(a[bc]\\)", 0);
+ test("\\(a\\([bc]\\)\\)", 0);
+ test("(a([bc]))", 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
new file mode 100644
index 00000000000..138e20efbf6
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// 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, flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<CharT> r(p, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test("\\(a\\)", std::regex_constants::basic, 1);
+ test("\\(a[bc]\\)", std::regex_constants::basic, 1);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::basic, 2);
+ test("(a([bc]))", std::regex_constants::basic, 0);
+
+ test("\\(a\\)", std::regex_constants::extended, 0);
+ test("\\(a[bc]\\)", std::regex_constants::extended, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::extended, 0);
+ test("(a([bc]))", std::regex_constants::extended, 2);
+
+ test("\\(a\\)", std::regex_constants::ECMAScript, 0);
+ test("\\(a[bc]\\)", std::regex_constants::ECMAScript, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::ECMAScript, 0);
+ test("(a([bc]))", std::regex_constants::ECMAScript, 2);
+
+ test("\\(a\\)", std::regex_constants::awk, 0);
+ test("\\(a[bc]\\)", std::regex_constants::awk, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::awk, 0);
+ test("(a([bc]))", std::regex_constants::awk, 2);
+
+ test("\\(a\\)", std::regex_constants::grep, 1);
+ test("\\(a[bc]\\)", std::regex_constants::grep, 1);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::grep, 2);
+ test("(a([bc]))", std::regex_constants::grep, 0);
+
+ test("\\(a\\)", std::regex_constants::egrep, 0);
+ test("\\(a[bc]\\)", std::regex_constants::egrep, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::egrep, 0);
+ test("(a([bc]))", std::regex_constants::egrep, 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
new file mode 100644
index 00000000000..d623a15936f
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// 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, flag_type f);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, std::size_t len, std::regex_constants::syntax_option_type f,
+ unsigned mc)
+{
+ std::basic_regex<CharT> r(p, len, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test("\\(a\\)", 5, std::regex_constants::basic, 1);
+ test("\\(a[bc]\\)", 9, std::regex_constants::basic, 1);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::basic, 2);
+ test("(a([bc]))", 9, std::regex_constants::basic, 0);
+
+ test("\\(a\\)", 5, std::regex_constants::extended, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::extended, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::extended, 0);
+ test("(a([bc]))", 9, std::regex_constants::extended, 2);
+
+ test("\\(a\\)", 5, std::regex_constants::ECMAScript, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::ECMAScript, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::ECMAScript, 0);
+ test("(a([bc]))", 9, std::regex_constants::ECMAScript, 2);
+
+ test("\\(a\\)", 5, std::regex_constants::awk, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::awk, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::awk, 0);
+ test("(a([bc]))", 9, std::regex_constants::awk, 2);
+
+ test("\\(a\\)", 5, std::regex_constants::grep, 1);
+ test("\\(a[bc]\\)", 9, std::regex_constants::grep, 1);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::grep, 2);
+ test("(a([bc]))", 9, std::regex_constants::grep, 0);
+
+ test("\\(a\\)", 5, std::regex_constants::egrep, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::egrep, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::egrep, 0);
+ test("(a([bc]))", 9, std::regex_constants::egrep, 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp
new file mode 100644
index 00000000000..b58b8e03cd2
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+template <class String>
+void
+test(const String& p, unsigned mc)
+{
+ std::basic_regex<typename String::value_type> r(p);
+ assert(r.flags() == std::regex_constants::ECMAScript);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test(std::string("\\(a\\)"), 0);
+ test(std::string("\\(a[bc]\\)"), 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), 0);
+ test(std::string("(a([bc]))"), 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp
new file mode 100644
index 00000000000..768de568e22
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+template <class String>
+void
+test(const String& p, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<typename String::value_type> r(p, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test(std::string("\\(a\\)"), std::regex_constants::basic, 1);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::basic, 1);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::basic, 2);
+ test(std::string("(a([bc]))"), std::regex_constants::basic, 0);
+
+ test(std::string("\\(a\\)"), std::regex_constants::extended, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::extended, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::extended, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::extended, 2);
+
+ test(std::string("\\(a\\)"), std::regex_constants::ECMAScript, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::ECMAScript, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::ECMAScript, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::ECMAScript, 2);
+
+ test(std::string("\\(a\\)"), std::regex_constants::awk, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::awk, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::awk, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::awk, 2);
+
+ test(std::string("\\(a\\)"), std::regex_constants::grep, 1);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::grep, 1);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::grep, 2);
+ test(std::string("(a([bc]))"), std::regex_constants::grep, 0);
+
+ test(std::string("\\(a\\)"), std::regex_constants::egrep, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::egrep, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::egrep, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::egrep, 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp
new file mode 100644
index 00000000000..be0b26dc5c2
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// locale_type imbue(locale_type loc);
+
+#include <regex>
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ std::regex r;
+ std::locale loc = r.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(loc.name() == "C");
+ assert(r.getloc().name() == LOCALE_en_US_UTF_8);
+ loc = r.imbue(std::locale("C"));
+ assert(loc.name() == LOCALE_en_US_UTF_8);
+ assert(r.getloc().name() == "C");
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp
new file mode 100644
index 00000000000..9d3c481686e
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// template <class charT, class traits>
+// void swap(basic_regex<charT, traits>& lhs, basic_regex<charT, traits>& rhs);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2;
+ swap(r2, r1);
+ assert(r1.flags() == std::regex::ECMAScript);
+ assert(r1.mark_count() == 0);
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.regex/re.regex.swap/swap.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.swap/swap.pass.cpp
new file mode 100644
index 00000000000..cda8ef3541a
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/re.regex.swap/swap.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// void swap(basic_regex& e);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2;
+ r2.swap(r1);
+ assert(r1.flags() == std::regex::ECMAScript);
+ assert(r1.mark_count() == 0);
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/libcxx/test/std/re/re.regex/types.pass.cpp b/libcxx/test/std/re/re.regex/types.pass.cpp
new file mode 100644
index 00000000000..02011ac56eb
--- /dev/null
+++ b/libcxx/test/std/re/re.regex/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+// {
+// public:
+// // types:
+// typedef charT value_type;
+// typedef regex_constants::syntax_option_type flag_type;
+// typedef typename traits::locale_type locale_type;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::basic_regex<char>::value_type, char>::value), "");
+ static_assert((std::is_same<std::basic_regex<char>::flag_type,
+ std::regex_constants::syntax_option_type>::value), "");
+ static_assert((std::is_same<std::basic_regex<char>::locale_type, std::locale>::value), "");
+
+ static_assert((std::is_same<std::basic_regex<wchar_t>::value_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::basic_regex<wchar_t>::flag_type,
+ std::regex_constants::syntax_option_type>::value), "");
+ static_assert((std::is_same<std::basic_regex<wchar_t>::locale_type, std::locale>::value), "");
+}
diff --git a/libcxx/test/std/re/re.req/nothing_to_do.pass.cpp b/libcxx/test/std/re/re.req/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/std/re/re.req/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/re/re.results/re.results.acc/begin_end.pass.cpp b/libcxx/test/std/re/re.results/re.results.acc/begin_end.pass.cpp
new file mode 100644
index 00000000000..80c06f299bd
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.acc/begin_end.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_iterator begin() const;
+// const_iterator end() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ std::match_results<const char*>::const_iterator i = m.begin();
+ std::match_results<const char*>::const_iterator e = m.end();
+
+ assert(e - i == m.size());
+ for (int j = 0; i != e; ++i, ++j)
+ assert(*i == m[j]);
+}
+
+int main()
+{
+ test();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.acc/cbegin_cend.pass.cpp b/libcxx/test/std/re/re.results/re.results.acc/cbegin_cend.pass.cpp
new file mode 100644
index 00000000000..a983c8afc81
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.acc/cbegin_cend.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ std::match_results<const char*>::const_iterator i = m.cbegin();
+ std::match_results<const char*>::const_iterator e = m.cend();
+
+ assert(e - i == m.size());
+ for (int j = 0; i != e; ++i, ++j)
+ assert(*i == m[j]);
+}
+
+int main()
+{
+ test();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.acc/index.pass.cpp b/libcxx/test/std/re/re.results/re.results.acc/index.pass.cpp
new file mode 100644
index 00000000000..b798969c288
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.acc/index.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_reference operator[](size_type n) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ assert(m[0].first == s+2);
+ assert(m[0].second == s+9);
+ assert(m[0].matched == true);
+
+ assert(m[1].first == s+4);
+ assert(m[1].second == s+7);
+ assert(m[1].matched == true);
+
+ assert(m[2].first == s+4);
+ assert(m[2].second == s+5);
+ assert(m[2].matched == true);
+
+ assert(m[3].first == s+11);
+ assert(m[3].second == s+11);
+ assert(m[3].matched == false);
+
+ assert(m[4].first == s+11);
+ assert(m[4].second == s+11);
+ assert(m[4].matched == false);
+}
+
+int main()
+{
+ test();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.acc/length.pass.cpp b/libcxx/test/std/re/re.results/re.results.acc/length.pass.cpp
new file mode 100644
index 00000000000..91020851a30
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.acc/length.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// difference_type length(size_type sub = 0) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.length() == m[0].length());
+ assert(m.length(0) == m[0].length());
+ assert(m.length(1) == m[1].length());
+ assert(m.length(2) == m[2].length());
+ assert(m.length(3) == m[3].length());
+ assert(m.length(4) == m[4].length());
+}
+
+int main()
+{
+ test();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.acc/position.pass.cpp b/libcxx/test/std/re/re.results/re.results.acc/position.pass.cpp
new file mode 100644
index 00000000000..2698e2d9169
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.acc/position.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// difference_type position(size_type sub = 0) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.position() == std::distance(s, m[0].first));
+ assert(m.position(0) == std::distance(s, m[0].first));
+ assert(m.position(1) == std::distance(s, m[1].first));
+ assert(m.position(2) == std::distance(s, m[2].first));
+ assert(m.position(3) == std::distance(s, m[3].first));
+ assert(m.position(4) == std::distance(s, m[4].first));
+}
+
+int main()
+{
+ test();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.acc/prefix.pass.cpp b/libcxx/test/std/re/re.results/re.results.acc/prefix.pass.cpp
new file mode 100644
index 00000000000..58cdabc24df
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.acc/prefix.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_reference prefix() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == s+2);
+ assert(m.prefix().matched == true);
+}
+
+int main()
+{
+ test();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.acc/str.pass.cpp b/libcxx/test/std/re/re.results/re.results.acc/str.pass.cpp
new file mode 100644
index 00000000000..2ebfeabb207
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.acc/str.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// string_type str(size_type sub = 0) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.str() == std::string(m[0]));
+ assert(m.str(0) == std::string(m[0]));
+ assert(m.str(1) == std::string(m[1]));
+ assert(m.str(2) == std::string(m[2]));
+ assert(m.str(3) == std::string(m[3]));
+ assert(m.str(4) == std::string(m[4]));
+}
+
+int main()
+{
+ test();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.acc/suffix.pass.cpp b/libcxx/test/std/re/re.results/re.results.acc/suffix.pass.cpp
new file mode 100644
index 00000000000..b842ea861e4
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.acc/suffix.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_reference suffix() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ assert(m.suffix().first == s+9);
+ assert(m.suffix().second == s+11);
+ assert(m.suffix().matched == true);
+}
+
+int main()
+{
+ test();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.all/get_allocator.pass.cpp b/libcxx/test/std/re/re.results/re.results.all/get_allocator.pass.cpp
new file mode 100644
index 00000000000..04367953ad2
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.all/get_allocator.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// allocator_type get_allocator() const;
+
+#include <regex>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class CharT, class Allocator>
+void
+test(const Allocator& a)
+{
+ std::match_results<const CharT*, Allocator> m(a);
+ assert(m.size() == 0);
+ assert(m.str() == std::basic_string<CharT>());
+ assert(m.get_allocator() == a);
+}
+
+int main()
+{
+ test<char>(test_allocator<std::sub_match<const char*> >(3));
+ test<wchar_t>(test_allocator<std::sub_match<const wchar_t*> >(3));
+}
diff --git a/libcxx/test/std/re/re.results/re.results.const/allocator.pass.cpp b/libcxx/test/std/re/re.results/re.results.const/allocator.pass.cpp
new file mode 100644
index 00000000000..a24c669f657
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.const/allocator.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// match_results(const Allocator& a = Allocator());
+
+#include <regex>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class CharT, class Allocator>
+void
+test(const Allocator& a)
+{
+ std::match_results<const CharT*, Allocator> m(a);
+ assert(m.size() == 0);
+ assert(m.str() == std::basic_string<CharT>());
+ assert(m.get_allocator() == a);
+}
+
+int main()
+{
+ test<char>(test_allocator<std::sub_match<const char*> >(3));
+ test<wchar_t>(test_allocator<std::sub_match<const wchar_t*> >(3));
+}
diff --git a/libcxx/test/std/re/re.results/re.results.const/default.pass.cpp b/libcxx/test/std/re/re.results/re.results.const/default.pass.cpp
new file mode 100644
index 00000000000..e10fbfd76cf
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.const/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// match_results(const Allocator& a = Allocator());
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ std::match_results<const CharT*> m;
+ assert(m.size() == 0);
+ assert(m.str() == std::basic_string<CharT>());
+ assert(m.get_allocator() == std::allocator<std::sub_match<const CharT*> >());
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.form/form1.pass.cpp b/libcxx/test/std/re/re.results/re.results.form/form1.pass.cpp
new file mode 100644
index 00000000000..9701c60ba77
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.form/form1.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class OutputIter>
+// OutputIter
+// format(OutputIter out, const char_type* fmt_first, const char_type* fmt_last,
+// regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, fmt + std::char_traits<char>::length(fmt)).base();
+ assert(r == out + 58);
+ assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, fmt + std::char_traits<char>::length(fmt),
+ std::regex_constants::format_sed).base();
+ assert(r == out + 59);
+ assert(std::string(out) == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, fmt + std::char_traits<char>::length(fmt),
+ std::regex_constants::format_sed).base();
+ assert(r == out + 34);
+ assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e");
+ }
+
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+ fmt, fmt + std::char_traits<wchar_t>::length(fmt)).base();
+ assert(r == out + 58);
+ assert(std::wstring(out) == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+ fmt, fmt + std::char_traits<wchar_t>::length(fmt),
+ std::regex_constants::format_sed).base();
+ assert(r == out + 59);
+ assert(std::wstring(out) == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ const wchar_t fmt[] = L"match: &, m[1]: \\1, m[2]: \\2";
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+ fmt, fmt + std::char_traits<wchar_t>::length(fmt),
+ std::regex_constants::format_sed).base();
+ assert(r == out + 34);
+ assert(std::wstring(out) == L"match: cdefghi, m[1]: efg, m[2]: e");
+ }
+}
diff --git a/libcxx/test/std/re/re.results/re.results.form/form2.pass.cpp b/libcxx/test/std/re/re.results/re.results.form/form2.pass.cpp
new file mode 100644
index 00000000000..b18b7fb9f55
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.form/form2.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class OutputIter, class ST, class SA>
+// OutputIter
+// format(OutputIter out, const basic_string<char_type, ST, SA>& fmt,
+// regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <iostream>
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > nstr;
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t> > wstr;
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ char* r = m.format(output_iterator<char*>(out), fmt).base();
+ assert(r == out + 58);
+ assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, std::regex_constants::format_sed).base();
+ assert(r == out + 59);
+ assert(std::string(out) == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ nstr fmt("match: &, m[1]: \\1, m[2]: \\2");
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, std::regex_constants::format_sed).base();
+ assert(r == out + 34);
+ assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e");
+ }
+
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out), fmt).base();
+ assert(r == out + 58);
+ assert(std::wstring(out) == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+ fmt, std::regex_constants::format_sed).base();
+ assert(r == out + 59);
+ assert(std::wstring(out) == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ wstr fmt(L"match: &, m[1]: \\1, m[2]: \\2");
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+ fmt, std::regex_constants::format_sed).base();
+ assert(r == out + 34);
+ assert(std::wstring(out) == L"match: cdefghi, m[1]: efg, m[2]: e");
+ }
+}
diff --git a/libcxx/test/std/re/re.results/re.results.form/form3.pass.cpp b/libcxx/test/std/re/re.results/re.results.form/form3.pass.cpp
new file mode 100644
index 00000000000..27f2388adce
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.form/form3.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class ST, class SA>
+// basic_string<char_type, ST, SA>
+// format(const basic_string<char_type, ST, SA>& fmt,
+// regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <iostream>
+
+#include <regex>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+ typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > nstr;
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t> > wstr;
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ nstr out = m.format(fmt);
+ assert(out == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ nstr out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ nstr fmt("match: &, m[1]: \\1, m[2]: \\2");
+ nstr out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == "match: cdefghi, m[1]: efg, m[2]: e");
+ }
+
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ wstr out = m.format(fmt);
+ assert(out == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ wstr out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wstr fmt(L"match: &, m[1]: \\1, m[2]: \\2");
+ wstr out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == L"match: cdefghi, m[1]: efg, m[2]: e");
+ }
+}
diff --git a/libcxx/test/std/re/re.results/re.results.form/form4.pass.cpp b/libcxx/test/std/re/re.results/re.results.form/form4.pass.cpp
new file mode 100644
index 00000000000..1d44c32f6a8
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.form/form4.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// string_type
+// format(const char_type* fmt,
+// regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <iostream>
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ std::string out = m.format(fmt);
+ assert(out == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ std::string out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
+ std::string out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == "match: cdefghi, m[1]: efg, m[2]: e");
+ }
+
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ std::wstring out = m.format(fmt);
+ assert(out == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ std::wstring out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ const wchar_t fmt[] = L"match: &, m[1]: \\1, m[2]: \\2";
+ std::wstring out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == L"match: cdefghi, m[1]: efg, m[2]: e");
+ }
+}
diff --git a/libcxx/test/std/re/re.results/re.results.nonmember/equal.pass.cpp b/libcxx/test/std/re/re.results/re.results.nonmember/equal.pass.cpp
new file mode 100644
index 00000000000..7902b8e642e
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.nonmember/equal.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class BidirectionalIterator, class Allocator>
+// bool
+// operator==(const match_results<BidirectionalIterator, Allocator>& m1,
+// const match_results<BidirectionalIterator, Allocator>& m2);
+
+// template <class BidirectionalIterator, class Allocator>
+// bool
+// operator!=(const match_results<BidirectionalIterator, Allocator>& m1,
+// const match_results<BidirectionalIterator, Allocator>& m2);
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m1;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi")));
+ std::match_results<const char*> m2;
+
+ assert(m1 == m1);
+ assert(m1 != m2);
+
+ m2 = m1;
+
+ assert(m1 == m2);
+}
+
+int main()
+{
+ test();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.size/empty.pass.cpp b/libcxx/test/std/re/re.results/re.results.size/empty.pass.cpp
new file mode 100644
index 00000000000..6634d92830d
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.size/empty.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// size_type size() const;
+// bool empty() const;
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ std::match_results<const CharT*> m;
+ assert(m.empty());
+ assert(m.size() == 0);
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+ assert(!m.empty());
+ assert(m.size() == 3);
+}
+
+int main()
+{
+ test<char>();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.size/max_size.pass.cpp b/libcxx/test/std/re/re.results/re.results.size/max_size.pass.cpp
new file mode 100644
index 00000000000..0b31409275b
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.size/max_size.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// size_type max_size() const;
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ std::match_results<const CharT*> m;
+ assert(m.max_size() > 0);
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.state/ready.pass.cpp b/libcxx/test/std/re/re.results/re.results.state/ready.pass.cpp
new file mode 100644
index 00000000000..8f586c3f32d
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.state/ready.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// bool ready() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test1()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(m.ready() == false);
+ std::regex_search(s, m, std::regex("cd((e)fg)hi"));
+ assert(m.ready() == true);
+}
+
+void
+test2()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(m.ready() == false);
+ std::regex_search(s, m, std::regex("z"));
+ assert(m.ready() == true);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.swap/member_swap.pass.cpp b/libcxx/test/std/re/re.results/re.results.swap/member_swap.pass.cpp
new file mode 100644
index 00000000000..09b85c0ff5d
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.swap/member_swap.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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// void swap(match_results& that);
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m1;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi")));
+ std::match_results<const char*> m2;
+
+ std::match_results<const char*> m1_save = m1;
+ std::match_results<const char*> m2_save = m2;
+
+ m1.swap(m2);
+
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+}
+
+int main()
+{
+ test();
+}
diff --git a/libcxx/test/std/re/re.results/re.results.swap/non_member_swap.pass.cpp b/libcxx/test/std/re/re.results/re.results.swap/non_member_swap.pass.cpp
new file mode 100644
index 00000000000..3f5e34df44c
--- /dev/null
+++ b/libcxx/test/std/re/re.results/re.results.swap/non_member_swap.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class BidirectionalIterator, class Allocator>
+// void swap(match_results<BidirectionalIterator, Allocator>& m1,
+// match_results<BidirectionalIterator, Allocator>& m2);
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m1;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi")));
+ std::match_results<const char*> m2;
+
+ std::match_results<const char*> m1_save = m1;
+ std::match_results<const char*> m2_save = m2;
+
+ swap(m1, m2);
+
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+}
+
+int main()
+{
+ test();
+}
diff --git a/libcxx/test/std/re/re.results/types.pass.cpp b/libcxx/test/std/re/re.results/types.pass.cpp
new file mode 100644
index 00000000000..4d553837efe
--- /dev/null
+++ b/libcxx/test/std/re/re.results/types.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator,
+// class Allocator = allocator<sub_match<BidirectionalIterator>>>
+// class match_results
+// {
+// public:
+// typedef sub_match<BidirectionalIterator> value_type;
+// typedef const value_type& const_reference;
+// typedef const_reference reference;
+// typedef /implementation-defined/ const_iterator;
+// typedef const_iterator iterator;
+// typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
+// typedef typename allocator_traits<Allocator>::size_type size_type;
+// typedef Allocator allocator_type;
+// typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;
+// typedef basic_string<char_type> string_type;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::match_results<CharT*> MR;
+ static_assert((std::is_same<typename MR::value_type, std::sub_match<CharT*> >::value), "");
+ static_assert((std::is_same<typename MR::const_reference, const std::sub_match<CharT*>& >::value), "");
+ static_assert((std::is_same<typename MR::reference, std::sub_match<CharT*>& >::value), "");
+ static_assert((!std::is_same<typename MR::const_iterator, void>::value), "");
+ static_assert((std::is_same<typename MR::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<typename MR::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<typename MR::allocator_type, std::allocator<std::sub_match<CharT*> > >::value), "");
+ static_assert((std::is_same<typename MR::char_type, CharT>::value), "");
+ static_assert((std::is_same<typename MR::string_type, std::basic_string<CharT> >::value), "");
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/libcxx/test/std/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp b/libcxx/test/std/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp
new file mode 100644
index 00000000000..c14d5bcdefa
--- /dev/null
+++ b/libcxx/test/std/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator> class sub_match;
+
+// int compare(const string_type& s) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ typedef SM::string_type string;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare(string()) == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare(string()) > 0);
+ assert(sm.compare(string("123")) == 0);
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ typedef SM::string_type string;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare(string()) == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare(string()) > 0);
+ assert(sm.compare(string(L"123")) == 0);
+ }
+}
diff --git a/libcxx/test/std/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp b/libcxx/test/std/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp
new file mode 100644
index 00000000000..0874742f1c9
--- /dev/null
+++ b/libcxx/test/std/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator> class sub_match;
+
+// int compare(const sub_match& s) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare(sm2) == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare(sm2) > 0);
+ sm2.first = s;
+ sm2.second = s + 3;
+ sm2.matched = true;
+ assert(sm.compare(sm2) == 0);
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare(sm2) == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare(sm2) > 0);
+ sm2.first = s;
+ sm2.second = s + 3;
+ sm2.matched = true;
+ assert(sm.compare(sm2) == 0);
+ }
+}
diff --git a/libcxx/test/std/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp b/libcxx/test/std/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp
new file mode 100644
index 00000000000..48c05ca91d0
--- /dev/null
+++ b/libcxx/test/std/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator> class sub_match;
+
+// int compare(const value_type* s) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare("") == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare("") > 0);
+ assert(sm.compare("123") == 0);
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare(L"") == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare(L"") > 0);
+ assert(sm.compare(L"123") == 0);
+ }
+}
diff --git a/libcxx/test/std/re/re.submatch/re.submatch.members/default.pass.cpp b/libcxx/test/std/re/re.submatch/re.submatch.members/default.pass.cpp
new file mode 100644
index 00000000000..451466af83c
--- /dev/null
+++ b/libcxx/test/std/re/re.submatch/re.submatch.members/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator> class sub_match;
+
+// constexpr sub_match();
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm;
+ assert(sm.matched == false);
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm;
+ assert(sm.matched == false);
+ }
+}
diff --git a/libcxx/test/std/re/re.submatch/re.submatch.members/length.pass.cpp b/libcxx/test/std/re/re.submatch/re.submatch.members/length.pass.cpp
new file mode 100644
index 00000000000..4874c0d0592
--- /dev/null
+++ b/libcxx/test/std/re/re.submatch/re.submatch.members/length.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator> class sub_match;
+
+// difference_type length() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ assert(sm.length() == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.length() == 3);
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ assert(sm.length() == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.length() == 3);
+ }
+}
diff --git a/libcxx/test/std/re/re.submatch/re.submatch.members/operator_string.pass.cpp b/libcxx/test/std/re/re.submatch/re.submatch.members/operator_string.pass.cpp
new file mode 100644
index 00000000000..dd856a56d0b
--- /dev/null
+++ b/libcxx/test/std/re/re.submatch/re.submatch.members/operator_string.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator> class sub_match;
+
+// operator string_type() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM::string_type str = sm;
+ assert(str.empty());
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ str = sm;
+ assert(str == std::string("123"));
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM::string_type str = sm;
+ assert(str.empty());
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ str = sm;
+ assert(str == std::wstring(L"123"));
+ }
+}
diff --git a/libcxx/test/std/re/re.submatch/re.submatch.members/str.pass.cpp b/libcxx/test/std/re/re.submatch/re.submatch.members/str.pass.cpp
new file mode 100644
index 00000000000..ca5fd7d78ac
--- /dev/null
+++ b/libcxx/test/std/re/re.submatch/re.submatch.members/str.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator> class sub_match;
+
+// string_type str() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM::string_type str = sm.str();
+ assert(str.empty());
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ str = sm.str();
+ assert(str == std::string("123"));
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM::string_type str = sm.str();
+ assert(str.empty());
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ str = sm.str();
+ assert(str == std::wstring(L"123"));
+ }
+}
diff --git a/libcxx/test/std/re/re.submatch/re.submatch.op/compare.pass.cpp b/libcxx/test/std/re/re.submatch/re.submatch.op/compare.pass.cpp
new file mode 100644
index 00000000000..36376aa0563
--- /dev/null
+++ b/libcxx/test/std/re/re.submatch/re.submatch.op/compare.pass.cpp
@@ -0,0 +1,287 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator> class sub_match;
+
+// template <class BiIter>
+// bool
+// operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator==(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator!=(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator<(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool operator>(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator>=(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator<=(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator==(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator==(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator!=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator<(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator>(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator>=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator<=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator==(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator==(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+// bool
+// operator!=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const std::basic_string<CharT>& x, const std::basic_string<CharT>& y, bool doCStrTests = true)
+{
+ typedef std::basic_string<CharT> string;
+ typedef std::sub_match<typename string::const_iterator> sub_match;
+ sub_match sm1;
+ sm1.first = x.begin();
+ sm1.second = x.end();
+ sm1.matched = true;
+ sub_match sm2;
+ sm2.first = y.begin();
+ sm2.second = y.end();
+ sm2.matched = true;
+ assert((sm1 == sm2) == (x == y));
+ assert((sm1 != sm2) == (x != y));
+ assert((sm1 < sm2) == (x < y));
+ assert((sm1 > sm2) == (x > y));
+ assert((sm1 <= sm2) == (x <= y));
+ assert((sm1 >= sm2) == (x >= y));
+ assert((x == sm2) == (x == y));
+ assert((x != sm2) == (x != y));
+ assert((x < sm2) == (x < y));
+ assert((x > sm2) == (x > y));
+ assert((x <= sm2) == (x <= y));
+ assert((x >= sm2) == (x >= y));
+ assert((sm1 == y) == (x == y));
+ assert((sm1 != y) == (x != y));
+ assert((sm1 < y) == (x < y));
+ assert((sm1 > y) == (x > y));
+ assert((sm1 <= y) == (x <= y));
+ assert((sm1 >= y) == (x >= y));
+ if (doCStrTests) {
+ assert((x.c_str() == sm2) == (x == y));
+ assert((x.c_str() != sm2) == (x != y));
+ assert((x.c_str() < sm2) == (x < y));
+ assert((x.c_str() > sm2) == (x > y));
+ assert((x.c_str() <= sm2) == (x <= y));
+ assert((x.c_str() >= sm2) == (x >= y));
+ assert((sm1 == y.c_str()) == (x == y));
+ assert((sm1 != y.c_str()) == (x != y));
+ assert((sm1 < y.c_str()) == (x < y));
+ assert((sm1 > y.c_str()) == (x > y));
+ assert((sm1 <= y.c_str()) == (x <= y));
+ assert((sm1 >= y.c_str()) == (x >= y));
+ }
+ assert((x[0] == sm2) == (string(1, x[0]) == y));
+ assert((x[0] != sm2) == (string(1, x[0]) != y));
+ assert((x[0] < sm2) == (string(1, x[0]) < y));
+ assert((x[0] > sm2) == (string(1, x[0]) > y));
+ assert((x[0] <= sm2) == (string(1, x[0]) <= y));
+ assert((x[0] >= sm2) == (string(1, x[0]) >= y));
+ assert((sm1 == y[0]) == (x == string(1, y[0])));
+ assert((sm1 != y[0]) == (x != string(1, y[0])));
+ assert((sm1 < y[0]) == (x < string(1, y[0])));
+ assert((sm1 > y[0]) == (x > string(1, y[0])));
+ assert((sm1 <= y[0]) == (x <= string(1, y[0])));
+ assert((sm1 >= y[0]) == (x >= string(1, y[0])));
+}
+
+int main()
+{
+ test(std::string("123"), std::string("123"));
+ test(std::string("1234"), std::string("123"));
+ test(std::wstring(L"123"), std::wstring(L"123"));
+ test(std::wstring(L"1234"), std::wstring(L"123"));
+ test(std::string("123\00056", 6), std::string("123\00056", 6), false);
+ test(std::wstring(L"123\00056", 6), std::wstring(L"123\00056", 6), false);
+}
diff --git a/libcxx/test/std/re/re.submatch/re.submatch.op/stream.pass.cpp b/libcxx/test/std/re/re.submatch/re.submatch.op/stream.pass.cpp
new file mode 100644
index 00000000000..050bb062e71
--- /dev/null
+++ b/libcxx/test/std/re/re.submatch/re.submatch.op/stream.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator> class sub_match;
+
+// template <class charT, class ST, class BiIter>
+// basic_ostream<charT, ST>&
+// operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
+
+#include <regex>
+#include <sstream>
+#include <cassert>
+
+template <class CharT>
+void
+test(const std::basic_string<CharT>& s)
+{
+ typedef std::basic_string<CharT> string;
+ typedef std::sub_match<typename string::const_iterator> SM;
+ typedef std::basic_ostringstream<CharT> ostringstream;
+ SM sm;
+ sm.first = s.begin();
+ sm.second = s.end();
+ sm.matched = true;
+ ostringstream os;
+ os << sm;
+ assert(os.str() == s);
+}
+
+int main()
+{
+ test(std::string("123"));
+ test(std::wstring(L"123"));
+}
diff --git a/libcxx/test/std/re/re.submatch/types.pass.cpp b/libcxx/test/std/re/re.submatch/types.pass.cpp
new file mode 100644
index 00000000000..47c79149a8d
--- /dev/null
+++ b/libcxx/test/std/re/re.submatch/types.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 BidirectionalIterator>
+// class sub_match
+// : public pair<BidirectionalIterator, BidirectionalIterator>
+// {
+// public:
+// typedef BidirectionalIterator iterator;
+// typedef typename iterator_traits<iterator>::value_type value_type;
+// typedef typename iterator_traits<iterator>::difference_type difference_type;
+// typedef basic_string<value_type> string_type;
+//
+// bool matched;
+// ...
+// };
+
+#include <regex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::sub_match<char*> SM;
+ static_assert((std::is_same<SM::iterator, char*>::value), "");
+ static_assert((std::is_same<SM::value_type, char>::value), "");
+ static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<SM::string_type, std::string>::value), "");
+ static_assert((std::is_convertible<SM*, std::pair<char*, char*>*>::value), "");
+
+ SM sm;
+ sm.first = nullptr;
+ sm.second = nullptr;
+ sm.matched = false;
+ }
+ {
+ typedef std::sub_match<wchar_t*> SM;
+ static_assert((std::is_same<SM::iterator, wchar_t*>::value), "");
+ static_assert((std::is_same<SM::value_type, wchar_t>::value), "");
+ static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<SM::string_type, std::wstring>::value), "");
+ static_assert((std::is_convertible<SM*, std::pair<wchar_t*, wchar_t*>*>::value), "");
+
+ SM sm;
+ sm.first = nullptr;
+ sm.second = nullptr;
+ sm.matched = false;
+ }
+ {
+ static_assert((std::is_same<std::csub_match, std::sub_match<const char*> >::value), "");
+ static_assert((std::is_same<std::wcsub_match, std::sub_match<const wchar_t*> >::value), "");
+ static_assert((std::is_same<std::ssub_match, std::sub_match<std::string::const_iterator> >::value), "");
+ static_assert((std::is_same<std::wssub_match, std::sub_match<std::wstring::const_iterator> >::value), "");
+ }
+}
diff --git a/libcxx/test/std/re/re.syn/cmatch.pass.cpp b/libcxx/test/std/re/re.syn/cmatch.pass.cpp
new file mode 100644
index 00000000000..1364b7873ea
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/cmatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef match_results<const char*> cmatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::match_results<const char*>, std::cmatch>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/cregex_iterator.pass.cpp b/libcxx/test/std/re/re.syn/cregex_iterator.pass.cpp
new file mode 100644
index 00000000000..7b6ac133f5a
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/cregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef regex_iterator<const char*> cregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_iterator<const char*>, std::cregex_iterator>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/cregex_token_iterator.pass.cpp b/libcxx/test/std/re/re.syn/cregex_token_iterator.pass.cpp
new file mode 100644
index 00000000000..36ee9b66ea9
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/cregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef regex_token_iterator<const char*> cregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_token_iterator<const char*>, std::cregex_token_iterator>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/csub_match.pass.cpp b/libcxx/test/std/re/re.syn/csub_match.pass.cpp
new file mode 100644
index 00000000000..e0de67b4feb
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/csub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef sub_match<const char*> csub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::sub_match<const char*>, std::csub_match>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/regex.pass.cpp b/libcxx/test/std/re/re.syn/regex.pass.cpp
new file mode 100644
index 00000000000..a208442b966
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/regex.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef basic_regex<char> regex;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::basic_regex<char>, std::regex>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/smatch.pass.cpp b/libcxx/test/std/re/re.syn/smatch.pass.cpp
new file mode 100644
index 00000000000..87323538968
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/smatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef match_results<string::const_iterator> smatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::match_results<std::string::const_iterator>, std::smatch>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/sregex_iterator.pass.cpp b/libcxx/test/std/re/re.syn/sregex_iterator.pass.cpp
new file mode 100644
index 00000000000..7acd96194b0
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/sregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef regex_iterator<string::const_iterator> sregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_iterator<std::string::const_iterator>, std::sregex_iterator>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/sregex_token_iterator.pass.cpp b/libcxx/test/std/re/re.syn/sregex_token_iterator.pass.cpp
new file mode 100644
index 00000000000..185fd627b4f
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/sregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_token_iterator<std::string::const_iterator>, std::sregex_token_iterator>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/ssub_match.pass.cpp b/libcxx/test/std/re/re.syn/ssub_match.pass.cpp
new file mode 100644
index 00000000000..b378339664c
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/ssub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef sub_match<string::const_iterator> ssub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::sub_match<std::string::const_iterator>, std::ssub_match>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/wcmatch.pass.cpp b/libcxx/test/std/re/re.syn/wcmatch.pass.cpp
new file mode 100644
index 00000000000..3ca8ed51eab
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/wcmatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef match_results<const wchar_t*> wcmatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::match_results<const wchar_t*>, std::wcmatch>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/wcregex_iterator.pass.cpp b/libcxx/test/std/re/re.syn/wcregex_iterator.pass.cpp
new file mode 100644
index 00000000000..99469ecf82b
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/wcregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef regex_iterator<const wchar_t*> wcregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_iterator<const wchar_t*>, std::wcregex_iterator>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/wcregex_token_iterator.pass.cpp b/libcxx/test/std/re/re.syn/wcregex_token_iterator.pass.cpp
new file mode 100644
index 00000000000..f16911f2985
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/wcregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_token_iterator<const wchar_t*>, std::wcregex_token_iterator>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/wcsub_match.pass.cpp b/libcxx/test/std/re/re.syn/wcsub_match.pass.cpp
new file mode 100644
index 00000000000..7e8c872b603
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/wcsub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef sub_match<const wchar_t*> wcsub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::sub_match<const wchar_t*>, std::wcsub_match>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/wregex.pass.cpp b/libcxx/test/std/re/re.syn/wregex.pass.cpp
new file mode 100644
index 00000000000..635eac0176c
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/wregex.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef basic_regex<wchar_t> wregex;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::basic_regex<wchar_t>, std::wregex>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/wsmatch.pass.cpp b/libcxx/test/std/re/re.syn/wsmatch.pass.cpp
new file mode 100644
index 00000000000..092c7d16d7a
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/wsmatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef match_results<wstring::const_iterator> wsmatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::match_results<std::wstring::const_iterator>, std::wsmatch>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/wsregex_iterator.pass.cpp b/libcxx/test/std/re/re.syn/wsregex_iterator.pass.cpp
new file mode 100644
index 00000000000..0052716e46d
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/wsregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_iterator<std::wstring::const_iterator>, std::wsregex_iterator>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/wsregex_token_iterator.pass.cpp b/libcxx/test/std/re/re.syn/wsregex_token_iterator.pass.cpp
new file mode 100644
index 00000000000..dc71991eb9b
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/wsregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_token_iterator<std::wstring::const_iterator>, std::wsregex_token_iterator>::value), "");
+}
diff --git a/libcxx/test/std/re/re.syn/wssub_match.pass.cpp b/libcxx/test/std/re/re.syn/wssub_match.pass.cpp
new file mode 100644
index 00000000000..2360a15513d
--- /dev/null
+++ b/libcxx/test/std/re/re.syn/wssub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// typedef sub_match<wstring::const_iterator> wssub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::sub_match<std::wstring::const_iterator>, std::wssub_match>::value), "");
+}
diff --git a/libcxx/test/std/re/re.traits/default.pass.cpp b/libcxx/test/std/re/re.traits/default.pass.cpp
new file mode 100644
index 00000000000..c9a97e025ac
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/default.pass.cpp
@@ -0,0 +1,37 @@
+// -*- 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>
+
+// template <class charT> struct regex_traits;
+
+// regex_traits();
+
+#include <regex>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == "C");
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == "C");
+ }
+ {
+ std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == LOCALE_en_US_UTF_8);
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == LOCALE_en_US_UTF_8);
+ }
+}
diff --git a/libcxx/test/std/re/re.traits/getloc.pass.cpp b/libcxx/test/std/re/re.traits/getloc.pass.cpp
new file mode 100644
index 00000000000..27ab6cd8654
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/getloc.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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> struct regex_traits;
+
+// locale_type getloc()const;
+
+#include <regex>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == "C");
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == "C");
+ }
+ {
+ std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == LOCALE_en_US_UTF_8);
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == LOCALE_en_US_UTF_8);
+ }
+}
diff --git a/libcxx/test/std/re/re.traits/imbue.pass.cpp b/libcxx/test/std/re/re.traits/imbue.pass.cpp
new file mode 100644
index 00000000000..11eca41de37
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/imbue.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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> struct regex_traits;
+
+// locale_type imbue(locale_type l);
+
+#include <regex>
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+ std::locale loc = t.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(loc.name() == "C");
+ assert(t.getloc().name() == LOCALE_en_US_UTF_8);
+ }
+}
diff --git a/libcxx/test/std/re/re.traits/isctype.pass.cpp b/libcxx/test/std/re/re.traits/isctype.pass.cpp
new file mode 100644
index 00000000000..ad69f05ae75
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/isctype.pass.cpp
@@ -0,0 +1,279 @@
+//===----------------------------------------------------------------------===//
+//
+// 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> struct regex_traits;
+
+// bool isctype(charT c, char_class_type f) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+
+ std::string s("w");
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "alnum";
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "alpha";
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "blank";
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "cntrl";
+ assert( t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "digit";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "graph";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "lower";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "print";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "punct";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "space";
+ assert( t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "upper";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "xdigit";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+ }
+ {
+ std::regex_traits<wchar_t> t;
+
+ std::wstring s(L"w");
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"alnum";
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"alpha";
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"blank";
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"cntrl";
+ assert( t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"digit";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"graph";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"lower";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"print";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"punct";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"space";
+ assert( t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"upper";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"xdigit";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+ }
+}
diff --git a/libcxx/test/std/re/re.traits/length.pass.cpp b/libcxx/test/std/re/re.traits/length.pass.cpp
new file mode 100644
index 00000000000..473c233c531
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/length.pass.cpp
@@ -0,0 +1,31 @@
+// -*- 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>
+
+// template <class charT> struct regex_traits;
+
+// static std::size_t length(const char_type* p);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(std::regex_traits<char>::length("") == 0);
+ assert(std::regex_traits<char>::length("1") == 1);
+ assert(std::regex_traits<char>::length("12") == 2);
+ assert(std::regex_traits<char>::length("123") == 3);
+
+ assert(std::regex_traits<wchar_t>::length(L"") == 0);
+ assert(std::regex_traits<wchar_t>::length(L"1") == 1);
+ assert(std::regex_traits<wchar_t>::length(L"12") == 2);
+ assert(std::regex_traits<wchar_t>::length(L"123") == 3);
+}
diff --git a/libcxx/test/std/re/re.traits/lookup_classname.pass.cpp b/libcxx/test/std/re/re.traits/lookup_classname.pass.cpp
new file mode 100644
index 00000000000..0b1b18eb507
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/lookup_classname.pass.cpp
@@ -0,0 +1,211 @@
+//===----------------------------------------------------------------------===//
+//
+// 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> struct regex_traits;
+
+// template <class ForwardIterator>
+// char_class_type
+// lookup_classname(ForwardIterator first, ForwardIterator last,
+// bool icase = false) const;
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+template <class char_type>
+void
+test(const char_type* A,
+ typename std::regex_traits<char_type>::char_class_type expected,
+ bool icase = false)
+{
+ std::regex_traits<char_type> t;
+ typedef forward_iterator<const char_type*> F;
+ assert(t.lookup_classname(F(A), F(A + t.length(A)), icase) == expected);
+}
+
+int main()
+{
+ test("d", std::ctype_base::digit);
+ test("D", std::ctype_base::digit);
+ test("d", std::ctype_base::digit, true);
+ test("D", std::ctype_base::digit, true);
+
+ test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+ test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+
+ test("s", std::ctype_base::space);
+ test("S", std::ctype_base::space);
+ test("s", std::ctype_base::space, true);
+ test("S", std::ctype_base::space, true);
+
+ test("alnum", std::ctype_base::alnum);
+ test("AlNum", std::ctype_base::alnum);
+ test("alnum", std::ctype_base::alnum, true);
+ test("AlNum", std::ctype_base::alnum, true);
+
+ test("alpha", std::ctype_base::alpha);
+ test("Alpha", std::ctype_base::alpha);
+ test("alpha", std::ctype_base::alpha, true);
+ test("Alpha", std::ctype_base::alpha, true);
+
+ test("blank", std::ctype_base::blank);
+ test("Blank", std::ctype_base::blank);
+ test("blank", std::ctype_base::blank, true);
+ test("Blank", std::ctype_base::blank, true);
+
+ test("cntrl", std::ctype_base::cntrl);
+ test("Cntrl", std::ctype_base::cntrl);
+ test("cntrl", std::ctype_base::cntrl, true);
+ test("Cntrl", std::ctype_base::cntrl, true);
+
+ test("digit", std::ctype_base::digit);
+ test("Digit", std::ctype_base::digit);
+ test("digit", std::ctype_base::digit, true);
+ test("Digit", std::ctype_base::digit, true);
+
+ test("digit", std::ctype_base::digit);
+ test("DIGIT", std::ctype_base::digit);
+ test("digit", std::ctype_base::digit, true);
+ test("Digit", std::ctype_base::digit, true);
+
+ test("graph", std::ctype_base::graph);
+ test("GRAPH", std::ctype_base::graph);
+ test("graph", std::ctype_base::graph, true);
+ test("Graph", std::ctype_base::graph, true);
+
+ test("lower", std::ctype_base::lower);
+ test("LOWER", std::ctype_base::lower);
+ test("lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+ test("Lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+
+ test("print", std::ctype_base::print);
+ test("PRINT", std::ctype_base::print);
+ test("print", std::ctype_base::print, true);
+ test("Print", std::ctype_base::print, true);
+
+ test("punct", std::ctype_base::punct);
+ test("PUNCT", std::ctype_base::punct);
+ test("punct", std::ctype_base::punct, true);
+ test("Punct", std::ctype_base::punct, true);
+
+ test("space", std::ctype_base::space);
+ test("SPACE", std::ctype_base::space);
+ test("space", std::ctype_base::space, true);
+ test("Space", std::ctype_base::space, true);
+
+ test("upper", std::ctype_base::upper);
+ test("UPPER", std::ctype_base::upper);
+ test("upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+ test("Upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+
+ test("xdigit", std::ctype_base::xdigit);
+ test("XDIGIT", std::ctype_base::xdigit);
+ test("xdigit", std::ctype_base::xdigit, true);
+ test("Xdigit", std::ctype_base::xdigit, true);
+
+ test("dig", std::ctype_base::mask());
+ test("", std::ctype_base::mask());
+ test("digits", std::ctype_base::mask());
+
+ test(L"d", std::ctype_base::digit);
+ test(L"D", std::ctype_base::digit);
+ test(L"d", std::ctype_base::digit, true);
+ test(L"D", std::ctype_base::digit, true);
+
+ test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+ test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+
+ test(L"s", std::ctype_base::space);
+ test(L"S", std::ctype_base::space);
+ test(L"s", std::ctype_base::space, true);
+ test(L"S", std::ctype_base::space, true);
+
+ test(L"alnum", std::ctype_base::alnum);
+ test(L"AlNum", std::ctype_base::alnum);
+ test(L"alnum", std::ctype_base::alnum, true);
+ test(L"AlNum", std::ctype_base::alnum, true);
+
+ test(L"alpha", std::ctype_base::alpha);
+ test(L"Alpha", std::ctype_base::alpha);
+ test(L"alpha", std::ctype_base::alpha, true);
+ test(L"Alpha", std::ctype_base::alpha, true);
+
+ test(L"blank", std::ctype_base::blank);
+ test(L"Blank", std::ctype_base::blank);
+ test(L"blank", std::ctype_base::blank, true);
+ test(L"Blank", std::ctype_base::blank, true);
+
+ test(L"cntrl", std::ctype_base::cntrl);
+ test(L"Cntrl", std::ctype_base::cntrl);
+ test(L"cntrl", std::ctype_base::cntrl, true);
+ test(L"Cntrl", std::ctype_base::cntrl, true);
+
+ test(L"digit", std::ctype_base::digit);
+ test(L"Digit", std::ctype_base::digit);
+ test(L"digit", std::ctype_base::digit, true);
+ test(L"Digit", std::ctype_base::digit, true);
+
+ test(L"digit", std::ctype_base::digit);
+ test(L"DIGIT", std::ctype_base::digit);
+ test(L"digit", std::ctype_base::digit, true);
+ test(L"Digit", std::ctype_base::digit, true);
+
+ test(L"graph", std::ctype_base::graph);
+ test(L"GRAPH", std::ctype_base::graph);
+ test(L"graph", std::ctype_base::graph, true);
+ test(L"Graph", std::ctype_base::graph, true);
+
+ test(L"lower", std::ctype_base::lower);
+ test(L"LOWER", std::ctype_base::lower);
+ test(L"lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+ test(L"Lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+
+ test(L"print", std::ctype_base::print);
+ test(L"PRINT", std::ctype_base::print);
+ test(L"print", std::ctype_base::print, true);
+ test(L"Print", std::ctype_base::print, true);
+
+ test(L"punct", std::ctype_base::punct);
+ test(L"PUNCT", std::ctype_base::punct);
+ test(L"punct", std::ctype_base::punct, true);
+ test(L"Punct", std::ctype_base::punct, true);
+
+ test(L"space", std::ctype_base::space);
+ test(L"SPACE", std::ctype_base::space);
+ test(L"space", std::ctype_base::space, true);
+ test(L"Space", std::ctype_base::space, true);
+
+ test(L"upper", std::ctype_base::upper);
+ test(L"UPPER", std::ctype_base::upper);
+ test(L"upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+ test(L"Upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+
+ test(L"xdigit", std::ctype_base::xdigit);
+ test(L"XDIGIT", std::ctype_base::xdigit);
+ test(L"xdigit", std::ctype_base::xdigit, true);
+ test(L"Xdigit", std::ctype_base::xdigit, true);
+
+ test(L"dig", std::ctype_base::mask());
+ test(L"", std::ctype_base::mask());
+ test(L"digits", std::ctype_base::mask());
+}
diff --git a/libcxx/test/std/re/re.traits/lookup_collatename.pass.cpp b/libcxx/test/std/re/re.traits/lookup_collatename.pass.cpp
new file mode 100644
index 00000000000..d495f8aaf07
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/lookup_collatename.pass.cpp
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// template <class ForwardIterator>
+// string_type
+// lookup_collatename(ForwardIterator first, ForwardIterator last) const;
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <iterator>
+#include <cassert>
+#include "test_iterators.h"
+
+template <class char_type>
+void
+test(const char_type* A, const std::basic_string<char_type>& expected)
+{
+ std::regex_traits<char_type> t;
+ typedef forward_iterator<const char_type*> F;
+ assert(t.lookup_collatename(F(A), F(A + t.length(A))) == expected);
+}
+
+int main()
+{
+ test("NUL", std::string("\x00", 1));
+ test("alert", std::string("\x07"));
+ test("backspace", std::string("\x08"));
+ test("tab", std::string("\x09"));
+ test("carriage-return", std::string("\x0D"));
+ test("newline", std::string("\x0A"));
+ test("vertical-tab", std::string("\x0B"));
+ test("form-feed", std::string("\x0C"));
+ test("space", std::string(" "));
+ test("exclamation-mark", std::string("!"));
+ test("quotation-mark", std::string("\""));
+ test("number-sign", std::string("#"));
+ test("dollar-sign", std::string("$"));
+ test("percent-sign", std::string("%"));
+ test("ampersand", std::string("&"));
+ test("apostrophe", std::string("\'"));
+ test("left-parenthesis", std::string("("));
+ test("right-parenthesis", std::string(")"));
+ test("asterisk", std::string("*"));
+ test("plus-sign", std::string("+"));
+ test("comma", std::string(","));
+ test("hyphen-minus", std::string("-"));
+ test("hyphen", std::string("-"));
+ test("full-stop", std::string("."));
+ test("period", std::string("."));
+ test("slash", std::string("/"));
+ test("solidus", std::string("/"));
+ test("zero", std::string("0"));
+ test("one", std::string("1"));
+ test("two", std::string("2"));
+ test("three", std::string("3"));
+ test("four", std::string("4"));
+ test("five", std::string("5"));
+ test("six", std::string("6"));
+ test("seven", std::string("7"));
+ test("eight", std::string("8"));
+ test("nine", std::string("9"));
+ test("colon", std::string(":"));
+ test("semicolon", std::string(";"));
+ test("less-than-sign", std::string("<"));
+ test("equals-sign", std::string("="));
+ test("greater-than-sign", std::string(">"));
+ test("question-mark", std::string("?"));
+ test("commercial-at", std::string("@"));
+ for (char c = 'A'; c <= 'Z'; ++c)
+ {
+ const char a[2] = {c};
+ test(a, std::string(a));
+ }
+ test("left-square-bracket", std::string("["));
+ test("backslash", std::string("\\"));
+ test("reverse-solidus", std::string("\\"));
+ test("right-square-bracket", std::string("]"));
+ test("circumflex-accent", std::string("^"));
+ test("circumflex", std::string("^"));
+ test("low-line", std::string("_"));
+ test("underscore", std::string("_"));
+ test("grave-accent", std::string("`"));
+ for (char c = 'a'; c <= 'z'; ++c)
+ {
+ const char a[2] = {c};
+ test(a, std::string(a));
+ }
+ test("left-brace", std::string("{"));
+ test("left-curly-bracket", std::string("{"));
+ test("vertical-line", std::string("|"));
+ test("right-brace", std::string("}"));
+ test("right-curly-bracket", std::string("}"));
+ test("tilde", std::string("~"));
+
+ test("tild", std::string(""));
+ test("ch", std::string(""));
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ test("ch", std::string("ch"));
+ std::locale::global(std::locale("C"));
+
+ test(L"NUL", std::wstring(L"\x00", 1));
+ test(L"alert", std::wstring(L"\x07"));
+ test(L"backspace", std::wstring(L"\x08"));
+ test(L"tab", std::wstring(L"\x09"));
+ test(L"carriage-return", std::wstring(L"\x0D"));
+ test(L"newline", std::wstring(L"\x0A"));
+ test(L"vertical-tab", std::wstring(L"\x0B"));
+ test(L"form-feed", std::wstring(L"\x0C"));
+ test(L"space", std::wstring(L" "));
+ test(L"exclamation-mark", std::wstring(L"!"));
+ test(L"quotation-mark", std::wstring(L"\""));
+ test(L"number-sign", std::wstring(L"#"));
+ test(L"dollar-sign", std::wstring(L"$"));
+ test(L"percent-sign", std::wstring(L"%"));
+ test(L"ampersand", std::wstring(L"&"));
+ test(L"apostrophe", std::wstring(L"\'"));
+ test(L"left-parenthesis", std::wstring(L"("));
+ test(L"right-parenthesis", std::wstring(L")"));
+ test(L"asterisk", std::wstring(L"*"));
+ test(L"plus-sign", std::wstring(L"+"));
+ test(L"comma", std::wstring(L","));
+ test(L"hyphen-minus", std::wstring(L"-"));
+ test(L"hyphen", std::wstring(L"-"));
+ test(L"full-stop", std::wstring(L"."));
+ test(L"period", std::wstring(L"."));
+ test(L"slash", std::wstring(L"/"));
+ test(L"solidus", std::wstring(L"/"));
+ test(L"zero", std::wstring(L"0"));
+ test(L"one", std::wstring(L"1"));
+ test(L"two", std::wstring(L"2"));
+ test(L"three", std::wstring(L"3"));
+ test(L"four", std::wstring(L"4"));
+ test(L"five", std::wstring(L"5"));
+ test(L"six", std::wstring(L"6"));
+ test(L"seven", std::wstring(L"7"));
+ test(L"eight", std::wstring(L"8"));
+ test(L"nine", std::wstring(L"9"));
+ test(L"colon", std::wstring(L":"));
+ test(L"semicolon", std::wstring(L";"));
+ test(L"less-than-sign", std::wstring(L"<"));
+ test(L"equals-sign", std::wstring(L"="));
+ test(L"greater-than-sign", std::wstring(L">"));
+ test(L"question-mark", std::wstring(L"?"));
+ test(L"commercial-at", std::wstring(L"@"));
+ for (wchar_t c = L'A'; c <= L'Z'; ++c)
+ {
+ const wchar_t a[2] = {c};
+ test(a, std::wstring(a));
+ }
+ test(L"left-square-bracket", std::wstring(L"["));
+ test(L"backslash", std::wstring(L"\\"));
+ test(L"reverse-solidus", std::wstring(L"\\"));
+ test(L"right-square-bracket", std::wstring(L"]"));
+ test(L"circumflex-accent", std::wstring(L"^"));
+ test(L"circumflex", std::wstring(L"^"));
+ test(L"low-line", std::wstring(L"_"));
+ test(L"underscore", std::wstring(L"_"));
+ test(L"grave-accent", std::wstring(L"`"));
+ for (wchar_t c = L'a'; c <= L'z'; ++c)
+ {
+ const wchar_t a[2] = {c};
+ test(a, std::wstring(a));
+ }
+ test(L"left-brace", std::wstring(L"{"));
+ test(L"left-curly-bracket", std::wstring(L"{"));
+ test(L"vertical-line", std::wstring(L"|"));
+ test(L"right-brace", std::wstring(L"}"));
+ test(L"right-curly-bracket", std::wstring(L"}"));
+ test(L"tilde", std::wstring(L"~"));
+
+ test(L"tild", std::wstring(L""));
+ test(L"ch", std::wstring(L""));
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ test(L"ch", std::wstring(L"ch"));
+ std::locale::global(std::locale("C"));
+}
diff --git a/libcxx/test/std/re/re.traits/transform.pass.cpp b/libcxx/test/std/re/re.traits/transform.pass.cpp
new file mode 100644
index 00000000000..c3bce7939fe
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/transform.pass.cpp
@@ -0,0 +1,44 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// template <class ForwardIterator>
+// string_type transform(ForwardIterator first, ForwardIterator last) const;
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+ const char a[] = "a";
+ const char B[] = "B";
+ typedef forward_iterator<const char*> F;
+ assert(t.transform(F(a), F(a+1)) > t.transform(F(B), F(B+1)));
+ t.imbue(std::locale("cs_CZ.ISO8859-2"));
+ assert(t.transform(F(a), F(a+1)) < t.transform(F(B), F(B+1)));
+ }
+ {
+ std::regex_traits<wchar_t> t;
+ const wchar_t a[] = L"a";
+ const wchar_t B[] = L"B";
+ typedef forward_iterator<const wchar_t*> F;
+ assert(t.transform(F(a), F(a+1)) > t.transform(F(B), F(B+1)));
+ t.imbue(std::locale("cs_CZ.ISO8859-2"));
+ assert(t.transform(F(a), F(a+1)) < t.transform(F(B), F(B+1)));
+ }
+}
diff --git a/libcxx/test/std/re/re.traits/transform_primary.pass.cpp b/libcxx/test/std/re/re.traits/transform_primary.pass.cpp
new file mode 100644
index 00000000000..28734d621ad
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/transform_primary.pass.cpp
@@ -0,0 +1,49 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// template <class ForwardIterator>
+// string_type
+// transform_primary(ForwardIterator first, ForwardIterator last) const;
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+ const char A[] = "A";
+ const char Aacute[] = "\xC1";
+ typedef forward_iterator<const char*> F;
+ assert(t.transform_primary(F(A), F(A+1)) !=
+ t.transform_primary(F(Aacute), F(Aacute+1)));
+ t.imbue(std::locale("cs_CZ.ISO8859-2"));
+ assert(t.transform_primary(F(A), F(A+1)) ==
+ t.transform_primary(F(Aacute), F(Aacute+1)));
+ }
+ {
+ std::regex_traits<wchar_t> t;
+ const wchar_t A[] = L"A";
+ const wchar_t Aacute[] = L"\xC1";
+ typedef forward_iterator<const wchar_t*> F;
+ assert(t.transform_primary(F(A), F(A+1)) !=
+ t.transform_primary(F(Aacute), F(Aacute+1)));
+ t.imbue(std::locale("cs_CZ.ISO8859-2"));
+ assert(t.transform_primary(F(A), F(A+1)) ==
+ t.transform_primary(F(Aacute), F(Aacute+1)));
+ }
+}
diff --git a/libcxx/test/std/re/re.traits/translate.pass.cpp b/libcxx/test/std/re/re.traits/translate.pass.cpp
new file mode 100644
index 00000000000..c3523387c56
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/translate.pass.cpp
@@ -0,0 +1,34 @@
+// -*- 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>
+
+// template <class charT> struct regex_traits;
+
+// charT translate(charT c) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+ assert(t.translate('a') == 'a');
+ assert(t.translate('B') == 'B');
+ assert(t.translate('c') == 'c');
+ }
+ {
+ std::regex_traits<wchar_t> t;
+ assert(t.translate(L'a') == L'a');
+ assert(t.translate(L'B') == L'B');
+ assert(t.translate(L'c') == L'c');
+ }
+}
diff --git a/libcxx/test/std/re/re.traits/translate_nocase.pass.cpp b/libcxx/test/std/re/re.traits/translate_nocase.pass.cpp
new file mode 100644
index 00000000000..0692e000d3f
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/translate_nocase.pass.cpp
@@ -0,0 +1,72 @@
+// -*- 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>
+
+// template <class charT> struct regex_traits;
+
+// charT translate_nocase(charT c) const;
+
+// REQUIRES: locale.en_US.UTF-8
+
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "platform_support.h"
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+ assert(t.translate_nocase(' ') == ' ');
+ assert(t.translate_nocase('A') == 'a');
+ assert(t.translate_nocase('\x07') == '\x07');
+ assert(t.translate_nocase('.') == '.');
+ assert(t.translate_nocase('a') == 'a');
+ assert(t.translate_nocase('1') == '1');
+ assert(t.translate_nocase('\xDA') == '\xDA');
+ assert(t.translate_nocase('\xFA') == '\xFA');
+ t.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(t.translate_nocase(' ') == ' ');
+ assert(t.translate_nocase('A') == 'a');
+ assert(t.translate_nocase('\x07') == '\x07');
+ assert(t.translate_nocase('.') == '.');
+ assert(t.translate_nocase('a') == 'a');
+ assert(t.translate_nocase('1') == '1');
+ assert(t.translate_nocase('\xDA') == '\xFA');
+ assert(t.translate_nocase('\xFA') == '\xFA');
+ }
+ {
+ std::regex_traits<wchar_t> t;
+ assert(t.translate_nocase(L' ') == L' ');
+ assert(t.translate_nocase(L'A') == L'a');
+ assert(t.translate_nocase(L'\x07') == L'\x07');
+ assert(t.translate_nocase(L'.') == L'.');
+ assert(t.translate_nocase(L'a') == L'a');
+ assert(t.translate_nocase(L'1') == L'1');
+ assert(t.translate_nocase(L'\xDA') == L'\xDA');
+ assert(t.translate_nocase(L'\xFA') == L'\xFA');
+ t.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(t.translate_nocase(L' ') == L' ');
+ assert(t.translate_nocase(L'A') == L'a');
+ assert(t.translate_nocase(L'\x07') == L'\x07');
+ assert(t.translate_nocase(L'.') == L'.');
+ assert(t.translate_nocase(L'a') == L'a');
+ assert(t.translate_nocase(L'1') == L'1');
+ assert(t.translate_nocase(L'\xDA') == L'\xFA');
+ assert(t.translate_nocase(L'\xFA') == L'\xFA');
+ }
+}
diff --git a/libcxx/test/std/re/re.traits/types.pass.cpp b/libcxx/test/std/re/re.traits/types.pass.cpp
new file mode 100644
index 00000000000..50586a1f29f
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/types.pass.cpp
@@ -0,0 +1,32 @@
+// -*- 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>
+
+// template <class charT>
+// struct regex_traits
+// {
+// public:
+// typedef charT char_type;
+// typedef basic_string<char_type> string_type;
+// typedef locale locale_type;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_traits<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::regex_traits<char>::string_type, std::string>::value), "");
+ static_assert((std::is_same<std::regex_traits<char>::locale_type, std::locale>::value), "");
+ static_assert((std::is_same<std::regex_traits<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::regex_traits<wchar_t>::string_type, std::wstring>::value), "");
+ static_assert((std::is_same<std::regex_traits<wchar_t>::locale_type, std::locale>::value), "");
+}
diff --git a/libcxx/test/std/re/re.traits/value.pass.cpp b/libcxx/test/std/re/re.traits/value.pass.cpp
new file mode 100644
index 00000000000..349a29cc6bc
--- /dev/null
+++ b/libcxx/test/std/re/re.traits/value.pass.cpp
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+// 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> struct regex_traits;
+
+// int value(charT ch, int radix) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+
+ for (char c = 0; c < '0'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (char c = '0'; c < '8'; ++c)
+ {
+ assert(t.value(c, 8) == c - '0');
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (char c = '8'; c < ':'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (char c = ':'; c < 'A'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (char c = 'A'; c < 'G'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'A' +10);
+ }
+ for (char c = 'G'; c < 'a'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (char c = 'a'; c < 'g'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'a' +10);
+ }
+ for (int c = 'g'; c < 256; ++c)
+ {
+ assert(t.value(char(c), 8) == -1);
+ assert(t.value(char(c), 10) == -1);
+ assert(t.value(char(c), 16) == -1);
+ }
+ }
+ {
+ std::regex_traits<wchar_t> t;
+
+ for (wchar_t c = 0; c < '0'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (wchar_t c = '0'; c < '8'; ++c)
+ {
+ assert(t.value(c, 8) == c - '0');
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (wchar_t c = '8'; c < ':'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (wchar_t c = ':'; c < 'A'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (wchar_t c = 'A'; c < 'G'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'A' +10);
+ }
+ for (wchar_t c = 'G'; c < 'a'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (wchar_t c = 'a'; c < 'g'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'a' +10);
+ }
+ for (int c = 'g'; c < 0xFFFF; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ }
+}
OpenPOWER on IntegriCloud