81 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <istream>10 11// template <class charT, class traits = char_traits<charT> >12// class basic_iostream;13 14// basic_iostream(basic_iostream&& rhs);15 16#include <istream>17#include <cassert>18#include <streambuf>19 20#include "test_macros.h"21 22 23template <class CharT>24struct testbuf25 : public std::basic_streambuf<CharT>26{27 testbuf() {}28};29 30template <class CharT>31struct test_iostream32 : public std::basic_iostream<CharT>33{34 typedef std::basic_iostream<CharT> base;35 test_iostream(testbuf<CharT>* sb) : base(sb) {}36 37 test_iostream(test_iostream&& s)38 : base(std::move(s)) {}39};40 41 42int main(int, char**)43{44 {45 testbuf<char> sb;46 test_iostream<char> is1(&sb);47 test_iostream<char> is(std::move(is1));48 assert(is1.rdbuf() == &sb);49 assert(is1.gcount() == 0);50 assert(is.gcount() == 0);51 assert(is.rdbuf() == 0);52 assert(is.tie() == 0);53 assert(is.fill() == ' ');54 assert(is.rdstate() == is.goodbit);55 assert(is.exceptions() == is.goodbit);56 assert(is.flags() == (is.skipws | is.dec));57 assert(is.precision() == 6);58 assert(is.getloc().name() == "C");59 }60#ifndef TEST_HAS_NO_WIDE_CHARACTERS61 {62 testbuf<wchar_t> sb;63 test_iostream<wchar_t> is1(&sb);64 test_iostream<wchar_t> is(std::move(is1));65 assert(is1.gcount() == 0);66 assert(is.gcount() == 0);67 assert(is1.rdbuf() == &sb);68 assert(is.rdbuf() == 0);69 assert(is.tie() == 0);70 assert(is.fill() == L' ');71 assert(is.rdstate() == is.goodbit);72 assert(is.exceptions() == is.goodbit);73 assert(is.flags() == (is.skipws | is.dec));74 assert(is.precision() == 6);75 assert(is.getloc().name() == "C");76 }77#endif78 79 return 0;80}81