summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/input.output/string.streams/ostringstream
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/input.output/string.streams/ostringstream')
-rw-r--r--libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp48
-rw-r--r--libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp46
-rw-r--r--libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp48
-rw-r--r--libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp46
-rw-r--r--libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp44
-rw-r--r--libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp59
-rw-r--r--libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp52
-rw-r--r--libcxx/test/std/input.output/string.streams/ostringstream/types.pass.cpp36
8 files changed, 379 insertions, 0 deletions
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp
new file mode 100644
index 00000000000..eff47452c58
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_ostringstream
+
+// void swap(basic_ostringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream ss0(" 123 456");
+ std::ostringstream ss;
+ ss.swap(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ ss0 << i << ' ' << 567;;
+ assert(ss0.str() == "234 567");
+ }
+ {
+ std::wostringstream ss0(L" 123 456");
+ std::wostringstream ss;
+ ss.swap(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ ss0 << i << ' ' << 567;;
+ assert(ss0.str() == L"234 567");
+ }
+}
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp
new file mode 100644
index 00000000000..a6fb8ba69b2
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/move.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_ostringstream
+
+// basic_ostringstream& operator=(basic_ostringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::ostringstream ss0(" 123 456");
+ std::ostringstream ss;
+ ss = std::move(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ }
+ {
+ std::wostringstream ss0(L" 123 456");
+ std::wostringstream ss;
+ ss = std::move(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 00000000000..3d7081d8e24
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_ostringstream
+
+// void swap(basic_ostringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream ss0(" 123 456");
+ std::ostringstream ss;
+ swap(ss, ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ ss0 << i << ' ' << 567;;
+ assert(ss0.str() == "234 567");
+ }
+ {
+ std::wostringstream ss0(L" 123 456");
+ std::wostringstream ss;
+ swap(ss, ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ ss0 << i << ' ' << 567;;
+ assert(ss0.str() == L"234 567");
+ }
+}
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp
new file mode 100644
index 00000000000..dde1dc71923
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.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_ostringstream
+
+// explicit basic_ostringstream(ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream ss;
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == "");
+ }
+ {
+ std::ostringstream ss(std::ios_base::out);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == "");
+ }
+ {
+ std::wostringstream ss;
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L"");
+ }
+ {
+ std::wostringstream ss(std::ios_base::out);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L"");
+ }
+}
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp
new file mode 100644
index 00000000000..dc63b59fe39
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// basic_ostringstream(basic_ostringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::ostringstream ss0(" 123 456");
+ std::ostringstream ss(std::move(ss0));
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ }
+ {
+ std::wostringstream ss0(L" 123 456");
+ std::wostringstream ss(std::move(ss0));
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp
new file mode 100644
index 00000000000..89c91bdee05
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string.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_ostringstream
+
+// explicit basic_ostringstream(const basic_string<charT,traits,allocator>& str,
+// ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream ss(" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ }
+ {
+ std::ostringstream ss(" 123 456", std::ios_base::in);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ }
+ {
+ std::wostringstream ss(L" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ }
+ {
+ std::wostringstream ss(L" 123 456", std::ios_base::in);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ }
+}
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp
new file mode 100644
index 00000000000..ab277a2eeac
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.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_ostringstream
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream ss(" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 0;
+ ss << i;
+ assert(ss.str() == "0123 456");
+ ss << 456;
+ assert(ss.str() == "0456 456");
+ ss.str(" 789");
+ assert(ss.str() == " 789");
+ ss << "abc";
+ assert(ss.str() == "abc9");
+ }
+ {
+ std::wostringstream ss(L" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 0;
+ ss << i;
+ assert(ss.str() == L"0123 456");
+ ss << 456;
+ assert(ss.str() == L"0456 456");
+ ss.str(L" 789");
+ assert(ss.str() == L" 789");
+ ss << L"abc";
+ assert(ss.str() == L"abc9");
+ }
+}
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/types.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/types.pass.cpp
new file mode 100644
index 00000000000..c9cb763784e
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+// : public basic_ostream<charT, traits>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+// typedef Allocator allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_ostringstream<char> >::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
OpenPOWER on IntegriCloud