brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 9eb4a50 Raw
79 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_istream;13 14// basic_istream(basic_istream&& rhs);15 16#include <istream>17#include <cassert>18#include <streambuf>19 20#include "test_macros.h"21 22template <class CharT>23struct testbuf24    : public std::basic_streambuf<CharT>25{26    testbuf() {}27};28 29template <class CharT>30struct test_istream31    : public std::basic_istream<CharT>32{33    typedef std::basic_istream<CharT> base;34    test_istream(testbuf<CharT>* sb) : base(sb) {}35 36    test_istream(test_istream&& s)37        : base(std::move(s)) {}38};39 40int main(int, char**)41{42    {43        testbuf<char> sb;44        test_istream<char> is1(&sb);45        test_istream<char> is(std::move(is1));46        assert(is1.rdbuf() == &sb);47        assert(is1.gcount() == 0);48        assert(is.gcount() == 0);49        assert(is.rdbuf() == 0);50        assert(is.tie() == 0);51        assert(is.fill() == ' ');52        assert(is.rdstate() == is.goodbit);53        assert(is.exceptions() == is.goodbit);54        assert(is.flags() == (is.skipws | is.dec));55        assert(is.precision() == 6);56        assert(is.getloc().name() == "C");57    }58#ifndef TEST_HAS_NO_WIDE_CHARACTERS59    {60        testbuf<wchar_t> sb;61        test_istream<wchar_t> is1(&sb);62        test_istream<wchar_t> is(std::move(is1));63        assert(is1.gcount() == 0);64        assert(is.gcount() == 0);65        assert(is1.rdbuf() == &sb);66        assert(is.rdbuf() == 0);67        assert(is.tie() == 0);68        assert(is.fill() == L' ');69        assert(is.rdstate() == is.goodbit);70        assert(is.exceptions() == is.goodbit);71        assert(is.flags() == (is.skipws | is.dec));72        assert(is.precision() == 6);73        assert(is.getloc().name() == "C");74    }75#endif76 77  return 0;78}79