Dead
[official-gcc.git] / gomp-20050608-branch / libstdc++-v3 / testsuite / 27_io / basic_ostream / inserters_other / wchar_t / 5.cc
blob7a4c41dff4cd0a0b9a9eaddf648b1ebe1ef7ca04
1 // Copyright (C) 2005 Free Software Foundation
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
6 // Free Software Foundation; either version 2, or (at your option)
7 // any later version.
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,
17 // USA.
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.
25 #include <ostream>
26 #include <stdexcept>
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(""); }
39 template<typename T>
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
51 // called.
52 os.tie(&os_tie);
54 try
56 os << f;
57 // Exceptions thrown by f should not be caught
58 VERIFY( false );
60 catch (std::runtime_error&)
64 // Exceptions thrown by f should not cause badbit to be set
65 VERIFY( os.good() );
66 VERIFY( !buf_tie.sync_called() );
68 // The manipulator should be called even if !os.good().
69 os.setstate(std::ios_base::eofbit);
71 try
73 os << f;
74 // Exceptions thrown by f should not be caught
75 VERIFY( false );
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() );
86 void test05()
88 test(&func1);
89 test(&func2);
90 test(&func3);
93 int main()
95 test05();
96 return 0;