1 // Copyright (C) 2005 Free Software Foundation
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
6 // Free Software Foundation; either version 2, or (at your option)
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.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING. If not, write to the Free
16 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // 27.6.2.5.3 basic_ostream manipulator inserters
21 // _GLIBCXX_RESOLVE_LIB_DEFECTS
22 // DR 60. What is a formatted input function?
23 // Inserters for manipulators do not behave as formatted output functions.
27 #include <testsuite_hooks.h>
28 #include <testsuite_io.h>
30 std::wostream
& func1(std::wostream
&)
31 { throw std::runtime_error(""); }
33 std::wios
& func2(std::wios
&)
34 { throw std::runtime_error(""); }
36 std::ios_base
& func3(std::ios_base
&)
37 { throw std::runtime_error(""); }
40 void test(T
& (*f
)(T
&))
42 bool test
__attribute__((unused
)) = true;
44 __gnu_test::sync_wstreambuf buf
;
45 std::wostream
os(&buf
);
47 __gnu_test::sync_wstreambuf buf_tie
;
48 std::wostream
os_tie(&buf_tie
);
50 // No sentry should be constructed so os.tie()->flush() should not be
57 // Exceptions thrown by f should not be caught
60 catch (std::runtime_error
&)
64 // Exceptions thrown by f should not cause badbit to be set
66 VERIFY( !buf_tie
.sync_called() );
68 // The manipulator should be called even if !os.good().
69 os
.setstate(std::ios_base::eofbit
);
74 // Exceptions thrown by f should not be caught
77 catch (std::runtime_error
&)
81 // Exceptions thrown by f should not cause badbit to be set
82 VERIFY( os
.rdstate() == std::ios_base::eofbit
);
83 VERIFY( !buf_tie
.sync_called() );