summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/re/re.submatch/re.submatch.members/str.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/re/re.submatch/re.submatch.members/str.pass.cpp')
-rw-r--r--libcxx/test/std/re/re.submatch/re.submatch.members/str.pass.cpp47
1 files changed, 47 insertions, 0 deletions
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"));
+ }
+}
OpenPOWER on IntegriCloud