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 // XFAIL: libcpp-no-exceptions
11 // <ios>
12 
13 // template <class charT, class traits> class basic_ios
14 
15 // iostate exceptions() const;
16 
17 #include <ios>
18 #include <streambuf>
19 #include <cassert>
20 
21 struct testbuf : public std::streambuf {};
22 
23 int main()
24 {
25     {
26         std::ios ios(0);
27         assert(ios.exceptions() == std::ios::goodbit);
28         ios.exceptions(std::ios::eofbit);
29         assert(ios.exceptions() == std::ios::eofbit);
30         try
31         {
32             ios.exceptions(std::ios::badbit);
33             assert(false);
34         }
35         catch (std::ios::failure&)
36         {
37         }
38         assert(ios.exceptions() == std::ios::badbit);
39     }
40     {
41         testbuf sb;
42         std::ios ios(&sb);
43         assert(ios.exceptions() == std::ios::goodbit);
44         ios.exceptions(std::ios::eofbit);
45         assert(ios.exceptions() == std::ios::eofbit);
46         ios.exceptions(std::ios::badbit);
47         assert(ios.exceptions() == std::ios::badbit);
48     }
49 }
50