libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

resetiosflags.pass.cpp (1548B)


      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 // T1 resetiosflags(ios_base::fmtflags mask);
     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         assert(is.flags() & std::ios_base::skipws);
     32         is >> std::resetiosflags(std::ios_base::skipws);
     33         assert(!(is.flags() & std::ios_base::skipws));
     34     }
     35     {
     36         testbuf<char> sb;
     37         std::ostream os(&sb);
     38         assert(os.flags() & std::ios_base::skipws);
     39         os << std::resetiosflags(std::ios_base::skipws);
     40         assert(!(os.flags() & std::ios_base::skipws));
     41     }
     42     {
     43         testbuf<wchar_t> sb;
     44         std::wistream is(&sb);
     45         assert(is.flags() & std::ios_base::skipws);
     46         is >> std::resetiosflags(std::ios_base::skipws);
     47         assert(!(is.flags() & std::ios_base::skipws));
     48     }
     49     {
     50         testbuf<wchar_t> sb;
     51         std::wostream os(&sb);
     52         assert(os.flags() & std::ios_base::skipws);
     53         os << std::resetiosflags(std::ios_base::skipws);
     54         assert(!(os.flags() & std::ios_base::skipws));
     55     }
     56 }