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 #include "test_macros.h"
20 
21 template<typename CharT>
22 struct testbuf
23     : std::basic_stringbuf<CharT>
24 {
checktestbuf25     void check()
26     {
27         assert(this->eback() == NULL);
28         assert(this->gptr() == NULL);
29         assert(this->egptr() == NULL);
30         assert(this->pbase() == NULL);
31         assert(this->pptr() == NULL);
32         assert(this->epptr() == NULL);
33     }
34 };
35 
main(int,char **)36 int main(int, char**)
37 {
38     {
39         std::stringbuf buf;
40         assert(buf.str() == "");
41     }
42     {
43         std::wstringbuf buf;
44         assert(buf.str() == L"");
45     }
46     {
47         testbuf<char> buf;
48         buf.check();
49     }
50     {
51         testbuf<wchar_t> buf;
52         buf.check();
53     }
54 
55   return 0;
56 }
57