1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <iomanip>
11 
12 // T6 setw(int n);
13 
14 #include <iomanip>
15 #include <istream>
16 #include <ostream>
17 #include <cassert>
18 
19 template <class CharT>
20 struct testbuf
21     : public std::basic_streambuf<CharT>
22 {
testbuftestbuf23     testbuf() {}
24 };
25 
main()26 int main()
27 {
28     {
29         testbuf<char> sb;
30         std::istream is(&sb);
31         is >> std::setw(10);
32         assert(is.width() == 10);
33     }
34     {
35         testbuf<char> sb;
36         std::ostream os(&sb);
37         os << std::setw(10);
38         assert(os.width() == 10);
39     }
40     {
41         testbuf<wchar_t> sb;
42         std::wistream is(&sb);
43         is >> std::setw(10);
44         assert(is.width() == 10);
45     }
46     {
47         testbuf<wchar_t> sb;
48         std::wostream os(&sb);
49         os << std::setw(10);
50         assert(os.width() == 10);
51     }
52 }
53