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// <istream>
10
11// template <class charT, class traits = char_traits<charT> >
12// class basic_iostream;
13
14// explicit basic_iostream(basic_streambuf<charT,traits>* sb);
15
16#include <istream>
17#include <cassert>
18#include <streambuf>
19
20#include "test_macros.h"
21
22template <class CharT>
23struct testbuf
24 : public std::basic_streambuf<CharT>
25{
26 testbuf() {}
27};
28
29int main(int, char**)
30{
31 {
32 testbuf<char> sb;
33 std::basic_iostream<char> is(&sb);
34 assert(is.rdbuf() == &sb);
35 assert(is.tie() == 0);
36 assert(is.fill() == ' ');
37 assert(is.rdstate() == is.goodbit);
38 assert(is.exceptions() == is.goodbit);
39 assert(is.flags() == (is.skipws | is.dec));
40 assert(is.precision() == 6);
41 assert(is.getloc().name() == "C");
42 assert(is.gcount() == 0);
43 }
44#ifndef TEST_HAS_NO_WIDE_CHARACTERS
45 {
46 testbuf<wchar_t> sb;
47 std::basic_iostream<wchar_t> is(&sb);
48 assert(is.rdbuf() == &sb);
49 assert(is.tie() == 0);
50 assert(is.fill() == L' ');
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");
56 assert(is.gcount() == 0);
57 }
58#endif
59
60 return 0;
61}
62

source code of libcxx/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp