Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / input.output / iostream.format / output.streams / ostream.cons / move.pass.cpp
blobd2de7b09d0e2751038e79edc4d9ffdf2b4d510dd
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 //===----------------------------------------------------------------------===//
9 // <ostream>
11 // template <class charT, class traits = char_traits<charT> >
12 // class basic_ostream;
14 // basic_ostream(basic_ostream&& rhs);
16 #include <ostream>
17 #include <cassert>
19 #include "test_macros.h"
22 template <class CharT>
23 struct testbuf
24 : public std::basic_streambuf<CharT>
26 testbuf() {}
29 template <class CharT>
30 struct test_ostream
31 : public std::basic_ostream<CharT>
33 typedef std::basic_ostream<CharT> base;
34 test_ostream(testbuf<CharT>* sb) : base(sb) {}
36 test_ostream(test_ostream&& s)
37 : base(std::move(s)) {}
41 int main(int, char**)
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");
57 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
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");
72 #endif
74 return 0;