streambuf.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <istream>
11
12// template <class charT, class traits = char_traits<charT> >
13// class basic_istream;
14
15// explicit basic_istream(basic_streambuf<charT,traits>* sb);
16
17#include <istream>
18#include <cassert>
19
20template <class CharT>
21struct testbuf
22    : public std::basic_streambuf<CharT>
23{
24    testbuf() {}
25};
26
27int main()
28{
29    {
30        testbuf<char> sb;
31        std::basic_istream<char> is(&sb);
32        assert(is.rdbuf() == &sb);
33        assert(is.tie() == 0);
34        assert(is.fill() == ' ');
35        assert(is.rdstate() == is.goodbit);
36        assert(is.exceptions() == is.goodbit);
37        assert(is.flags() == (is.skipws | is.dec));
38        assert(is.precision() == 6);
39        assert(is.getloc().name() == "C");
40        assert(is.gcount() == 0);
41    }
42    {
43        testbuf<wchar_t> sb;
44        std::basic_istream<wchar_t> is(&sb);
45        assert(is.rdbuf() == &sb);
46        assert(is.tie() == 0);
47        assert(is.fill() == L' ');
48        assert(is.rdstate() == is.goodbit);
49        assert(is.exceptions() == is.goodbit);
50        assert(is.flags() == (is.skipws | is.dec));
51        assert(is.precision() == 6);
52        assert(is.getloc().name() == "C");
53        assert(is.gcount() == 0);
54    }
55}
56