| 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& operator=(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& operator=(test_iostream&& s) |
| 37 |
{base::operator=(std::move(s)); return *this;} |
| 38 |
}; |
| 39 |
|
| 40 |
|
| 41 |
int main(int, char**) |
| 42 |
{ |
| 43 |
{ |
| 44 |
testbuf<char> sb1; |
| 45 |
testbuf<char> sb2; |
| 46 |
test_iostream<char> is1(&sb1); |
| 47 |
test_iostream<char> is2(&sb2); |
| 48 |
is2 = (std::move(is1)); |
| 49 |
assert(is1.rdbuf() == &sb1); |
| 50 |
assert(is1.tie() == 0); |
| 51 |
assert(is1.fill() == ' '); |
| 52 |
assert(is1.rdstate() == is1.goodbit); |
| 53 |
assert(is1.exceptions() == is1.goodbit); |
| 54 |
assert(is1.flags() == (is1.skipws | is1.dec)); |
| 55 |
assert(is1.precision() == 6); |
| 56 |
assert(is1.getloc().name() == "C"); |
| 57 |
assert(is2.rdbuf() == &sb2); |
| 58 |
assert(is2.tie() == 0); |
| 59 |
assert(is2.fill() == ' '); |
| 60 |
assert(is2.rdstate() == is2.goodbit); |
| 61 |
assert(is2.exceptions() == is2.goodbit); |
| 62 |
assert(is2.flags() == (is2.skipws | is2.dec)); |
| 63 |
assert(is2.precision() == 6); |
| 64 |
assert(is2.getloc().name() == "C"); |
| 65 |
} |
| 66 |
#ifndef TEST_HAS_NO_WIDE_CHARACTERS |
| 67 |
{ |
| 68 |
testbuf<wchar_t> sb1; |
| 69 |
testbuf<wchar_t> sb2; |
| 70 |
test_iostream<wchar_t> is1(&sb1); |
| 71 |
test_iostream<wchar_t> is2(&sb2); |
| 72 |
is2 = (std::move(is1)); |
| 73 |
assert(is1.rdbuf() == &sb1); |
| 74 |
assert(is1.tie() == 0); |
| 75 |
assert(is1.fill() == ' '); |
| 76 |
assert(is1.rdstate() == is1.goodbit); |
| 77 |
assert(is1.exceptions() == is1.goodbit); |
| 78 |
assert(is1.flags() == (is1.skipws | is1.dec)); |
| 79 |
assert(is1.precision() == 6); |
| 80 |
assert(is1.getloc().name() == "C"); |
| 81 |
assert(is2.rdbuf() == &sb2); |
| 82 |
assert(is2.tie() == 0); |
| 83 |
assert(is2.fill() == ' '); |
| 84 |
assert(is2.rdstate() == is2.goodbit); |
| 85 |
assert(is2.exceptions() == is2.goodbit); |
| 86 |
assert(is2.flags() == (is2.skipws | is2.dec)); |
| 87 |
assert(is2.precision() == 6); |
| 88 |
assert(is2.getloc().name() == "C"); |
| 89 |
} |
| 90 |
#endif |
| 91 |
|
| 92 |
return 0; |
| 93 |
} |