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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [19_diagnostics/] [stdexcept.cc] - Blame information for rev 776

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// 2011-03-16 Benjamin Kosnik  <bkoz@redhat.com>
2
 
3
// Copyright (C) 2011
4
// Free Software Foundation, Inc.
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
#include <string>
22
#include <stdexcept>
23
#include <testsuite_hooks.h>
24
 
25
void test01()
26
{
27
  using namespace std;
28
  std::string s("error");
29
 
30
  try
31
    {
32
      logic_error e1(s);
33
      throw e1;
34
    }
35
  catch(const exception& e)
36
    {
37
      s = e.what();
38
    }
39
 
40
  try
41
    {
42
      domain_error e2(s);
43
      throw e2;
44
    }
45
  catch(const exception& e)
46
    {
47
      s = e.what();
48
    }
49
 
50
  try
51
    {
52
      invalid_argument e3(s);
53
      throw e3;
54
    }
55
  catch(const exception& e)
56
    {
57
      s = e.what();
58
    }
59
 
60
  try
61
    {
62
      length_error e4(s);
63
      throw e4;
64
    }
65
  catch(const exception& e)
66
    {
67
      s = e.what();
68
    }
69
 
70
  try
71
    {
72
      out_of_range e5(s);
73
      throw e5;
74
    }
75
  catch(const exception& e)
76
    {
77
      s = e.what();
78
    }
79
 
80
  try
81
    {
82
      runtime_error e6(s);
83
      throw e6;
84
    }
85
  catch(const exception& e)
86
    {
87
      s = e.what();
88
    }
89
 
90
  try
91
    {
92
      range_error e7(s);
93
      throw e7;
94
    }
95
  catch(const exception& e)
96
    {
97
      s = e.what();
98
    }
99
 
100
  try
101
    {
102
      overflow_error e8(s);
103
      throw e8;
104
    }
105
  catch(const exception& e)
106
    {
107
      s = e.what();
108
    }
109
 
110
  try
111
    {
112
      underflow_error e9(s);
113
      throw e9;
114
    }
115
  catch(const exception& e)
116
    {
117
      s = e.what();
118
    }
119
}
120
 
121
template<typename _Tp>
122
struct extra_error : public _Tp
123
{
124
  extra_error(const std::string& s) : _Tp(s) { }
125
};
126
 
127
void test02()
128
{
129
  using namespace std;
130
  std::string s("error");
131
 
132
  try
133
    {
134
      extra_error<logic_error> e1(s);
135
      throw e1;
136
    }
137
  catch(const exception& e)
138
    {
139
      s = e.what();
140
    }
141
 
142
  try
143
    {
144
      extra_error<domain_error> e2(s);
145
      throw e2;
146
    }
147
  catch(const exception& e)
148
    {
149
      s = e.what();
150
    }
151
 
152
  try
153
    {
154
      extra_error<invalid_argument> e3(s);
155
      throw e3;
156
    }
157
  catch(const exception& e)
158
    {
159
      s = e.what();
160
    }
161
 
162
  try
163
    {
164
      extra_error<length_error> e4(s);
165
      throw e4;
166
    }
167
  catch(const exception& e)
168
    {
169
      s = e.what();
170
    }
171
 
172
  try
173
    {
174
      extra_error<out_of_range> e5(s);
175
      throw e5;
176
    }
177
  catch(const exception& e)
178
    {
179
      s = e.what();
180
    }
181
 
182
  try
183
    {
184
      extra_error<runtime_error> e6(s);
185
      throw e6;
186
    }
187
  catch(const exception& e)
188
    {
189
      s = e.what();
190
    }
191
 
192
  try
193
    {
194
      extra_error<range_error> e7(s);
195
      throw e7;
196
    }
197
  catch(const exception& e)
198
    {
199
      s = e.what();
200
    }
201
 
202
  try
203
    {
204
      extra_error<overflow_error> e8(s);
205
      throw e8;
206
    }
207
  catch(const exception& e)
208
    {
209
      s = e.what();
210
    }
211
 
212
  try
213
    {
214
      extra_error<underflow_error> e9(s);
215
      throw e9;
216
    }
217
  catch(const exception& e)
218
    {
219
      s = e.what();
220
    }
221
}
222
 
223
int main(void)
224
{
225
  test01();
226
  test02();
227
  return 0;
228
}

powered by: WebSVN 2.1.0

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