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 / streambuf.pass.cpp
blobb2b428ede516dc3ea2ad5f7152c14b324a59cdb4
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 // explicit basic_istream(basic_streambuf<charT,traits>* sb);
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 int main(int, char**)
31 testbuf<char> sb;
32 std::basic_istream<char> is(&sb);
33 assert(is.rdbuf() == &sb);
34 assert(is.tie() == 0);
35 assert(is.fill() == ' ');
36 assert(is.rdstate() == is.goodbit);
37 assert(is.exceptions() == is.goodbit);
38 assert(is.flags() == (is.skipws | is.dec));
39 assert(is.precision() == 6);
40 assert(is.getloc().name() == "C");
41 assert(is.gcount() == 0);
43 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
45 testbuf<wchar_t> sb;
46 std::basic_istream<wchar_t> is(&sb);
47 assert(is.rdbuf() == &sb);
48 assert(is.tie() == 0);
49 assert(is.fill() == L' ');
50 assert(is.rdstate() == is.goodbit);
51 assert(is.exceptions() == is.goodbit);
52 assert(is.flags() == (is.skipws | is.dec));
53 assert(is.precision() == 6);
54 assert(is.getloc().name() == "C");
55 assert(is.gcount() == 0);
57 #endif
59 return 0;