Debian Codegraph @

libstdc++-v3/testsuite/27_io/basic_ios/exceptions/char/1.cc

raw
1 // 1999-09-20 bkoz
2
3 // Copyright (C) 1999-2025 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
19
20 // 27.4.4.2 basic_ios member functions
21
22 // NB: Don't include any other headers in this file.
23 #include <ios>
24 #include <testsuite_hooks.h>
25
26 void test01()
27 {
28 typedef std::ios_base::fmtflags fmtflags;
29 typedef std::ios_base::iostate iostate;
30 using std::ios_base;
31
32 // iostate exceptions() const
33 iostate iostate02;
34 {
35 std::ios ios_01(0);
36 VERIFY( ios_01.exceptions() == std::ios_base::goodbit );
37 }
38
39 // void exceptions(iostate except)
40 {
41 std::ios ios_01(0);
42 try {
43 ios_01.exceptions(std::ios_base::eofbit);
44 }
45 catch(...) {
46 VERIFY( false );
47 }
48 iostate02 = ios_01.exceptions();
49 VERIFY( static_cast<bool>(iostate02 & std::ios_base::eofbit) );
50 }
51
52 {
53 std::ios ios_01(0);
54 ios_01.clear(std::ios_base::eofbit);
55 try {
56 ios_01.exceptions(std::ios_base::eofbit);
57 VERIFY( false );
58 }
59 catch(std::ios_base::failure&) {
60 iostate02 = ios_01.exceptions();
61 VERIFY( static_cast<bool>(iostate02 & std::ios_base::eofbit) );
62 }
63 catch(...) {
64 VERIFY( false );
65 }
66 }
67 }
68
69 int main()
70 {
71 test01();
72 return 0;
73 }