summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-06-29 18:37:43 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-06-29 18:37:43 +0000
commite5561b04e49023adbc330fbf3b1c94fd07deab92 (patch)
treee555b769199d656af3b98b4a20bfee289e73ad4c /libcxx/test
parent99e13101b2bd7500919c368504c99dbd08b6a8e9 (diff)
downloadbcm5719-llvm-e5561b04e49023adbc330fbf3b1c94fd07deab92.tar.gz
bcm5719-llvm-e5561b04e49023adbc330fbf3b1c94fd07deab92.zip
[re.submatch]
llvm-svn: 107187
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp2
-rw-r--r--libcxx/test/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp49
-rw-r--r--libcxx/test/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp53
-rw-r--r--libcxx/test/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp47
-rw-r--r--libcxx/test/re/re.submatch/re.submatch.members/length.pass.cpp43
-rw-r--r--libcxx/test/re/re.submatch/re.submatch.members/operator_string.pass.cpp47
-rw-r--r--libcxx/test/re/re.submatch/re.submatch.members/str.pass.cpp47
-rw-r--r--libcxx/test/re/re.submatch/re.submatch.op/compare.pass.cpp283
-rw-r--r--libcxx/test/re/re.submatch/re.submatch.op/stream.pass.cpp42
-rw-r--r--libcxx/test/re/re.submatch/types.pass.cpp64
10 files changed, 677 insertions, 0 deletions
diff --git a/libcxx/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp b/libcxx/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
index 060fb20edb4..f2d7c814307 100644
--- a/libcxx/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
+++ b/libcxx/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
@@ -13,6 +13,8 @@
// basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
+#include <iostream>
+
#include <regex>
#include <cassert>
diff --git a/libcxx/test/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp b/libcxx/test/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp
new file mode 100644
index 00000000000..a2538a66bbe
--- /dev/null
+++ b/libcxx/test/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp b/libcxx/test/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp
new file mode 100644
index 00000000000..5eb962fcab5
--- /dev/null
+++ b/libcxx/test/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp b/libcxx/test/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp
new file mode 100644
index 00000000000..72e8eb3f818
--- /dev/null
+++ b/libcxx/test/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/re/re.submatch/re.submatch.members/length.pass.cpp b/libcxx/test/re/re.submatch/re.submatch.members/length.pass.cpp
new file mode 100644
index 00000000000..42b645e2e52
--- /dev/null
+++ b/libcxx/test/re/re.submatch/re.submatch.members/length.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/re/re.submatch/re.submatch.members/operator_string.pass.cpp b/libcxx/test/re/re.submatch/re.submatch.members/operator_string.pass.cpp
new file mode 100644
index 00000000000..a41ba108ad7
--- /dev/null
+++ b/libcxx/test/re/re.submatch/re.submatch.members/operator_string.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/re/re.submatch/re.submatch.members/str.pass.cpp b/libcxx/test/re/re.submatch/re.submatch.members/str.pass.cpp
new file mode 100644
index 00000000000..ffa7cfbdbc3
--- /dev/null
+++ b/libcxx/test/re/re.submatch/re.submatch.members/str.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/re/re.submatch/re.submatch.op/compare.pass.cpp b/libcxx/test/re/re.submatch/re.submatch.op/compare.pass.cpp
new file mode 100644
index 00000000000..404a6c0858c
--- /dev/null
+++ b/libcxx/test/re/re.submatch/re.submatch.op/compare.pass.cpp
@@ -0,0 +1,283 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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)
+{
+ 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));
+ 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"));
+}
diff --git a/libcxx/test/re/re.submatch/re.submatch.op/stream.pass.cpp b/libcxx/test/re/re.submatch/re.submatch.op/stream.pass.cpp
new file mode 100644
index 00000000000..5f4d705a78f
--- /dev/null
+++ b/libcxx/test/re/re.submatch/re.submatch.op/stream.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/re/re.submatch/types.pass.cpp b/libcxx/test/re/re.submatch/types.pass.cpp
new file mode 100644
index 00000000000..358380bae05
--- /dev/null
+++ b/libcxx/test/re/re.submatch/types.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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), "");
+ }
+}
OpenPOWER on IntegriCloud