OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_ostream/] [inserters_other/] [wchar_t/] [5.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 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.
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
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.
18
 
19
// 27.6.2.5.3 basic_ostream manipulator inserters
20
//
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.
24
 
25
#include <ostream>
26
#include <stdexcept>
27
#include <testsuite_hooks.h>
28
#include <testsuite_io.h>
29
 
30
std::wostream& func1(std::wostream&)
31
{ throw std::runtime_error(""); }
32
 
33
std::wios& func2(std::wios&)
34
{ throw std::runtime_error(""); }
35
 
36
std::ios_base& func3(std::ios_base&)
37
{ throw std::runtime_error(""); }
38
 
39
template<typename T>
40
void test(T& (*f)(T&))
41
{
42
  bool test __attribute__((unused)) = true;
43
 
44
  __gnu_test::sync_wstreambuf buf;
45
  std::wostream os(&buf);
46
 
47
  __gnu_test::sync_wstreambuf buf_tie;
48
  std::wostream os_tie(&buf_tie);
49
 
50
  // No sentry should be constructed so os.tie()->flush() should not be
51
  // called.
52
  os.tie(&os_tie);
53
 
54
  try
55
    {
56
      os << f;
57
      // Exceptions thrown by f should not be caught
58
      VERIFY( false );
59
    }
60
  catch (std::runtime_error&)
61
    {
62
    }
63
 
64
  // Exceptions thrown by f should not cause badbit to be set
65
  VERIFY( os.good() );
66
  VERIFY( !buf_tie.sync_called() );
67
 
68
  // The manipulator should be called even if !os.good().
69
  os.setstate(std::ios_base::eofbit);
70
 
71
  try
72
    {
73
      os << f;
74
      // Exceptions thrown by f should not be caught
75
      VERIFY( false );
76
    }
77
  catch (std::runtime_error&)
78
    {
79
    }
80
 
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() );
84
}
85
 
86
void test05()
87
{
88
  test(&func1);
89
  test(&func2);
90
  test(&func3);
91
}
92
 
93
int main()
94
{
95
  test05();
96
  return 0;
97
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.