[Clang][Sema] Reject declaring an alias template with the same name as its template...
[llvm-project.git] / libcxx / test / std / input.output / iostream.format / input.streams / istream / istream.assign / member_swap.pass.cpp
blob838a564c19f7424f920be0275f5ddec050d14116
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 //===----------------------------------------------------------------------===//
9 // <istream>
11 // template <class charT, class traits = char_traits<charT> >
12 // class basic_istream;
14 // void swap(basic_istream& rhs);
16 #include <istream>
17 #include <cassert>
18 #include <streambuf>
20 #include "test_macros.h"
22 template <class CharT>
23 struct testbuf
24 : public std::basic_streambuf<CharT>
26 testbuf() {}
29 template <class CharT>
30 struct test_istream
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);}
39 int main(int, char**)
42 testbuf<char> sb1;
43 testbuf<char> sb2;
44 test_istream<char> is1(&sb1);
45 test_istream<char> is2(&sb2);
46 is1.swap(is2);
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
66 testbuf<wchar_t> sb1;
67 testbuf<wchar_t> sb2;
68 test_istream<wchar_t> is1(&sb1);
69 test_istream<wchar_t> is2(&sb2);
70 is1.swap(is2);
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");
88 #endif
90 return 0;