xref: /llvm-project/libcxx/test/std/input.output/iostream.format/std.manip/setiosflags.pass.cpp (revision 2df59c50688c122bbcae7467d3eaf862c3ea3088)
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 // <iomanip>
10 
11 // T2 setiosflags (ios_base::fmtflags mask);
12 
13 #include <iomanip>
14 #include <istream>
15 #include <ostream>
16 #include <cassert>
17 
18 template <class CharT>
19 struct testbuf
20     : public std::basic_streambuf<CharT>
21 {
22     testbuf() {}
23 };
24 
25 int main(int, char**)
26 {
27     {
28         testbuf<char> sb;
29         std::istream is(&sb);
30         assert(!(is.flags() & std::ios_base::oct));
31         is >> std::setiosflags(std::ios_base::oct);
32         assert(is.flags() & std::ios_base::oct);
33     }
34     {
35         testbuf<char> sb;
36         std::ostream os(&sb);
37         assert(!(os.flags() & std::ios_base::oct));
38         os << std::setiosflags(std::ios_base::oct);
39         assert(os.flags() & std::ios_base::oct);
40     }
41     {
42         testbuf<wchar_t> sb;
43         std::wistream is(&sb);
44         assert(!(is.flags() & std::ios_base::oct));
45         is >> std::setiosflags(std::ios_base::oct);
46         assert(is.flags() & std::ios_base::oct);
47     }
48     {
49         testbuf<wchar_t> sb;
50         std::wostream os(&sb);
51         assert(!(os.flags() & std::ios_base::oct));
52         os << std::setiosflags(std::ios_base::oct);
53         assert(os.flags() & std::ios_base::oct);
54     }
55 
56   return 0;
57 }
58