]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/exceptions_null.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_ostream / inserters_other / char / exceptions_null.cc
CommitLineData
f1717362 1// Copyright (C) 2003-2016 Free Software Foundation, Inc.
92fe9461 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
6bc9506f 6// Free Software Foundation; either version 3, or (at your option)
92fe9461 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
6bc9506f 15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
92fe9461 17
63f54259 18// The library still throws the original definition of std::ios::failure
19// { dg-options "-D_GLIBCXX_USE_CXX11_ABI=0" }
92fe9461 20
21#include <istream>
22#include <ostream>
23#include <streambuf>
24#include <sstream>
25#include <testsuite_hooks.h>
26
92fe9461 27void test1()
28{
bb135391 29 using namespace std;
92fe9461 30 bool test __attribute__((unused)) = true;
bb135391 31
92fe9461 32 ostringstream stream;
e4bb1925 33 stream << static_cast<streambuf*>(0);
bb135391 34 VERIFY( stream.rdstate() & ios_base::badbit );
92fe9461 35}
36
37void test3()
38{
bb135391 39 using namespace std;
92fe9461 40 bool test __attribute__((unused)) = true;
bb135391 41
92fe9461 42 ostringstream stream;
43 stream.exceptions(ios_base::badbit);
44
45 try
46 {
e4bb1925 47 stream << static_cast<streambuf*>(0);
bb135391 48 VERIFY( false );
92fe9461 49 }
50 catch (ios_base::failure&)
51 {
52 }
53
bb135391 54 VERIFY( stream.rdstate() & ios_base::badbit );
92fe9461 55}
56
57// libstdc++/9371
58int main()
59{
60 test1();
61 test3();
62 return 0;
63}