1139749Simp// Copyright (C) 2004 Free Software Foundation, Inc. 284059Swpaul// 384059Swpaul// This file is part of the GNU ISO C++ Library. This library is free 484059Swpaul// software; you can redistribute it and/or modify it under the 584059Swpaul// terms of the GNU General Public License as published by the 684059Swpaul// Free Software Foundation; either version 2, or (at your option) 784059Swpaul// any later version. 884059Swpaul 984059Swpaul// This library is distributed in the hope that it will be useful, 1084059Swpaul// but WITHOUT ANY WARRANTY; without even the implied warranty of 1184059Swpaul// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1284059Swpaul// GNU General Public License for more details. 1384059Swpaul 1484059Swpaul// You should have received a copy of the GNU General Public License along 1584059Swpaul// with this library; see the file COPYING. If not, write to the Free 1684059Swpaul// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 1784059Swpaul// USA. 1884059Swpaul 1984059Swpaul// As a special exception, you may use this file as part of a free software 2084059Swpaul// library without restriction. Specifically, if other files instantiate 2184059Swpaul// templates or use macros or inline functions from this file, or you compile 2284059Swpaul// this file and link it with other files to produce an executable, this 2384059Swpaul// file does not by itself cause the resulting executable to be covered by 2484059Swpaul// the GNU General Public License. This exception does not however 2584059Swpaul// invalidate any other reasons why the executable file might be covered by 2684059Swpaul// the GNU General Public License. 2784059Swpaul 2884059Swpaul#include <istream> 2984059Swpaul#include <streambuf> 3084059Swpaul#include <sstream> 3184059Swpaul#include <testsuite_hooks.h> 3284059Swpaul#include <testsuite_io.h> 3384059Swpaul 3484059Swpaulusing namespace std; 3584059Swpaul 3684059Swpaulvoid test14() 3784059Swpaul{ 3884059Swpaul bool test __attribute__((unused)) = true; 3984059Swpaul __gnu_test::fail_wstreambuf bib; 4084059Swpaul wistream stream(&bib); 4184059Swpaul stream.exceptions(ios_base::badbit); 4284059Swpaul wstringbuf sbuf(L"", ios_base::out); 4384059Swpaul 4484059Swpaul try 4584059Swpaul { 4684059Swpaul stream >> &sbuf; 4784059Swpaul } 4884059Swpaul catch (...) 4984059Swpaul { VERIFY( false ); } 5084059Swpaul 5184059Swpaul VERIFY( stream.rdstate() & ios_base::failbit ); 5284059Swpaul VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); 5384059Swpaul} 5484059Swpaul 5584059Swpaulvoid test16() 5684059Swpaul{ 5784059Swpaul bool test __attribute__((unused)) = true; 5884059Swpaul wistringstream stream(L"foo, bar, qux"); 5984059Swpaul stream.exceptions(ios_base::badbit); 6084059Swpaul __gnu_test::fail_wstreambuf bob; 6184059Swpaul 6284059Swpaul try 6384059Swpaul { 64166676Sjkim stream >> &bob; 65166676Sjkim } 66166676Sjkim catch (...) 67166676Sjkim { VERIFY( false ); } 68166676Sjkim 69166676Sjkim VERIFY( stream.rdstate() & ios_base::failbit ); 70166676Sjkim VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); 71166676Sjkim} 72166676Sjkim 73166676Sjkim// libstdc++/9371 74166676Sjkimint main() 75166676Sjkim{ 76166676Sjkim test14(); 77166676Sjkim test16(); 78166676Sjkim return 0; 79166676Sjkim} 80166676Sjkim