Home | History | Annotate | Download | only in std.manip
      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 // T5 setprecision(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 {
     23     testbuf() {}
     24 };
     25 
     26 int main()
     27 {
     28     {
     29         testbuf<char> sb;
     30         std::istream is(&sb);
     31         is >> std::setprecision(10);
     32         assert(is.precision() == 10);
     33     }
     34     {
     35         testbuf<char> sb;
     36         std::ostream os(&sb);
     37         os << std::setprecision(10);
     38         assert(os.precision() == 10);
     39     }
     40     {
     41         testbuf<wchar_t> sb;
     42         std::wistream is(&sb);
     43         is >> std::setprecision(10);
     44         assert(is.precision() == 10);
     45     }
     46     {
     47         testbuf<wchar_t> sb;
     48         std::wostream os(&sb);
     49         os << std::setprecision(10);
     50         assert(os.precision() == 10);
     51     }
     52 }
     53