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 //===----------------------------------------------------------------------===//
8 
9 // <sstream>
10 
11 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
12 // class basic_stringstream
13 
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
17 
18 #include <sstream>
19 #include <cassert>
20 
21 #include "test_macros.h"
22 #if TEST_STD_VER >= 11
23 #include "test_convertible.h"
24 
25 template <typename S>
26 void test() {
27   static_assert(test_convertible<S>(), "");
28   static_assert(!test_convertible<S, std::ios_base::openmode>(), "");
29 }
30 #endif
31 
32 int main(int, char**)
33 {
34     {
35         std::stringstream ss;
36         assert(ss.rdbuf() != 0);
37         assert(ss.good());
38         assert(ss.str() == "");
39     }
40     {
41         std::stringstream ss(std::ios_base::in);
42         assert(ss.rdbuf() != 0);
43         assert(ss.good());
44         assert(ss.str() == "");
45     }
46     {
47         std::wstringstream ss;
48         assert(ss.rdbuf() != 0);
49         assert(ss.good());
50         assert(ss.str() == L"");
51     }
52     {
53         std::wstringstream ss(std::ios_base::in);
54         assert(ss.rdbuf() != 0);
55         assert(ss.good());
56         assert(ss.str() == L"");
57     }
58 
59 #if TEST_STD_VER >= 11
60     test<std::stringstream>();
61     test<std::wstringstream>();
62 #endif
63 
64     return 0;
65 }
66