Merged trunk at revision 161680 into branch.
[official-gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_ios / exceptions / char / 1.cc
blobf0494bd458df61d3963830d853f1a5510f058982
1 // 1999-09-20 bkoz
3 // Copyright (C) 1999, 2003, 2009, 2010 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.
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.
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/>.
21 // 27.4.4.2 basic_ios member functions
23 // NB: Don't include any other headers in this file.
24 #include <ios>
25 #include <testsuite_hooks.h>
27 void test01()
29 bool test __attribute__((unused)) = true;
31 typedef std::ios_base::fmtflags fmtflags;
32 typedef std::ios_base::iostate iostate;
33 using std::ios_base;
35 // iostate exceptions() const
36 iostate iostate02;
38 std::ios ios_01(0);
39 VERIFY( ios_01.exceptions() == std::ios_base::goodbit );
42 // void exceptions(iostate except)
44 std::ios ios_01(0);
45 try {
46 ios_01.exceptions(std::ios_base::eofbit);
48 catch(...) {
49 VERIFY( false );
51 iostate02 = ios_01.exceptions();
52 VERIFY( static_cast<bool>(iostate02 & std::ios_base::eofbit) );
56 std::ios ios_01(0);
57 ios_01.clear(std::ios_base::eofbit);
58 try {
59 ios_01.exceptions(std::ios_base::eofbit);
60 VERIFY( false );
62 catch(std::ios_base::failure& fail) {
63 iostate02 = ios_01.exceptions();
64 VERIFY( static_cast<bool>(iostate02 & std::ios_base::eofbit) );
66 catch(...) {
67 VERIFY( false );
72 int main()
74 test01();
75 return 0;