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