Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / input.output / iostream.format / input.streams / istream / istream.cons / move.pass.cpp
blob4f46ff509ef0e1421bfa19eaf0ccd385c0d46867
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 // <istream>
11 // template <class charT, class traits = char_traits<charT> >
12 // class basic_istream;
14 // basic_istream(basic_istream&& rhs);
16 #include <istream>
17 #include <cassert>
19 #include "test_macros.h"
21 template <class CharT>
22 struct testbuf
23 : public std::basic_streambuf<CharT>
25 testbuf() {}
28 template <class CharT>
29 struct test_istream
30 : public std::basic_istream<CharT>
32 typedef std::basic_istream<CharT> base;
33 test_istream(testbuf<CharT>* sb) : base(sb) {}
35 test_istream(test_istream&& s)
36 : base(std::move(s)) {}
39 int main(int, char**)
42 testbuf<char> sb;
43 test_istream<char> is1(&sb);
44 test_istream<char> is(std::move(is1));
45 assert(is1.rdbuf() == &sb);
46 assert(is1.gcount() == 0);
47 assert(is.gcount() == 0);
48 assert(is.rdbuf() == 0);
49 assert(is.tie() == 0);
50 assert(is.fill() == ' ');
51 assert(is.rdstate() == is.goodbit);
52 assert(is.exceptions() == is.goodbit);
53 assert(is.flags() == (is.skipws | is.dec));
54 assert(is.precision() == 6);
55 assert(is.getloc().name() == "C");
57 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
59 testbuf<wchar_t> sb;
60 test_istream<wchar_t> is1(&sb);
61 test_istream<wchar_t> is(std::move(is1));
62 assert(is1.gcount() == 0);
63 assert(is.gcount() == 0);
64 assert(is1.rdbuf() == &sb);
65 assert(is.rdbuf() == 0);
66 assert(is.tie() == 0);
67 assert(is.fill() == L' ');
68 assert(is.rdstate() == is.goodbit);
69 assert(is.exceptions() == is.goodbit);
70 assert(is.flags() == (is.skipws | is.dec));
71 assert(is.precision() == 6);
72 assert(is.getloc().name() == "C");
74 #endif
76 return 0;