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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [27_io/] [ios_base/] [storage/] [2.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// 2000-12-19 bkoz
2
 
3
// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
4
// Free Software Foundation
5
//
6
// This file is part of the GNU ISO C++ Library.  This library is free
7
// software; you can redistribute it and/or modify it under the
8
// terms of the GNU General Public License as published by the
9
// Free Software Foundation; either version 3, or (at your option)
10
// any later version.
11
 
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
// GNU General Public License for more details.
16
 
17
// You should have received a copy of the GNU General Public License along
18
// with this library; see the file COPYING3.  If not see
19
// <http://www.gnu.org/licenses/>.
20
 
21
// 27.4.2.5 ios_base storage functions
22
 
23
// XXX This test will not work for some versions of irix6 because of
24
// XXX bug(s) in libc malloc for very large allocations.  However
25
// XXX -lmalloc seems to work.
26
// See http://gcc.gnu.org/ml/gcc/2002-05/msg01012.html
27
// { dg-options "-lmalloc" { target mips*-*-irix6* } }
28
 
29
// This fails on some versions of Darwin 8 because malloc doesn't return
30
// NULL even if an allocation fails (filed as Radar 3884894).
31
// { dg-do run { xfail *-*-darwin8.[0-4].* } }
32
 
33
// Skip test at -m64 on Darwin because RLIMITS are not being honored.
34
// Radar 6467883: 10.4/10.5 setrlimits are not honored by memory allocators
35
// Radar 6467884: 10.X systems are not robust when paging space is exceeded
36
// { dg-skip-if "" { *-*-darwin* && lp64 } { "*" } { "" } } 
37
 
38
#include <sstream>
39
#include <iostream>
40
#include <limits>
41
#include <testsuite_hooks.h>
42
 
43
// libstdc++/3129
44
void test02()
45
{
46
  bool test __attribute__((unused)) = true;
47
  int max = std::numeric_limits<int>::max() - 1;
48
  std::stringbuf        strbuf;
49
  std::ios              ios(&strbuf);
50
 
51
  ios.exceptions(std::ios::badbit);
52
 
53
  long l = 0;
54
  void* v = 0;
55
 
56
  // pword
57
  ios.pword(1) = v;
58
  VERIFY( ios.pword(1) == v );
59
 
60
  try
61
    {
62
      v = ios.pword(max);
63
    }
64
  catch(std::ios_base::failure& obj)
65
    {
66
      // Ok.
67
      VERIFY( ios.bad() );
68
    }
69
  catch(...)
70
    {
71
      test = false;
72
      VERIFY( test );
73
    }
74
  VERIFY( v == 0 );
75
 
76
  VERIFY( ios.pword(1) == v );
77
 
78
  // max is different code path from max-1
79
  v = &test;
80
  try
81
    {
82
      v = ios.pword(std::numeric_limits<int>::max());
83
    }
84
  catch(std::ios_base::failure& obj)
85
    {
86
      // Ok.
87
      VERIFY( ios.bad() );
88
    }
89
  catch(...)
90
    {
91
      test = false;
92
      VERIFY( test );
93
    }
94
  VERIFY( v == &test );
95
 
96
  // iword
97
  ios.iword(1) = 1;
98
  VERIFY( ios.iword(1) == 1 );
99
 
100
  try
101
    {
102
      l = ios.iword(max);
103
    }
104
  catch(std::ios_base::failure& obj)
105
    {
106
      // Ok.
107
      VERIFY( ios.bad() );
108
    }
109
  catch(...)
110
    {
111
      test = false;
112
      VERIFY( test );
113
    }
114
  VERIFY( l == 0 );
115
 
116
  VERIFY( ios.iword(1) == 1 );
117
 
118
  // max is different code path from max-1
119
  l = 1;
120
  try
121
    {
122
      l = ios.iword(std::numeric_limits<int>::max());
123
    }
124
  catch(std::ios_base::failure& obj)
125
    {
126
      // Ok.
127
      VERIFY( ios.bad() );
128
    }
129
  catch(...)
130
    {
131
      test = false;
132
      VERIFY( test );
133
    }
134
  VERIFY( l == 1 );
135
 
136
}
137
 
138
int main(void)
139
{
140
  __gnu_test::set_memory_limits();
141
  test02();
142
  return 0;
143
}

powered by: WebSVN 2.1.0

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