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 19 #include "test_macros.h" 20 21 template <class CharT> 22 struct testbuf 23 : public std::basic_streambuf<CharT> 24 { 25 testbuf() {} 26 }; 27 28 int main(int, char**) 29 { 30 { 31 testbuf<char> sb; 32 std::basic_iostream<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); 42 } 43 { 44 testbuf<wchar_t> sb; 45 std::basic_iostream<wchar_t> is(&sb); 46 assert(is.rdbuf() == &sb); 47 assert(is.tie() == 0); 48 assert(is.fill() == L' '); 49 assert(is.rdstate() == is.goodbit); 50 assert(is.exceptions() == is.goodbit); 51 assert(is.flags() == (is.skipws | is.dec)); 52 assert(is.precision() == 6); 53 assert(is.getloc().name() == "C"); 54 assert(is.gcount() == 0); 55 } 56 57 return 0; 58 } 59