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 // <ostream> 11 12 // template <class charT, class traits = char_traits<charT> > 13 // class basic_ostream; 14 15 // explicit basic_ostream(basic_streambuf<charT,traits>* sb); 16 17 #include <ostream> 18 #include <cassert> 19 20 template <class CharT> 21 struct testbuf 22 : public std::basic_streambuf<CharT> 23 { testbuftestbuf24 testbuf() {} 25 }; 26 main()27int main() 28 { 29 { 30 testbuf<char> sb; 31 std::basic_ostream<char> os(&sb); 32 assert(os.rdbuf() == &sb); 33 assert(os.tie() == 0); 34 assert(os.fill() == ' '); 35 assert(os.rdstate() == os.goodbit); 36 assert(os.exceptions() == os.goodbit); 37 assert(os.flags() == (os.skipws | os.dec)); 38 assert(os.precision() == 6); 39 assert(os.getloc().name() == "C"); 40 } 41 { 42 testbuf<wchar_t> sb; 43 std::basic_ostream<wchar_t> os(&sb); 44 assert(os.rdbuf() == &sb); 45 assert(os.tie() == 0); 46 assert(os.fill() == L' '); 47 assert(os.rdstate() == os.goodbit); 48 assert(os.exceptions() == os.goodbit); 49 assert(os.flags() == (os.skipws | os.dec)); 50 assert(os.precision() == 6); 51 assert(os.getloc().name() == "C"); 52 } 53 } 54