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_stringbuf
13 
14 // explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
15 
16 #include <sstream>
17 #include <cassert>
18 
19 template<typename CharT>
20 struct testbuf
21     : std::basic_stringbuf<CharT>
22 {
23     void check()
24     {
25         assert(this->eback() == NULL);
26         assert(this->gptr() == NULL);
27         assert(this->egptr() == NULL);
28         assert(this->pbase() == NULL);
29         assert(this->pptr() == NULL);
30         assert(this->epptr() == NULL);
31     }
32 };
33 
34 int main(int, char**)
35 {
36     {
37         std::stringbuf buf;
38         assert(buf.str() == "");
39     }
40     {
41         std::wstringbuf buf;
42         assert(buf.str() == L"");
43     }
44     {
45         testbuf<char> buf;
46         buf.check();
47     }
48     {
49         testbuf<wchar_t> buf;
50         buf.check();
51     }
52 
53   return 0;
54 }
55