| 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 | // <ostream> |
| 10 | |
| 11 | // template <class charT, class traits = char_traits<charT> > |
| 12 | // class basic_ostream; |
| 13 | |
| 14 | // basic_ostream(basic_ostream&& rhs); |
| 15 | |
| 16 | #include <ostream> |
| 17 | #include <cassert> |
| 18 | |
| 19 | #include "test_macros.h" |
| 20 | |
| 21 | |
| 22 | template <class CharT> |
| 23 | struct testbuf |
| 24 | : public std::basic_streambuf<CharT> |
| 25 | { |
| 26 | testbuf() {} |
| 27 | }; |
| 28 | |
| 29 | template <class CharT> |
| 30 | struct test_ostream |
| 31 | : public std::basic_ostream<CharT> |
| 32 | { |
| 33 | typedef std::basic_ostream<CharT> base; |
| 34 | test_ostream(testbuf<CharT>* sb) : base(sb) {} |
| 35 | |
| 36 | test_ostream(test_ostream&& s) |
| 37 | : base(std::move(s)) {} |
| 38 | }; |
| 39 | |
| 40 | |
| 41 | int main(int, char**) |
| 42 | { |
| 43 | { |
| 44 | testbuf<char> sb; |
| 45 | test_ostream<char> os1(&sb); |
| 46 | test_ostream<char> os(std::move(os1)); |
| 47 | assert(os1.rdbuf() == &sb); |
| 48 | assert(os.rdbuf() == 0); |
| 49 | assert(os.tie() == 0); |
| 50 | assert(os.fill() == ' '); |
| 51 | assert(os.rdstate() == os.goodbit); |
| 52 | assert(os.exceptions() == os.goodbit); |
| 53 | assert(os.flags() == (os.skipws | os.dec)); |
| 54 | assert(os.precision() == 6); |
| 55 | assert(os.getloc().name() == "C"); |
| 56 | } |
| 57 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
| 58 | { |
| 59 | testbuf<wchar_t> sb; |
| 60 | test_ostream<wchar_t> os1(&sb); |
| 61 | test_ostream<wchar_t> os(std::move(os1)); |
| 62 | assert(os1.rdbuf() == &sb); |
| 63 | assert(os.rdbuf() == 0); |
| 64 | assert(os.tie() == 0); |
| 65 | assert(os.fill() == L' '); |
| 66 | assert(os.rdstate() == os.goodbit); |
| 67 | assert(os.exceptions() == os.goodbit); |
| 68 | assert(os.flags() == (os.skipws | os.dec)); |
| 69 | assert(os.precision() == 6); |
| 70 | assert(os.getloc().name() == "C"); |
| 71 | } |
| 72 | #endif |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 |
