| 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(const basic_string<charT,traits,Allocator>& s, |
| 15 | // ios_base::openmode which = ios_base::in | ios_base::out); |
| 16 | |
| 17 | #include <sstream> |
| 18 | #include <cassert> |
| 19 | |
| 20 | #include "test_macros.h" |
| 21 | |
| 22 | int main(int, char**) |
| 23 | { |
| 24 | { |
| 25 | std::stringbuf buf("testing" ); |
| 26 | assert(buf.str() == "testing" ); |
| 27 | } |
| 28 | { |
| 29 | std::stringbuf buf("testing" , std::ios_base::in); |
| 30 | assert(buf.str() == "testing" ); |
| 31 | } |
| 32 | { |
| 33 | std::stringbuf buf("testing" , std::ios_base::out); |
| 34 | assert(buf.str() == "testing" ); |
| 35 | } |
| 36 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
| 37 | { |
| 38 | std::wstringbuf buf(L"testing" ); |
| 39 | assert(buf.str() == L"testing" ); |
| 40 | } |
| 41 | { |
| 42 | std::wstringbuf buf(L"testing" , std::ios_base::in); |
| 43 | assert(buf.str() == L"testing" ); |
| 44 | } |
| 45 | { |
| 46 | std::wstringbuf buf(L"testing" , std::ios_base::out); |
| 47 | assert(buf.str() == L"testing" ); |
| 48 | } |
| 49 | #endif |
| 50 | |
| 51 | return 0; |
| 52 | } |
| 53 | |