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// T3 setbase(int base); 13 14#include <iomanip> 15#include <cassert> 16 17template <class CharT> 18struct testbuf 19 : public std::basic_streambuf<CharT> 20{ 21 testbuf() {} 22}; 23 24int main() 25{ 26 { 27 testbuf<char> sb; 28 std::istream is(&sb); 29 is >> std::setbase(8); 30 assert((is.flags() & std::ios_base::basefield) == std::ios_base::oct); 31 is >> std::setbase(10); 32 assert((is.flags() & std::ios_base::basefield) == std::ios_base::dec); 33 is >> std::setbase(16); 34 assert((is.flags() & std::ios_base::basefield) == std::ios_base::hex); 35 is >> std::setbase(15); 36 assert((is.flags() & std::ios_base::basefield) == 0); 37 } 38 { 39 testbuf<char> sb; 40 std::ostream os(&sb); 41 os << std::setbase(8); 42 assert((os.flags() & std::ios_base::basefield) == std::ios_base::oct); 43 os << std::setbase(10); 44 assert((os.flags() & std::ios_base::basefield) == std::ios_base::dec); 45 os << std::setbase(16); 46 assert((os.flags() & std::ios_base::basefield) == std::ios_base::hex); 47 os << std::setbase(15); 48 assert((os.flags() & std::ios_base::basefield) == 0); 49 } 50 { 51 testbuf<wchar_t> sb; 52 std::wistream is(&sb); 53 is >> std::setbase(8); 54 assert((is.flags() & std::ios_base::basefield) == std::ios_base::oct); 55 is >> std::setbase(10); 56 assert((is.flags() & std::ios_base::basefield) == std::ios_base::dec); 57 is >> std::setbase(16); 58 assert((is.flags() & std::ios_base::basefield) == std::ios_base::hex); 59 is >> std::setbase(15); 60 assert((is.flags() & std::ios_base::basefield) == 0); 61 } 62 { 63 testbuf<wchar_t> sb; 64 std::wostream os(&sb); 65 os << std::setbase(8); 66 assert((os.flags() & std::ios_base::basefield) == std::ios_base::oct); 67 os << std::setbase(10); 68 assert((os.flags() & std::ios_base::basefield) == std::ios_base::dec); 69 os << std::setbase(16); 70 assert((os.flags() & std::ios_base::basefield) == std::ios_base::hex); 71 os << std::setbase(15); 72 assert((os.flags() & std::ios_base::basefield) == 0); 73 } 74} 75