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_istream; 13 14 // explicit basic_istream(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_istream<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 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 44 { 45 testbuf<wchar_t> sb; 46 std::basic_istream<wchar_t> is(&sb); 47 assert(is.rdbuf() == &sb); 48 assert(is.tie() == 0); 49 assert(is.fill() == L' '); 50 assert(is.rdstate() == is.goodbit); 51 assert(is.exceptions() == is.goodbit); 52 assert(is.flags() == (is.skipws | is.dec)); 53 assert(is.precision() == 6); 54 assert(is.getloc().name() == "C"); 55 assert(is.gcount() == 0); 56 } 57 #endif 58 59 return 0; 60 } 61