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 // template <class charT, class traits> class basic_ios
13 // void setstate(iostate state);
19 #include "test_macros.h"
21 struct testbuf
: public std::streambuf
{};
27 ios
.setstate(std::ios::goodbit
);
28 assert(ios
.rdstate() == std::ios::badbit
);
29 #ifndef TEST_HAS_NO_EXCEPTIONS
32 ios
.exceptions(std::ios::badbit
);
40 ios
.setstate(std::ios::goodbit
);
43 catch (std::ios::failure
&)
45 assert(ios
.rdstate() == std::ios::badbit
);
49 ios
.setstate(std::ios::eofbit
);
52 catch (std::ios::failure
&)
54 assert(ios
.rdstate() == (std::ios::eofbit
| std::ios::badbit
));
61 ios
.setstate(std::ios::goodbit
);
62 assert(ios
.rdstate() == std::ios::goodbit
);
63 ios
.setstate(std::ios::eofbit
);
64 assert(ios
.rdstate() == std::ios::eofbit
);
65 ios
.setstate(std::ios::failbit
);
66 assert(ios
.rdstate() == (std::ios::eofbit
| std::ios::failbit
));