[libc++][doc] Updates format status.
[llvm-project.git] / libcxx / test / std / input.output / string.streams / stringstream / stringstream.cons / default.pass.cpp
blob0e535814ae54ee56ba4e0845dbc25024c8fec896
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <sstream>
11 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
12 // class basic_stringstream
14 // explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20
15 // basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20
16 // explicit basic_stringstream(ios_base::openmode which); // C++20
18 // XFAIL: FROZEN-CXX03-HEADERS-FIXME
20 #include <sstream>
21 #include <cassert>
23 #include "test_macros.h"
24 #include "operator_hijacker.h"
25 #if TEST_STD_VER >= 11
26 #include "test_convertible.h"
28 template <typename S>
29 void test() {
30 static_assert(test_convertible<S>(), "");
31 static_assert(!test_convertible<S, std::ios_base::openmode>(), "");
33 #endif
35 int main(int, char**)
38 std::stringstream ss;
39 assert(ss.rdbuf() != nullptr);
40 assert(ss.good());
41 assert(ss.str() == "");
44 std::basic_stringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss;
45 assert(ss.rdbuf() != nullptr);
46 assert(ss.good());
47 assert(ss.str() == "");
50 std::stringstream ss(std::ios_base::in);
51 assert(ss.rdbuf() != nullptr);
52 assert(ss.good());
53 assert(ss.str() == "");
56 std::basic_stringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss(std::ios_base::in);
57 assert(ss.rdbuf() != nullptr);
58 assert(ss.good());
59 assert(ss.str() == "");
61 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
63 std::wstringstream ss;
64 assert(ss.rdbuf() != nullptr);
65 assert(ss.good());
66 assert(ss.str() == L"");
69 std::wstringstream ss(std::ios_base::in);
70 assert(ss.rdbuf() != nullptr);
71 assert(ss.good());
72 assert(ss.str() == L"");
74 #endif
76 #if TEST_STD_VER >= 11
77 test<std::stringstream>();
78 # ifndef TEST_HAS_NO_WIDE_CHARACTERS
79 test<std::wstringstream>();
80 # endif
81 #endif
83 return 0;