1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // T3 setbase(int base);
18 #include "test_macros.h"
20 template <class CharT
>
22 : public std::basic_streambuf
<CharT
>
32 is
>> std::setbase(8);
33 assert((is
.flags() & std::ios_base::basefield
) == std::ios_base::oct
);
34 is
>> std::setbase(10);
35 assert((is
.flags() & std::ios_base::basefield
) == std::ios_base::dec
);
36 is
>> std::setbase(16);
37 assert((is
.flags() & std::ios_base::basefield
) == std::ios_base::hex
);
38 is
>> std::setbase(15);
39 assert((is
.flags() & std::ios_base::basefield
) == 0);
44 os
<< std::setbase(8);
45 assert((os
.flags() & std::ios_base::basefield
) == std::ios_base::oct
);
46 os
<< std::setbase(10);
47 assert((os
.flags() & std::ios_base::basefield
) == std::ios_base::dec
);
48 os
<< std::setbase(16);
49 assert((os
.flags() & std::ios_base::basefield
) == std::ios_base::hex
);
50 os
<< std::setbase(15);
51 assert((os
.flags() & std::ios_base::basefield
) == 0);
53 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
56 std::wistream
is(&sb
);
57 is
>> std::setbase(8);
58 assert((is
.flags() & std::ios_base::basefield
) == std::ios_base::oct
);
59 is
>> std::setbase(10);
60 assert((is
.flags() & std::ios_base::basefield
) == std::ios_base::dec
);
61 is
>> std::setbase(16);
62 assert((is
.flags() & std::ios_base::basefield
) == std::ios_base::hex
);
63 is
>> std::setbase(15);
64 assert((is
.flags() & std::ios_base::basefield
) == 0);
68 std::wostream
os(&sb
);
69 os
<< std::setbase(8);
70 assert((os
.flags() & std::ios_base::basefield
) == std::ios_base::oct
);
71 os
<< std::setbase(10);
72 assert((os
.flags() & std::ios_base::basefield
) == std::ios_base::dec
);
73 os
<< std::setbase(16);
74 assert((os
.flags() & std::ios_base::basefield
) == std::ios_base::hex
);
75 os
<< std::setbase(15);
76 assert((os
.flags() & std::ios_base::basefield
) == 0);
78 #endif // TEST_HAS_NO_WIDE_CHARACTERS