Home | History | Annotate | Download | only in iostream.cons
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <istream>
     11 
     12 // template <class charT, class traits = char_traits<charT> >
     13 // class basic_iostream;
     14 
     15 // explicit basic_iostream(basic_streambuf<charT,traits>* sb);
     16 
     17 #include <istream>
     18 #include <cassert>
     19 
     20 template <class CharT>
     21 struct testbuf
     22     : public std::basic_streambuf<CharT>
     23 {
     24     testbuf() {}
     25 };
     26 
     27 int main()
     28 {
     29     {
     30         testbuf<char> sb;
     31         std::basic_iostream<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_iostream<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