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 // T6 setw(int n);
12 
13 #include <iomanip>
14 #include <istream>
15 #include <ostream>
16 #include <cassert>
17 
18 #include "test_macros.h"
19 
20 template <class CharT>
21 struct testbuf
22     : public std::basic_streambuf<CharT>
23 {
testbuftestbuf24     testbuf() {}
25 };
26 
main(int,char **)27 int main(int, char**)
28 {
29     {
30         testbuf<char> sb;
31         std::istream is(&sb);
32         is >> std::setw(10);
33         assert(is.width() == 10);
34     }
35     {
36         testbuf<char> sb;
37         std::ostream os(&sb);
38         os << std::setw(10);
39         assert(os.width() == 10);
40     }
41     {
42         testbuf<wchar_t> sb;
43         std::wistream is(&sb);
44         is >> std::setw(10);
45         assert(is.width() == 10);
46     }
47     {
48         testbuf<wchar_t> sb;
49         std::wostream os(&sb);
50         os << std::setw(10);
51         assert(os.width() == 10);
52     }
53 
54   return 0;
55 }
56