159024Sobrien// Copyright (C) 2003, 2005 Free Software Foundation, Inc. 277298Sobrien// 359024Sobrien// This file is part of the GNU ISO C++ Library. This library is free 459024Sobrien// software; you can redistribute it and/or modify it under the 559024Sobrien// terms of the GNU General Public License as published by the 659024Sobrien// Free Software Foundation; either version 2, or (at your option) 759024Sobrien// any later version. 859024Sobrien 959024Sobrien// This library is distributed in the hope that it will be useful, 1059024Sobrien// but WITHOUT ANY WARRANTY; without even the implied warranty of 1159024Sobrien// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1259024Sobrien// GNU General Public License for more details. 1359024Sobrien 1459024Sobrien// You should have received a copy of the GNU General Public License along 1559024Sobrien// with this library; see the file COPYING. If not, write to the Free 1659024Sobrien// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 1759024Sobrien// USA. 1859024Sobrien 1959024Sobrien// As a special exception, you may use this file as part of a free software 2059024Sobrien// library without restriction. Specifically, if other files instantiate 2159024Sobrien// templates or use macros or inline functions from this file, or you compile 2259024Sobrien// this file and link it with other files to produce an executable, this 2359024Sobrien// file does not by itself cause the resulting executable to be covered by 2459024Sobrien// the GNU General Public License. This exception does not however 2559024Sobrien// invalidate any other reasons why the executable file might be covered by 2659024Sobrien// the GNU General Public License. 2759024Sobrien 2859024Sobrien#include <ostream> 2959024Sobrien#include <streambuf> 3059024Sobrien#include <sstream> 3159024Sobrien#include <testsuite_hooks.h> 3260484Sobrien#include <testsuite_io.h> 3359024Sobrien 3460484Sobrienusing namespace std; 3560484Sobrien 3659024Sobrienvoid test01() 3759024Sobrien{ 3859024Sobrien bool test __attribute__((unused)) = true; 3959024Sobrien __gnu_test::fail_streambuf bib; 4059024Sobrien ostream stream(&bib); 4159024Sobrien stream.exceptions(ios_base::badbit); 4259024Sobrien 4359024Sobrien try 4459024Sobrien { 4559024Sobrien stream.flush(); 4659024Sobrien VERIFY( false ); 4759024Sobrien } 4859024Sobrien catch (const __gnu_test::positioning_error&) 4959024Sobrien { 5059024Sobrien // stream should set badbit and rethrow facet_error. 5159024Sobrien VERIFY( stream.bad() ); 5259024Sobrien VERIFY( (stream.rdstate() & ios_base::failbit) == 0 ); 5359024Sobrien VERIFY( !stream.eof() ); 5459024Sobrien } 5559024Sobrien catch (...) 5659024Sobrien { 5759024Sobrien VERIFY( false ); 5859024Sobrien } 5960484Sobrien} 6060484Sobrien 6159024Sobrien// libstdc++/9546 6260484Sobrienint main() 6360484Sobrien{ 6460484Sobrien test01(); 6560484Sobrien return 0; 6660484Sobrien} 6760484Sobrien