xref: /llvm-project/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp (revision 2df59c50688c122bbcae7467d3eaf862c3ea3088)
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 // basic_streambuf<charT,traits>* setbuf(charT* s, streamsize n);
15 
16 #include <sstream>
17 #include <cassert>
18 
19 int main(int, char**)
20 {
21     {
22         std::stringbuf sb("0123456789");
23         assert(sb.pubsetbuf(0, 0) == &sb);
24         assert(sb.str() == "0123456789");
25     }
26     {
27         std::wstringbuf sb(L"0123456789");
28         assert(sb.pubsetbuf(0, 0) == &sb);
29         assert(sb.str() == L"0123456789");
30     }
31 
32   return 0;
33 }
34