1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template <class charT, class traits = char_traits<charT> >
12 // class basic_istream;
14 // void swap(basic_istream& rhs);
19 #include "test_macros.h"
21 template <class CharT
>
23 : public std::basic_streambuf
<CharT
>
28 template <class CharT
>
30 : public std::basic_istream
<CharT
>
32 typedef std::basic_istream
<CharT
> base
;
33 test_istream(testbuf
<CharT
>* sb
) : base(sb
) {}
35 void swap(test_istream
& s
) {base::swap(s
);}
43 test_istream
<char> is1(&sb1
);
44 test_istream
<char> is2(&sb2
);
46 assert(is1
.rdbuf() == &sb1
);
47 assert(is1
.tie() == 0);
48 assert(is1
.fill() == ' ');
49 assert(is1
.rdstate() == is1
.goodbit
);
50 assert(is1
.exceptions() == is1
.goodbit
);
51 assert(is1
.flags() == (is1
.skipws
| is1
.dec
));
52 assert(is1
.precision() == 6);
53 assert(is1
.getloc().name() == "C");
54 assert(is2
.rdbuf() == &sb2
);
55 assert(is2
.tie() == 0);
56 assert(is2
.fill() == ' ');
57 assert(is2
.rdstate() == is2
.goodbit
);
58 assert(is2
.exceptions() == is2
.goodbit
);
59 assert(is2
.flags() == (is2
.skipws
| is2
.dec
));
60 assert(is2
.precision() == 6);
61 assert(is2
.getloc().name() == "C");
63 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
67 test_istream
<wchar_t> is1(&sb1
);
68 test_istream
<wchar_t> is2(&sb2
);
70 assert(is1
.rdbuf() == &sb1
);
71 assert(is1
.tie() == 0);
72 assert(is1
.fill() == ' ');
73 assert(is1
.rdstate() == is1
.goodbit
);
74 assert(is1
.exceptions() == is1
.goodbit
);
75 assert(is1
.flags() == (is1
.skipws
| is1
.dec
));
76 assert(is1
.precision() == 6);
77 assert(is1
.getloc().name() == "C");
78 assert(is2
.rdbuf() == &sb2
);
79 assert(is2
.tie() == 0);
80 assert(is2
.fill() == ' ');
81 assert(is2
.rdstate() == is2
.goodbit
);
82 assert(is2
.exceptions() == is2
.goodbit
);
83 assert(is2
.flags() == (is2
.skipws
| is2
.dec
));
84 assert(is2
.precision() == 6);
85 assert(is2
.getloc().name() == "C");