libcxx initial import

llvm-svn: 103490
diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..75237e7
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// void swap(basic_istringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream ss(" 789 321");
+        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);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream ss(L" 789 321");
+        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);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp
new file mode 100644
index 0000000..8ac3fda
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// basic_istringstream& operator=(basic_istringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream 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);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream 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);
+    }
+#endif
+}
diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..696dd5b
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// template <class charT, class traits, class Allocator> 
+//   void
+//   swap(basic_istringstream<charT, traits, Allocator>& x,
+//        basic_istringstream<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream ss(" 789 321");
+        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);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream ss(L" 789 321");
+        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);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp
new file mode 100644
index 0000000..83933f7
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// explicit basic_istringstream(ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::istringstream ss(std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::wistringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+    {
+        std::wistringstream ss(std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp
new file mode 100644
index 0000000..83d66bb
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// basic_istringstream(basic_istringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream 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);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream 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);
+    }
+#endif
+}
diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp
new file mode 100644
index 0000000..5ff47e6
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// explicit basic_istringstream(const basic_string<charT,traits,allocator>& str, 
+//                              ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream 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);
+    }
+    {
+        std::istringstream ss(" 123 456", std::ios_base::out);
+        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);
+    }
+    {
+        std::wistringstream 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);
+    }
+    {
+        std::wistringstream ss(L" 123 456", std::ios_base::out);
+        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);
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp
new file mode 100644
index 0000000..08b01d3
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream 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.str(" 789");
+        ss.clear();
+        assert(ss.good());
+        assert(ss.str() == " 789");
+        ss >> i;
+        assert(i == 789);
+    }
+    {
+        std::wistringstream 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.str(L" 789");
+        ss.clear();
+        assert(ss.good());
+        assert(ss.str() == L" 789");
+        ss >> i;
+        assert(i == 789);
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/istringstream/types.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/types.pass.cpp
new file mode 100644
index 0000000..8d88da9
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/istringstream/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+//     : public basic_istream<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_istream<char>, std::basic_istringstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..c2ab4f5
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp
new file mode 100644
index 0000000..664473d
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        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
+}
diff --git a/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..c978063
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp
new file mode 100644
index 0000000..96140bc
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp
new file mode 100644
index 0000000..799ea36
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        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
+}
diff --git a/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp
new file mode 100644
index 0000000..6707ae8
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp
new file mode 100644
index 0000000..0025da9
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/input.output/string.streams/ostringstream/types.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/types.pass.cpp
new file mode 100644
index 0000000..24fe1ff
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/ostringstream/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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), "");
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..0562cea
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// void swap(basic_stringbuf& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp
new file mode 100644
index 0000000..84a978f
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_stringbuf& operator=(basic_stringbuf&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == L"testing");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..451a838
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// template <class charT, class traits, class Allocator> 
+//   void swap(basic_stringbuf<charT, traits, Allocator>& x, 
+//             basic_stringbuf<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp
new file mode 100644
index 0000000..f8231ba
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf;
+        assert(buf.str() == "");
+    }
+    {
+        std::wstringbuf buf;
+        assert(buf.str() == L"");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp
new file mode 100644
index 0000000..bec0464
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_stringbuf(basic_stringbuf&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf(move(buf1));
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf(move(buf1));
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf(move(buf1));
+        assert(buf.str() == "testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf(move(buf1));
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf(move(buf1));
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf(move(buf1));
+        assert(buf.str() == L"testing");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp
new file mode 100644
index 0000000..53c0081
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// explicit basic_stringbuf(const basic_string<charT,traits,Allocator>& s, 
+//                          ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf("testing");
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf("testing", std::ios_base::in);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf("testing", std::ios_base::out);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::wstringbuf buf(L"testing");
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf(L"testing", std::ios_base::in);
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf(L"testing", std::ios_base::out);
+        assert(buf.str() == L"testing");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
new file mode 100644
index 0000000..601e5bc
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf("testing");
+        assert(buf.str() == "testing");
+        buf.str("another test");
+        assert(buf.str() == "another test");
+    }
+    {
+        std::wstringbuf buf(L"testing");
+        assert(buf.str() == L"testing");
+        buf.str(L"another test");
+        assert(buf.str() == L"another test");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp
new file mode 100644
index 0000000..048f05d
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type overflow(int_type c = traits::eof());
+
+#include <sstream>
+#include <cassert>
+
+int overflow_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_stringbuf<CharT>
+{
+    typedef std::basic_stringbuf<CharT> base;
+    explicit testbuf(const std::basic_string<CharT>& str,
+                     std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
+        : base(str, which) {}
+
+    typename base::int_type
+        overflow(typename base::int_type c = base::type_traits::eof())
+        {++overflow_called; return base::overflow(c);}
+
+    void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("abc");
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == "1bc");
+        assert(sb.sputc('2') == '2');
+        assert(sb.str() == "12c");
+        assert(sb.sputc('3') == '3');
+        assert(sb.str() == "123");
+        assert(sb.sputc('4') == '4');
+        assert(sb.str() == "1234");
+        assert(sb.sputc('5') == '5');
+        assert(sb.str() == "12345");
+        assert(sb.sputc('6') == '6');
+        assert(sb.str() == "123456");
+        assert(sb.sputc('7') == '7');
+        assert(sb.str() == "1234567");
+        assert(sb.sputc('8') == '8');
+        assert(sb.str() == "12345678");
+        assert(sb.sputc('9') == '9');
+        assert(sb.str() == "123456789");
+        assert(sb.sputc('0') == '0');
+        assert(sb.str() == "1234567890");
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == "12345678901");
+    }
+    {
+        testbuf<wchar_t> sb(L"abc");
+        assert(sb.sputc(L'1') == L'1');
+        assert(sb.str() == L"1bc");
+        assert(sb.sputc(L'2') == L'2');
+        assert(sb.str() == L"12c");
+        assert(sb.sputc(L'3') == L'3');
+        assert(sb.str() == L"123");
+        assert(sb.sputc(L'4') == L'4');
+        assert(sb.str() == L"1234");
+        assert(sb.sputc(L'5') == L'5');
+        assert(sb.str() == L"12345");
+        assert(sb.sputc(L'6') == L'6');
+        assert(sb.str() == L"123456");
+        assert(sb.sputc(L'7') == L'7');
+        assert(sb.str() == L"1234567");
+        assert(sb.sputc(L'8') == L'8');
+        assert(sb.str() == L"12345678");
+        assert(sb.sputc(L'9') == L'9');
+        assert(sb.str() == L"123456789");
+        assert(sb.sputc(L'0') == L'0');
+        assert(sb.str() == L"1234567890");
+        assert(sb.sputc(L'1') == L'1');
+        assert(sb.str() == L"12345678901");
+    }
+    {
+        testbuf<char> sb("abc", std::ios_base::app | std::ios_base::out);
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == "abc1");
+        assert(sb.sputc('2') == '2');
+        assert(sb.str() == "abc12");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp
new file mode 100644
index 0000000..0f85c0c
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type pbackfail(int_type c = traits::eof());
+
+#include <sstream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_stringbuf<CharT>
+{
+    typedef std::basic_stringbuf<CharT> base;
+    explicit testbuf(const std::basic_string<CharT>& str,
+                     std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
+        : base(str, which) {}
+
+    typename base::int_type
+        pbackfail(typename base::int_type c = base::type_traits::eof())
+        {return base::pbackfail(c);}
+
+    void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("123", std::ios_base::in);
+        assert(sb.sgetc() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.sgetc() == '3');
+        assert(sb.snextc() == std::char_traits<char>::eof());
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail('3') == std::char_traits<char>::eof());
+        assert(sb.pbackfail('2') == '2');
+        assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof());
+        assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof());
+        assert(sb.str() == "123");
+    }
+    {
+        testbuf<char> sb("123");
+        assert(sb.sgetc() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.sgetc() == '3');
+        assert(sb.snextc() == std::char_traits<char>::eof());
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof());
+        assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof());
+        assert(sb.str() == "133");
+    }
+    {
+        testbuf<wchar_t> sb(L"123", std::ios_base::in);
+        assert(sb.sgetc() == L'1');
+        assert(sb.snextc() == L'2');
+        assert(sb.snextc() == L'3');
+        assert(sb.sgetc() == L'3');
+        assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(L'3') == L'3');
+        assert(sb.pbackfail(L'3') == std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(L'2') == L'2');
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof());
+        assert(sb.str() == L"123");
+    }
+    {
+        testbuf<wchar_t> sb(L"123");
+        assert(sb.sgetc() == L'1');
+        assert(sb.snextc() == L'2');
+        assert(sb.snextc() == L'3');
+        assert(sb.sgetc() == L'3');
+        assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(L'3') == L'3');
+        assert(sb.pbackfail(L'3') == L'3');
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof());
+        assert(sb.str() == L"133");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
new file mode 100644
index 0000000..43cc9e0
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// pos_type seekoff(off_type off, ios_base::seekdir way, 
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf sb("0123456789", std::ios_base::in);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == '6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == '7');
+    }
+    {
+        std::stringbuf sb("0123456789", std::ios_base::out);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc('b') == 'b');
+        assert(sb.str() == "012a456b89");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc('c') == 'c');
+        assert(sb.str() == "012a456c89");
+    }
+    {
+        std::stringbuf sb("0123456789");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == '6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == '7');
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
+        assert(sb.sgetc() == '7');
+        assert(sb.sputc('c') == 'c');
+        assert(sb.str() == "012a456c89");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc('3') == '3');
+        assert(sb.str() == "0123456c89");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc('7') == '7');
+        assert(sb.str() == "0123456789");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc('c') == 'c');
+        assert(sb.str() == "0123456c89");
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::in);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == L'6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == L'7');
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::out);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc(L'b') == L'b');
+        assert(sb.str() == L"012a456b89");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc(L'c') == L'c');
+        assert(sb.str() == L"012a456c89");
+    }
+    {
+        std::wstringbuf sb(L"0123456789");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == L'6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == L'7');
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
+        assert(sb.sgetc() == L'7');
+        assert(sb.sputc(L'c') == L'c');
+        assert(sb.str() == L"012a456c89");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc(L'3') == L'3');
+        assert(sb.str() == L"0123456c89");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc(L'7') == L'7');
+        assert(sb.str() == L"0123456789");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc(L'c') == L'c');
+        assert(sb.str() == L"0123456c89");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
new file mode 100644
index 0000000..6e2d832
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// pos_type seekpos(pos_type sp,
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf sb("0123456789", std::ios_base::in);
+        assert(sb.pubseekpos(3, std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+    }
+    {
+        std::stringbuf sb("0123456789", std::ios_base::out);
+        assert(sb.pubseekpos(3, std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+    }
+    {
+        std::stringbuf sb("0123456789");
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc('3') == '3');
+        assert(sb.str() == "0123456789");
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::in);
+        assert(sb.pubseekpos(3, std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::out);
+        assert(sb.pubseekpos(3, std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+    }
+    {
+        std::wstringbuf sb(L"0123456789");
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc(L'3') == L'3');
+        assert(sb.str() == L"0123456789");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp
new file mode 100644
index 0000000..184e759
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_streambuf<charT,traits>* setbuf(charT* s, streamsize n);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf sb("0123456789");
+        assert(sb.pubsetbuf(0, 0) == &sb);
+        assert(sb.str() == "0123456789");
+    }
+    {
+        std::wstringbuf sb(L"0123456789");
+        assert(sb.pubsetbuf(0, 0) == &sb);
+        assert(sb.str() == L"0123456789");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp
new file mode 100644
index 0000000..1f5b91e
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type underflow();
+
+#include <sstream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_stringbuf<CharT>
+{
+    typedef std::basic_stringbuf<CharT> base;
+    explicit testbuf(const std::basic_string<CharT>& str)
+        : base(str) {}
+
+    typename base::int_type underflow() {return base::underflow();}
+    void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("123");
+        sb.pbump(3);
+        assert(sb.underflow() == '1');
+        assert(sb.underflow() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.underflow() == '2');
+        assert(sb.underflow() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.underflow() == '3');
+        assert(sb.underflow() == '3');
+        assert(sb.snextc() == std::char_traits<char>::eof());
+        assert(sb.underflow() == std::char_traits<char>::eof());
+        assert(sb.underflow() == std::char_traits<char>::eof());
+        sb.sputc('4');
+        assert(sb.underflow() == '4');
+        assert(sb.underflow() == '4');
+    }
+    {
+        testbuf<wchar_t> sb(L"123");
+        sb.pbump(3);
+        assert(sb.underflow() == L'1');
+        assert(sb.underflow() == L'1');
+        assert(sb.snextc() == L'2');
+        assert(sb.underflow() == L'2');
+        assert(sb.underflow() == L'2');
+        assert(sb.snextc() == L'3');
+        assert(sb.underflow() == L'3');
+        assert(sb.underflow() == L'3');
+        assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+        assert(sb.underflow() == std::char_traits<wchar_t>::eof());
+        assert(sb.underflow() == std::char_traits<wchar_t>::eof());
+        sb.sputc(L'4');
+        assert(sb.underflow() == L'4');
+        assert(sb.underflow() == L'4');
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringbuf/types.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/types.pass.cpp
new file mode 100644
index 0000000..84930d6
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringbuf/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+//     : public basic_streambuf<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_streambuf<char>, std::basic_stringbuf<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::off_type, std::char_traits<char>::off_type>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/libcxx/test/input.output/string.streams/stringstream.cons/default.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/default.pass.cpp
new file mode 100644
index 0000000..e8c7325
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringstream.cons/default.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/input.output/string.streams/stringstream.cons/move.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/move.pass.cpp
new file mode 100644
index 0000000..da68210
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringstream.cons/move.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        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
+}
diff --git a/libcxx/test/input.output/string.streams/stringstream.cons/string.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/string.pass.cpp
new file mode 100644
index 0000000..e1e7f63
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringstream.cons/string.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <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/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..6517d20
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp
new file mode 100644
index 0000000..cffc430
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        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
+}
diff --git a/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..f5ee292
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringstream.members/str.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.members/str.pass.cpp
new file mode 100644
index 0000000..1352d0f
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringstream.members/str.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// void str(const basic_string<charT,traits,Allocator>& str);
+
+#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 ");
+        ss.str("5466 89 ");
+        ss >> i;
+        assert(i == 5466);
+        ss >> i;
+        assert(i == 89);
+        ss << i << ' ' << 321;
+        assert(ss.str() == "89 3219 ");
+    }
+    {
+        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 ");
+        ss.str(L"5466 89 ");
+        ss >> i;
+        assert(i == 5466);
+        ss >> i;
+        assert(i == 89);
+        ss << i << ' ' << 321;
+        assert(ss.str() == L"89 3219 ");
+    }
+}
diff --git a/libcxx/test/input.output/string.streams/stringstream/types.pass.cpp b/libcxx/test/input.output/string.streams/stringstream/types.pass.cpp
new file mode 100644
index 0000000..0b64c24
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/stringstream/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+//     : public basic_iostream<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_iostream<char>, std::basic_stringstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/libcxx/test/input.output/string.streams/version.pass.cpp b/libcxx/test/input.output/string.streams/version.pass.cpp
new file mode 100644
index 0000000..0567394
--- /dev/null
+++ b/libcxx/test/input.output/string.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+#include <sstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}