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 // basic_istream(basic_istream&& rhs); 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 { testbuftestbuf25 testbuf() {} 26 }; 27 28 template <class CharT> 29 struct test_istream 30 : public std::basic_istream<CharT> 31 { 32 typedef std::basic_istream<CharT> base; test_istreamtest_istream33 test_istream(testbuf<CharT>* sb) : base(sb) {} 34 test_istreamtest_istream35 test_istream(test_istream&& s) 36 : base(std::move(s)) {} 37 }; 38 main(int,char **)39int main(int, char**) 40 { 41 { 42 testbuf<char> sb; 43 test_istream<char> is1(&sb); 44 test_istream<char> is(std::move(is1)); 45 assert(is1.rdbuf() == &sb); 46 assert(is1.gcount() == 0); 47 assert(is.gcount() == 0); 48 assert(is.rdbuf() == 0); 49 assert(is.tie() == 0); 50 assert(is.fill() == ' '); 51 assert(is.rdstate() == is.goodbit); 52 assert(is.exceptions() == is.goodbit); 53 assert(is.flags() == (is.skipws | is.dec)); 54 assert(is.precision() == 6); 55 assert(is.getloc().name() == "C"); 56 } 57 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 58 { 59 testbuf<wchar_t> sb; 60 test_istream<wchar_t> is1(&sb); 61 test_istream<wchar_t> is(std::move(is1)); 62 assert(is1.gcount() == 0); 63 assert(is.gcount() == 0); 64 assert(is1.rdbuf() == &sb); 65 assert(is.rdbuf() == 0); 66 assert(is.tie() == 0); 67 assert(is.fill() == L' '); 68 assert(is.rdstate() == is.goodbit); 69 assert(is.exceptions() == is.goodbit); 70 assert(is.flags() == (is.skipws | is.dec)); 71 assert(is.precision() == 6); 72 assert(is.getloc().name() == "C"); 73 } 74 #endif 75 76 return 0; 77 } 78