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 //===----------------------------------------------------------------------===//
9 // REQUIRES: locale.en_US.UTF-8
10 // REQUIRES: locale.fr_FR.UTF-8
14 // template <class charT, class traits> class basic_ios
16 // void move(basic_ios&& rhs);
22 #include "test_macros.h"
23 #include "platform_support.h" // locale name macros
26 : public std::streambuf
33 testios(std::streambuf
* p
) : std::ios(p
) {}
34 void swap(std::ios
& x
) {std::ios::swap(x
);}
37 bool f1_called
= false;
38 bool f2_called
= false;
40 bool g1_called
= false;
41 bool g2_called
= false;
42 bool g3_called
= false;
44 void f1(std::ios_base::event
, std::ios_base
&, int index
)
50 void f2(std::ios_base::event
, std::ios_base
&, int index
)
56 void g1(std::ios_base::event
, std::ios_base
&, int index
)
62 void g2(std::ios_base::event
, std::ios_base
&, int index
)
68 void g3(std::ios_base::event
, std::ios_base
&, int index
)
78 ios1
.flags(std::ios::boolalpha
| std::ios::dec
| std::ios::fixed
);
81 ios1
.imbue(std::locale(LOCALE_en_US_UTF_8
));
82 ios1
.exceptions(std::ios::failbit
);
83 ios1
.setstate(std::ios::eofbit
);
84 ios1
.register_callback(f1
, 4);
85 ios1
.register_callback(f2
, 5);
93 ios1
.tie((std::ostream
*)1);
98 ios2
.flags(std::ios::showpoint
| std::ios::uppercase
);
101 ios2
.imbue(std::locale(LOCALE_fr_FR_UTF_8
));
102 ios2
.exceptions(std::ios::eofbit
);
103 ios2
.setstate(std::ios::goodbit
);
104 ios2
.register_callback(g1
, 7);
105 ios2
.register_callback(g2
, 8);
106 ios2
.register_callback(g3
, 9);
116 ios2
.tie((std::ostream
*)2);
121 assert(ios1
.rdstate() == std::ios::goodbit
);
122 assert(ios1
.rdbuf() == &sb1
);
123 assert(ios1
.flags() == (std::ios::showpoint
| std::ios::uppercase
));
124 assert(ios1
.precision() == 2);
125 assert(ios1
.width() == 12);
126 assert(ios1
.getloc().name() == LOCALE_fr_FR_UTF_8
);
127 assert(ios1
.exceptions() == std::ios::eofbit
);
133 assert(ios1
.iword(0) == 4);
134 assert(ios1
.iword(1) == 5);
135 assert(ios1
.iword(2) == 6);
136 assert(ios1
.iword(3) == 7);
137 assert(ios1
.iword(4) == 8);
138 assert(ios1
.iword(5) == 9);
139 assert(ios1
.pword(0) == &d1
);
140 assert(ios1
.pword(1) == &d2
);
141 assert(ios1
.tie() == (std::ostream
*)2);
142 assert(ios1
.fill() == '2');
143 ios1
.imbue(std::locale("C"));
150 assert(ios2
.rdstate() == std::ios::eofbit
);
151 assert(ios2
.rdbuf() == &sb2
);
152 assert(ios2
.flags() == (std::ios::boolalpha
| std::ios::dec
| std::ios::fixed
));
153 assert(ios2
.precision() == 1);
154 assert(ios2
.width() == 11);
155 assert(ios2
.getloc().name() == LOCALE_en_US_UTF_8
);
156 assert(ios2
.exceptions() == std::ios::failbit
);
157 assert(ios2
.iword(0) == 1);
158 assert(ios2
.iword(1) == 2);
159 assert(ios2
.iword(2) == 3);
160 assert(ios2
.pword(0) == &c1
);
161 assert(ios2
.pword(1) == &c2
);
162 assert(ios2
.pword(2) == &c3
);
163 assert(ios2
.tie() == (std::ostream
*)1);
164 assert(ios2
.fill() == '1');
165 ios2
.imbue(std::locale("C"));