]> gcc.gnu.org Git - gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc
Update copyright years.
[gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_ostream / exceptions / wchar_t / 9561.cc
CommitLineData
5624e564 1// Copyright (C) 2005-2015 Free Software Foundation, Inc.
ba4b172f
PC
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
748086b7 6// Free Software Foundation; either version 3, or (at your option)
ba4b172f
PC
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
748086b7
JJ
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
ba4b172f
PC
17
18#include <ostream>
19#include <streambuf>
20#include <testsuite_hooks.h>
21
22// libstdc++/9561
23struct foobar: std::exception { };
24
25struct buf: std::wstreambuf
26{
27 virtual int_type
28 overflow(int_type)
29 {
30 throw foobar();
31 return int_type();
32 }
33};
34
35void test01()
36{
37 using namespace std;
38 bool test __attribute__((unused)) = true;
39
40 buf b;
41 std::wostream strm(&b);
42 strm.exceptions(std::wios::badbit);
43
44 try
45 {
46 strm << std::endl;
47 }
48 catch(foobar)
49 {
50 // strm should throw foobar and not do anything else
51 VERIFY(strm.bad());
52 return;
53 }
54 catch(...)
55 {
56 VERIFY( false );
57 return;
58 }
59 VERIFY( false );
60}
61
62int main()
63{
64 test01();
65 return 0;
66}
This page took 0.976295 seconds and 5 git commands to generate.