]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/exceptions_null.cc
New std::string implementation.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_ostream / inserters_other / char / exceptions_null.cc
CommitLineData
aa118a03 1// Copyright (C) 2003-2014 Free Software Foundation, Inc.
12841eb3
BK
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)
12841eb3
BK
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/>.
12841eb3 17
34a2b755
JW
18// The library still throws the original definition of std::ios::failure
19// { dg-options "-D_GLIBCXX_USE_CXX11_ABI=0" }
12841eb3
BK
20
21#include <istream>
22#include <ostream>
23#include <streambuf>
24#include <sstream>
25#include <testsuite_hooks.h>
26
12841eb3
BK
27void test1()
28{
ba4b172f 29 using namespace std;
12841eb3 30 bool test __attribute__((unused)) = true;
ba4b172f 31
12841eb3 32 ostringstream stream;
8fc81078 33 stream << static_cast<streambuf*>(0);
ba4b172f 34 VERIFY( stream.rdstate() & ios_base::badbit );
12841eb3
BK
35}
36
37void test3()
38{
ba4b172f 39 using namespace std;
12841eb3 40 bool test __attribute__((unused)) = true;
ba4b172f 41
12841eb3
BK
42 ostringstream stream;
43 stream.exceptions(ios_base::badbit);
44
45 try
46 {
8fc81078 47 stream << static_cast<streambuf*>(0);
ba4b172f 48 VERIFY( false );
12841eb3
BK
49 }
50 catch (ios_base::failure&)
51 {
52 }
53
ba4b172f 54 VERIFY( stream.rdstate() & ios_base::badbit );
12841eb3
BK
55}
56
57// libstdc++/9371
58int main()
59{
60 test1();
61 test3();
62 return 0;
63}