| 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_ostringstream |
| 13 | |
| 14 | // basic_ostringstream(basic_ostringstream&& rhs); |
| 15 | |
| 16 | // XFAIL: FROZEN-CXX03-HEADERS-FIXME |
| 17 | |
| 18 | #include <sstream> |
| 19 | #include <cassert> |
| 20 | |
| 21 | #include "operator_hijacker.h" |
| 22 | #include "test_macros.h" |
| 23 | |
| 24 | int main(int, char**) |
| 25 | { |
| 26 | { |
| 27 | std::ostringstream ss0(" 123 456" ); |
| 28 | std::ostringstream ss(std::move(ss0)); |
| 29 | assert(ss.rdbuf() != nullptr); |
| 30 | assert(ss.good()); |
| 31 | assert(ss.str() == " 123 456" ); |
| 32 | int i = 234; |
| 33 | ss << i << ' ' << 567; |
| 34 | assert(ss.str() == "234 5676" ); |
| 35 | } |
| 36 | { |
| 37 | std::basic_ostringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss0(" 123 456" ); |
| 38 | std::basic_ostringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss(std::move(ss0)); |
| 39 | assert(ss.rdbuf() != nullptr); |
| 40 | assert(ss.good()); |
| 41 | assert(ss.str() == " 123 456" ); |
| 42 | int i = 234; |
| 43 | ss << i << ' ' << 567; |
| 44 | assert(ss.str() == "234 5676" ); |
| 45 | } |
| 46 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
| 47 | { |
| 48 | std::wostringstream ss0(L" 123 456" ); |
| 49 | std::wostringstream ss(std::move(ss0)); |
| 50 | assert(ss.rdbuf() != nullptr); |
| 51 | assert(ss.good()); |
| 52 | assert(ss.str() == L" 123 456" ); |
| 53 | int i = 234; |
| 54 | ss << i << ' ' << 567; |
| 55 | assert(ss.str() == L"234 5676" ); |
| 56 | } |
| 57 | { |
| 58 | std::basic_ostringstream<wchar_t, std::char_traits<wchar_t>, operator_hijacker_allocator<wchar_t> > ss0( |
| 59 | L" 123 456" ); |
| 60 | std::basic_ostringstream<wchar_t, std::char_traits<wchar_t>, operator_hijacker_allocator<wchar_t> > ss( |
| 61 | std::move(ss0)); |
| 62 | assert(ss.rdbuf() != nullptr); |
| 63 | assert(ss.good()); |
| 64 | assert(ss.str() == L" 123 456" ); |
| 65 | int i = 234; |
| 66 | ss << i << ' ' << 567; |
| 67 | assert(ss.str() == L"234 5676" ); |
| 68 | } |
| 69 | #endif |
| 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | |