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);
20 #include "test_macros.h"
22 template <class CharT
>
24 : public std::basic_streambuf
<CharT
>
29 template <class CharT
>
31 : public std::basic_istream
<CharT
>
33 typedef std::basic_istream
<CharT
> base
;
34 test_istream(testbuf
<CharT
>* sb
) : base(sb
) {}
36 void swap(test_istream
& s
) {base::swap(s
);}
44 test_istream
<char> is1(&sb1
);
45 test_istream
<char> is2(&sb2
);
47 assert(is1
.rdbuf() == &sb1
);
48 assert(is1
.tie() == 0);
49 assert(is1
.fill() == ' ');
50 assert(is1
.rdstate() == is1
.goodbit
);
51 assert(is1
.exceptions() == is1
.goodbit
);
52 assert(is1
.flags() == (is1
.skipws
| is1
.dec
));
53 assert(is1
.precision() == 6);
54 assert(is1
.getloc().name() == "C");
55 assert(is2
.rdbuf() == &sb2
);
56 assert(is2
.tie() == 0);
57 assert(is2
.fill() == ' ');
58 assert(is2
.rdstate() == is2
.goodbit
);
59 assert(is2
.exceptions() == is2
.goodbit
);
60 assert(is2
.flags() == (is2
.skipws
| is2
.dec
));
61 assert(is2
.precision() == 6);
62 assert(is2
.getloc().name() == "C");
64 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
68 test_istream
<wchar_t> is1(&sb1
);
69 test_istream
<wchar_t> is2(&sb2
);
71 assert(is1
.rdbuf() == &sb1
);
72 assert(is1
.tie() == 0);
73 assert(is1
.fill() == ' ');
74 assert(is1
.rdstate() == is1
.goodbit
);
75 assert(is1
.exceptions() == is1
.goodbit
);
76 assert(is1
.flags() == (is1
.skipws
| is1
.dec
));
77 assert(is1
.precision() == 6);
78 assert(is1
.getloc().name() == "C");
79 assert(is2
.rdbuf() == &sb2
);
80 assert(is2
.tie() == 0);
81 assert(is2
.fill() == ' ');
82 assert(is2
.rdstate() == is2
.goodbit
);
83 assert(is2
.exceptions() == is2
.goodbit
);
84 assert(is2
.flags() == (is2
.skipws
| is2
.dec
));
85 assert(is2
.precision() == 6);
86 assert(is2
.getloc().name() == "C");