]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_ostream / flush / char / exceptions_badbit_throw.cc
index 943b6d41ea5bfe3548bc8dea8728a6db12b94436..2efd7cfa9583f37b4173b907762f686ac2e69744 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2003-2014 Free Software Foundation, Inc.
+// Copyright (C) 2003-2024 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -26,24 +26,25 @@ using namespace std;
 
 void test01()
 {
-  bool test __attribute__((unused)) = true;
   __gnu_test::fail_streambuf bib;
   ostream stream(&bib);
+
+  stream.flush(); // should catch exception and set badbit
+  VERIFY( stream.rdstate() == ios_base::badbit );
+
+  stream.clear();
   stream.exceptions(ios_base::badbit);
 
   try
     {
-      stream.flush();
+      stream.flush(); // should catch exception and set badbit and rethrow
       VERIFY( false );
     }
-  catch (const __gnu_test::positioning_error&) 
+  catch (const __gnu_test::positioning_error&)
     {
-      // stream should set badbit and rethrow facet_error.
-      VERIFY( stream.bad() );
-      VERIFY( (stream.rdstate() & ios_base::failbit) == 0 );
-      VERIFY( !stream.eof() );
+      VERIFY( stream.rdstate() == ios_base::badbit );
     }
-  catch (...) 
+  catch (...)
     {
       VERIFY( false );
     }