summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/input.output/string.streams/stringstream.cons
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/input.output/string.streams/stringstream.cons')
-rw-r--r--libcxx/test/std/input.output/string.streams/stringstream.cons/default.pass.cpp46
-rw-r--r--libcxx/test/std/input.output/string.streams/stringstream.cons/move.pass.cpp52
-rw-r--r--libcxx/test/std/input.output/string.streams/stringstream.cons/move2.pass.cpp37
-rw-r--r--libcxx/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp49
-rw-r--r--libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp56
-rw-r--r--libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp54
-rw-r--r--libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp59
7 files changed, 353 insertions, 0 deletions
diff --git a/libcxx/test/std/input.output/string.streams/stringstream.cons/default.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream.cons/default.pass.cpp
new file mode 100644
index 00000000000..b8905ade340
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringstream.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringstream ss;
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == "");
+ }
+ {
+ std::stringstream ss(std::ios_base::in);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == "");
+ }
+ {
+ std::wstringstream ss;
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L"");
+ }
+ {
+ std::wstringstream ss(std::ios_base::in);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L"");
+ }
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringstream.cons/move.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream.cons/move.pass.cpp
new file mode 100644
index 00000000000..4ae3aa6e84d
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringstream.cons/move.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// basic_stringstream(basic_stringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::stringstream ss0(" 123 456 ");
+ std::stringstream ss(std::move(ss0));
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == "456 1236 ");
+ }
+ {
+ std::wstringstream ss0(L" 123 456 ");
+ std::wstringstream ss(std::move(ss0));
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == L"456 1236 ");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringstream.cons/move2.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream.cons/move2.pass.cpp
new file mode 100644
index 00000000000..856cf3cbeaf
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringstream.cons/move2.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// basic_stringstream(basic_stringstream&& rhs);
+
+#include <sstream>
+#include <vector>
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::vector<std::istringstream> vecis;
+ vecis.push_back(std::istringstream());
+ vecis.back().str("hub started at [00 6b 8b 45 69]");
+ vecis.push_back(std::istringstream());
+ vecis.back().str("hub started at [00 6b 8b 45 69]");
+ for (int n = 0; n < vecis.size(); n++)
+ {
+ assert(vecis[n].str().size() == 31);
+ vecis[n].seekg(0, std::ios_base::beg);
+ assert(vecis[n].str().size() == 31);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
new file mode 100644
index 00000000000..3776f17f530
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringstream.cons/string.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// explicit basic_stringstream(const basic_string<charT,traits,Allocator>& str,
+// ios_base::openmode which = ios_base::out|ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringstream ss(" 123 456 ");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == "456 1236 ");
+ }
+ {
+ std::wstringstream ss(L" 123 456 ");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == L"456 1236 ");
+ }
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp
new file mode 100644
index 00000000000..95599dd254e
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// void swap(basic_stringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringstream ss0(" 123 456 ");
+ std::stringstream ss;
+ ss.swap(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == "456 1236 ");
+ ss0 << i << ' ' << 123;
+ assert(ss0.str() == "456 123");
+ }
+ {
+ std::wstringstream ss0(L" 123 456 ");
+ std::wstringstream ss;
+ ss.swap(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == L"456 1236 ");
+ ss0 << i << ' ' << 123;
+ assert(ss0.str() == L"456 123");
+ }
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp
new file mode 100644
index 00000000000..ccaf72d7e55
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// basic_stringstream& operator=(basic_stringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::stringstream ss0(" 123 456 ");
+ std::stringstream ss;
+ ss = std::move(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == "456 1236 ");
+ }
+ {
+ std::wstringstream ss0(L" 123 456 ");
+ std::wstringstream ss;
+ ss = std::move(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == L"456 1236 ");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 00000000000..3ec11cd9e30
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// template <class charT, class traits, class Allocator>
+// void
+// swap(basic_stringstream<charT, traits, Allocator>& x,
+// basic_stringstream<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringstream ss0(" 123 456 ");
+ std::stringstream ss;
+ swap(ss, ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == "456 1236 ");
+ ss0 << i << ' ' << 123;
+ assert(ss0.str() == "456 123");
+ }
+ {
+ std::wstringstream ss0(L" 123 456 ");
+ std::wstringstream ss;
+ swap(ss, ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == L"456 1236 ");
+ ss0 << i << ' ' << 123;
+ assert(ss0.str() == L"456 123");
+ }
+}
OpenPOWER on IntegriCloud