summaryrefslogtreecommitdiff
path: root/libcxx/test/libcxx-03/input.output
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/libcxx-03/input.output')
-rw-r--r--libcxx/test/libcxx-03/input.output/file.streams/fstreams/filebuf/traits_mismatch.verify.cpp22
-rw-r--r--libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.close.pass.cpp38
-rw-r--r--libcxx/test/libcxx-03/input.output/file.streams/fstreams/traits_mismatch.verify.cpp29
-rw-r--r--libcxx/test/libcxx-03/input.output/file.streams/lit.local.cfg7
-rw-r--r--libcxx/test/libcxx-03/input.output/iostream.format/input.streams/traits_mismatch.verify.cpp25
-rw-r--r--libcxx/test/libcxx-03/input.output/iostream.format/lit.local.cfg7
-rw-r--r--libcxx/test/libcxx-03/input.output/iostream.format/output.streams/traits_mismatch.verify.cpp25
-rw-r--r--libcxx/test/libcxx-03/input.output/iostream.objects/lit.local.cfg7
-rw-r--r--libcxx/test/libcxx-03/input.output/iostreams.base/ios.base/ios.base.cons/dtor.uninitialized.pass.cpp83
-rw-r--r--libcxx/test/libcxx-03/input.output/iostreams.base/ios/iostate.flags/clear.abort.pass.cpp43
-rw-r--r--libcxx/test/libcxx-03/input.output/iostreams.base/lit.local.cfg7
-rw-r--r--libcxx/test/libcxx-03/input.output/stream.buffers/lit.local.cfg7
-rw-r--r--libcxx/test/libcxx-03/input.output/string.streams/lit.local.cfg7
-rw-r--r--libcxx/test/libcxx-03/input.output/string.streams/stringbuf/const_sso_buffer.pass.cpp171
-rw-r--r--libcxx/test/libcxx-03/input.output/string.streams/traits_mismatch.verify.cpp25
15 files changed, 503 insertions, 0 deletions
diff --git a/libcxx/test/libcxx-03/input.output/file.streams/fstreams/filebuf/traits_mismatch.verify.cpp b/libcxx/test/libcxx-03/input.output/file.streams/fstreams/filebuf/traits_mismatch.verify.cpp
new file mode 100644
index 000000000000..455c9979ae57
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/file.streams/fstreams/filebuf/traits_mismatch.verify.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template<class charT, class traits = char_traits<charT>>
+// class basic_filebuf;
+//
+// The char type of the stream and the char_type of the traits have to match
+
+// UNSUPPORTED: no-wide-characters
+
+#include <fstream>
+
+std::basic_filebuf<char, std::char_traits<wchar_t> > f;
+// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
+// expected-error@*:* 9 {{only virtual member functions can be marked 'override'}}
diff --git a/libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.close.pass.cpp b/libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.close.pass.cpp
new file mode 100644
index 000000000000..d77d5370f2c4
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.close.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// close();
+
+// Inspired by PR#38052 - std::fstream still good after closing and updating content
+
+#include <fstream>
+#include <cassert>
+#include "test_macros.h"
+#include "platform_support.h"
+
+int main(int, char**)
+{
+ std::string temp = get_temp_file_name();
+
+ std::fstream ofs(temp, std::ios::out | std::ios::trunc);
+ ofs << "Hello, World!\n";
+ assert( ofs.good());
+ ofs.close();
+ assert( ofs.good());
+ ofs << "Hello, World!\n";
+ assert(!ofs.good());
+
+ std::remove(temp.c_str());
+
+ return 0;
+}
diff --git a/libcxx/test/libcxx-03/input.output/file.streams/fstreams/traits_mismatch.verify.cpp b/libcxx/test/libcxx-03/input.output/file.streams/fstreams/traits_mismatch.verify.cpp
new file mode 100644
index 000000000000..cc52cc119d50
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/file.streams/fstreams/traits_mismatch.verify.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// The char type of the stream and the char_type of the traits have to match
+
+// UNSUPPORTED: no-wide-characters
+
+#include <fstream>
+
+std::basic_fstream<char, std::char_traits<wchar_t> > f;
+// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
+// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
+
+// expected-error@*:* 11 {{only virtual member functions can be marked 'override'}}
+
+// FIXME: As of commit r324062 Clang incorrectly generates a diagnostic about mismatching
+// exception specifications for types which are already invalid for one reason or another.
+// For now we tolerate this diagnostic.
+// expected-error@*:* 0-1 {{exception specification of overriding function is more lax than base version}}
diff --git a/libcxx/test/libcxx-03/input.output/file.streams/lit.local.cfg b/libcxx/test/libcxx-03/input.output/file.streams/lit.local.cfg
new file mode 100644
index 000000000000..ac628161afe7
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/file.streams/lit.local.cfg
@@ -0,0 +1,7 @@
+# Load the same local configuration as the corresponding one in libcxx/test/std
+import os
+
+inLibcxx = os.path.join("libcxx", "test", "libcxx-03")
+inStd = os.path.join("libcxx", "test", "std")
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
+config.load_from_path(localConfig, lit_config)
diff --git a/libcxx/test/libcxx-03/input.output/iostream.format/input.streams/traits_mismatch.verify.cpp b/libcxx/test/libcxx-03/input.output/iostream.format/input.streams/traits_mismatch.verify.cpp
new file mode 100644
index 000000000000..a03aed123c03
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/iostream.format/input.streams/traits_mismatch.verify.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// The char type of the stream and the char_type of the traits have to match
+
+// UNSUPPORTED: no-wide-characters
+
+#include <istream>
+#include <string>
+
+struct test_istream
+ : public std::basic_istream<char, std::char_traits<wchar_t> > {};
+
+// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
+// expected-error@*:* {{only virtual member functions can be marked 'override'}}
diff --git a/libcxx/test/libcxx-03/input.output/iostream.format/lit.local.cfg b/libcxx/test/libcxx-03/input.output/iostream.format/lit.local.cfg
new file mode 100644
index 000000000000..ac628161afe7
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/iostream.format/lit.local.cfg
@@ -0,0 +1,7 @@
+# Load the same local configuration as the corresponding one in libcxx/test/std
+import os
+
+inLibcxx = os.path.join("libcxx", "test", "libcxx-03")
+inStd = os.path.join("libcxx", "test", "std")
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
+config.load_from_path(localConfig, lit_config)
diff --git a/libcxx/test/libcxx-03/input.output/iostream.format/output.streams/traits_mismatch.verify.cpp b/libcxx/test/libcxx-03/input.output/iostream.format/output.streams/traits_mismatch.verify.cpp
new file mode 100644
index 000000000000..9e7bc998eb91
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/iostream.format/output.streams/traits_mismatch.verify.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// The char type of the stream and the char_type of the traits have to match
+
+// UNSUPPORTED: no-wide-characters
+
+#include <ostream>
+#include <string>
+
+struct test_ostream
+ : public std::basic_ostream<char, std::char_traits<wchar_t> > {};
+
+// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
+// expected-error@*:* {{only virtual member functions can be marked 'override'}}
diff --git a/libcxx/test/libcxx-03/input.output/iostream.objects/lit.local.cfg b/libcxx/test/libcxx-03/input.output/iostream.objects/lit.local.cfg
new file mode 100644
index 000000000000..ac628161afe7
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/iostream.objects/lit.local.cfg
@@ -0,0 +1,7 @@
+# Load the same local configuration as the corresponding one in libcxx/test/std
+import os
+
+inLibcxx = os.path.join("libcxx", "test", "libcxx-03")
+inStd = os.path.join("libcxx", "test", "std")
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
+config.load_from_path(localConfig, lit_config)
diff --git a/libcxx/test/libcxx-03/input.output/iostreams.base/ios.base/ios.base.cons/dtor.uninitialized.pass.cpp b/libcxx/test/libcxx-03/input.output/iostreams.base/ios.base/ios.base.cons/dtor.uninitialized.pass.cpp
new file mode 100644
index 000000000000..c04250987e8e
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/iostreams.base/ios.base/ios.base.cons/dtor.uninitialized.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// TODO(mordante) Investigate
+// UNSUPPORTED: apple-clang
+
+// UNSUPPORTED: no-exceptions
+
+// The fix for issue 57964 requires an updated dylib due to explicit
+// instantiations. That means Apple backdeployment targets remain broken.
+// XFAIL using-built-library-before-llvm-19
+
+// <ios>
+
+// class ios_base
+
+// ~ios_base()
+//
+// Destroying a constructed ios_base object that has not been
+// initialized by basic_ios::init is undefined behaviour. This can
+// happen in practice, make sure the undefined behaviour is handled
+// gracefully.
+//
+//
+// [ios.base.cons]/1
+//
+// ios_base();
+// Effects: Each ios_base member has an indeterminate value after construction.
+// The object's members shall be initialized by calling basic_ios::init before
+// the object's first use or before it is destroyed, whichever comes first;
+// otherwise the behavior is undefined.
+//
+// [basic.ios.cons]/2
+//
+// basic_ios();
+// Effects: Leaves its member objects uninitialized. The object shall be
+// initialized by calling basic_ios::init before its first use or before it is
+// destroyed, whichever comes first; otherwise the behavior is undefined.
+//
+// ostream and friends have a basic_ios virtual base.
+// [class.base.init]/13
+// In a non-delegating constructor, initialization proceeds in the
+// following order:
+// - First, and only for the constructor of the most derived class
+// ([intro.object]), virtual base classes are initialized ...
+//
+// So in this example
+// struct Foo : AlwaysThrows, std::ostream {
+// Foo() : AlwaysThrows{}, std::ostream{nullptr} {}
+// };
+//
+// Here
+// - the ios_base object is constructed
+// - the AlwaysThrows object is constructed and throws an exception
+// - the AlwaysThrows object is destrodyed
+// - the ios_base object is destroyed
+//
+// The ios_base object is destroyed before it has been initialized and runs
+// into undefined behavior. By using __loc_ as a sentinel we can avoid
+// accessing uninitialized memory in the destructor.
+
+#include <ostream>
+
+struct AlwaysThrows {
+ AlwaysThrows() { throw 1; }
+};
+
+struct Foo : AlwaysThrows, std::ostream {
+ Foo() : AlwaysThrows(), std::ostream(nullptr) {}
+};
+
+int main(int, char**) {
+ try {
+ Foo foo;
+ } catch (...) {
+ };
+ return 0;
+}
diff --git a/libcxx/test/libcxx-03/input.output/iostreams.base/ios/iostate.flags/clear.abort.pass.cpp b/libcxx/test/libcxx-03/input.output/iostreams.base/ios/iostate.flags/clear.abort.pass.cpp
new file mode 100644
index 000000000000..8f0f5a6d78b1
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/iostreams.base/ios/iostate.flags/clear.abort.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void clear(iostate state);
+
+// Make sure that we abort() when exceptions are disabled and the exception
+// flag is set for the iostate we pass to clear().
+
+// REQUIRES: no-exceptions
+
+#include <csignal>
+#include <cstdlib>
+#include <ios>
+#include <streambuf>
+
+#include "test_macros.h"
+
+
+void exit_success(int) {
+ std::_Exit(EXIT_SUCCESS);
+}
+
+struct testbuf : public std::streambuf {};
+
+int main(int, char**) {
+ std::signal(SIGABRT, exit_success);
+
+ testbuf buf;
+ std::ios ios(&buf);
+ ios.exceptions(std::ios::badbit);
+ ios.clear(std::ios::badbit);
+
+ return EXIT_FAILURE;
+}
diff --git a/libcxx/test/libcxx-03/input.output/iostreams.base/lit.local.cfg b/libcxx/test/libcxx-03/input.output/iostreams.base/lit.local.cfg
new file mode 100644
index 000000000000..ac628161afe7
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/iostreams.base/lit.local.cfg
@@ -0,0 +1,7 @@
+# Load the same local configuration as the corresponding one in libcxx/test/std
+import os
+
+inLibcxx = os.path.join("libcxx", "test", "libcxx-03")
+inStd = os.path.join("libcxx", "test", "std")
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
+config.load_from_path(localConfig, lit_config)
diff --git a/libcxx/test/libcxx-03/input.output/stream.buffers/lit.local.cfg b/libcxx/test/libcxx-03/input.output/stream.buffers/lit.local.cfg
new file mode 100644
index 000000000000..ac628161afe7
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/stream.buffers/lit.local.cfg
@@ -0,0 +1,7 @@
+# Load the same local configuration as the corresponding one in libcxx/test/std
+import os
+
+inLibcxx = os.path.join("libcxx", "test", "libcxx-03")
+inStd = os.path.join("libcxx", "test", "std")
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
+config.load_from_path(localConfig, lit_config)
diff --git a/libcxx/test/libcxx-03/input.output/string.streams/lit.local.cfg b/libcxx/test/libcxx-03/input.output/string.streams/lit.local.cfg
new file mode 100644
index 000000000000..ac628161afe7
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/string.streams/lit.local.cfg
@@ -0,0 +1,7 @@
+# Load the same local configuration as the corresponding one in libcxx/test/std
+import os
+
+inLibcxx = os.path.join("libcxx", "test", "libcxx-03")
+inStd = os.path.join("libcxx", "test", "std")
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
+config.load_from_path(localConfig, lit_config)
diff --git a/libcxx/test/libcxx-03/input.output/string.streams/stringbuf/const_sso_buffer.pass.cpp b/libcxx/test/libcxx-03/input.output/string.streams/stringbuf/const_sso_buffer.pass.cpp
new file mode 100644
index 000000000000..2b6c3802a56b
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/string.streams/stringbuf/const_sso_buffer.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// XFAIL: FROZEN-CXX03-HEADERS-FIXME
+
+// How the constructors of basic_stringbuf initialize the buffer pointers is
+// not specified. For some constructors it's implementation defined whether the
+// pointers are set to nullptr. Libc++'s implementation directly uses the SSO
+// buffer of a std::string as the initial size. This test validates that
+// behaviour.
+//
+// This behaviour is allowed by LWG2995.
+
+#include <sstream>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class CharT>
+struct test_buf : public std::basic_stringbuf<CharT> {
+ typedef std::basic_streambuf<CharT> base;
+ typedef typename base::char_type char_type;
+ typedef typename base::int_type int_type;
+ typedef typename base::traits_type traits_type;
+
+ char_type* pbase() const { return base::pbase(); }
+ char_type* pptr() const { return base::pptr(); }
+ char_type* epptr() const { return base::epptr(); }
+ void gbump(int n) { base::gbump(n); }
+
+ virtual int_type overflow(int_type c = traits_type::eof()) { return base::overflow(c); }
+
+ test_buf() = default;
+ explicit test_buf(std::ios_base::openmode which) : std::basic_stringbuf<CharT>(which) {}
+
+ explicit test_buf(const std::basic_string<CharT>& s) : std::basic_stringbuf<CharT>(s) {}
+#if TEST_STD_VER >= 20
+ explicit test_buf(const std::allocator<CharT>& a) : std::basic_stringbuf<CharT>(a) {}
+ test_buf(std::ios_base::openmode which, const std::allocator<CharT>& a) : std::basic_stringbuf<CharT>(which, a) {}
+ explicit test_buf(std::basic_string<CharT>&& s)
+ : std::basic_stringbuf<CharT>(std::forward<std::basic_string<CharT>>(s)) {}
+
+ test_buf(const std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>>& s,
+ const std::allocator<CharT>& a)
+ : std::basic_stringbuf<CharT>(s, a) {}
+ test_buf(const std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>>& s,
+ std::ios_base::openmode which,
+ const std::allocator<CharT>& a)
+ : std::basic_stringbuf<CharT>(s, which, a) {}
+ test_buf(const std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>>& s)
+ : std::basic_stringbuf<CharT>(s) {}
+#endif // TEST_STD_VER >= 20
+
+#if TEST_STD_VER >= 26
+ test_buf(std::basic_string_view<CharT> s) : std::basic_stringbuf<CharT>(s) {}
+ test_buf(std::basic_string_view<CharT> s, const std::allocator<CharT>& a) : std::basic_stringbuf<CharT>(s, a) {}
+ test_buf(std::basic_string_view<CharT> s, std::ios_base::openmode which, const std::allocator<CharT>& a)
+ : std::basic_stringbuf<CharT>(s, which, a) {}
+#endif // TEST_STD_VER >= 26
+};
+
+template <class CharT>
+static void test() {
+ std::size_t size = std::basic_string<CharT>().capacity(); // SSO buffer size.
+ {
+ test_buf<CharT> b;
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() == b.pbase() + size);
+ }
+ {
+ test_buf<CharT> b(std::ios_base::out);
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() == b.pbase() + size);
+ }
+ {
+ std::basic_string<CharT> s;
+ s.reserve(1024);
+ test_buf<CharT> b(s);
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() == b.pbase() + size); // copy so uses size
+ }
+#if TEST_STD_VER >= 20
+ {
+ test_buf<CharT> b = test_buf<CharT>(std::allocator<CharT>());
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() == b.pbase() + size);
+ }
+ {
+ test_buf<CharT> b = test_buf<CharT>(std::ios_base::out, std::allocator<CharT>());
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() == b.pbase() + size);
+ }
+ {
+ std::basic_string<CharT> s;
+ s.reserve(1024);
+ std::size_t capacity = s.capacity();
+ test_buf<CharT> b = test_buf<CharT>(std::move(s));
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() >= b.pbase() + capacity); // move so uses s.capacity()
+ }
+ {
+ std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>> s;
+ s.reserve(1024);
+ test_buf<CharT> b = test_buf<CharT>(s, std::allocator<CharT>());
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() == b.pbase() + size); // copy so uses size
+ }
+ {
+ std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>> s;
+ s.reserve(1024);
+ test_buf<CharT> b = test_buf<CharT>(s, std::ios_base::out, std::allocator<CharT>());
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() == b.pbase() + size); // copy so uses size
+ }
+ {
+ std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>> s;
+ s.reserve(1024);
+ test_buf<CharT> b = test_buf<CharT>(s);
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() == b.pbase() + size); // copy so uses size
+ }
+#endif // TEST_STD_VER >= 20
+#if TEST_STD_VER >= 26
+ {
+ std::basic_string_view<CharT> s;
+ test_buf<CharT> b = test_buf<CharT>(s);
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() == b.pbase() + size);
+ }
+ {
+ std::basic_string_view<CharT> s;
+ test_buf<CharT> b = test_buf<CharT>(s, std::allocator<CharT>());
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() == b.pbase() + size);
+ }
+ {
+ std::basic_string_view<CharT> s;
+ test_buf<CharT> b = test_buf<CharT>(s, std::ios_base::out, std::allocator<CharT>());
+ assert(b.pbase() != nullptr);
+ assert(b.pptr() == b.pbase());
+ assert(b.epptr() == b.pbase() + size);
+ }
+#endif // TEST_STD_VER >= 26
+}
+
+int main(int, char**) {
+ test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+ test<wchar_t>();
+#endif
+ return 0;
+}
diff --git a/libcxx/test/libcxx-03/input.output/string.streams/traits_mismatch.verify.cpp b/libcxx/test/libcxx-03/input.output/string.streams/traits_mismatch.verify.cpp
new file mode 100644
index 000000000000..36f3222c3a7a
--- /dev/null
+++ b/libcxx/test/libcxx-03/input.output/string.streams/traits_mismatch.verify.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template<class charT, class traits = char_traits<charT>,
+// class Allocator = allocator<charT>>
+// class basic_stringbuf;
+//
+// The char type of the stream and the char_type of the traits have to match
+
+// UNSUPPORTED: no-wide-characters
+
+#include <sstream>
+
+std::basic_stringbuf<char, std::char_traits<wchar_t> > sb;
+// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
+// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
+
+// expected-error@*:* 5 {{only virtual member functions can be marked 'override'}}