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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [22_locale/] [facet/] [1.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 2000-08-31 Benjamin Kosnik <bkoz@redhat.com>
2
 
3
// Copyright (C) 2000, 2002, 2003 Free Software Foundation
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 2, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING.  If not, write to the Free
18
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
// USA.
20
 
21
// 22.1.1.1.2 - class locale::facet [lib.locale.facet]
22
 
23
#include <cwchar> // for mbstate_t
24
#include <locale>
25
#include <stdexcept>
26
#include <string>
27
#include <iterator>
28
#include <limits>
29
#include <testsuite_hooks.h>
30
 
31
// 1 a class if a facet if it is publicly derived from another facet
32
typedef std::istreambuf_iterator<char>          input_iterator;
33
typedef std::ostreambuf_iterator<char>          output_iterator;
34
 
35
class gnu_collate: public std::collate<char> { };
36
class gnu_ctype: public std::ctype<char> { };
37
class gnu_codecvt: public std::codecvt<char, char, std::mbstate_t> { };
38
class gnu_moneypunct: public std::moneypunct<char> { };
39
class gnu_moneypunct_true: public std::moneypunct<char, true> { };
40
class gnu_money_get: public std::money_get<char> { };
41
class gnu_money_put: public std::money_put<char> { };
42
class gnu_numpunct: public std::numpunct<char> { };
43
class gnu_num_get: public std::num_get<char> { };
44
class gnu_num_put: public std::num_put<char> { };
45
class gnu_time_get: public std::time_get<char> { };
46
class gnu_time_put: public std::time_put<char> { };
47
class gnu_messages: public std::messages<char> { };
48
 
49
class gnu_collate_byname: public std::collate_byname<char>
50
{
51
public:
52
  explicit
53
  gnu_collate_byname(const char* c, size_t refs = 0)
54
  : std::collate_byname<char>(c, refs) { }
55
};
56
 
57
class gnu_ctype_byname: public std::ctype_byname<char>
58
{
59
public:
60
  explicit
61
  gnu_ctype_byname(const char* c, size_t refs = 0)
62
  : std::ctype_byname<char>(c, refs) { }
63
};
64
 
65
class gnu_moneypunct_byname_true: public std::moneypunct_byname<char, true>
66
{
67
public:
68
  explicit
69
  gnu_moneypunct_byname_true(const char* c, size_t refs = 0)
70
  : std::moneypunct_byname<char, true>(c, refs) { }
71
};
72
 
73
class gnu_moneypunct_byname_false: public std::moneypunct_byname<char, false>
74
{
75
public:
76
  explicit
77
  gnu_moneypunct_byname_false(const char* c, size_t refs = 0)
78
  : std::moneypunct_byname<char, false>(c, refs) { }
79
};
80
 
81
 
82
class gnu_money_get_in: public std::money_get<char, input_iterator>
83
{
84
public:
85
  explicit
86
  gnu_money_get_in(size_t refs = 0)
87
  : std::money_get<char, input_iterator>(refs) { }
88
};
89
 
90
class gnu_money_put_out: public std::money_put<char, output_iterator>
91
{
92
public:
93
  explicit
94
  gnu_money_put_out(size_t refs = 0)
95
  : std::money_put<char, output_iterator>(refs) { }
96
};
97
 
98
class gnu_numpunct_byname: public std::numpunct_byname<char>
99
{
100
public:
101
  explicit
102
  gnu_numpunct_byname(const char* c, size_t refs = 0)
103
  : std::numpunct_byname<char>(c, refs) { }
104
};
105
 
106
class gnu_num_get_in: public std::num_get<char, input_iterator>
107
{
108
public:
109
  explicit
110
  gnu_num_get_in(size_t refs = 0)
111
  : std::num_get<char, input_iterator>(refs) { }
112
};
113
 
114
class gnu_num_put_out: public std::num_put<char, output_iterator>
115
{
116
public:
117
  explicit
118
  gnu_num_put_out(size_t refs = 0)
119
  : std::num_put<char, output_iterator>(refs) { }
120
};
121
 
122
class gnu_time_get_byname: public std::time_get_byname<char>
123
{
124
public:
125
  explicit
126
  gnu_time_get_byname(const char* c, size_t refs = 0)
127
  : std::time_get_byname<char>(c, refs) { }
128
};
129
 
130
class gnu_time_get_in: public std::time_get<char, input_iterator>
131
{
132
public:
133
  explicit
134
  gnu_time_get_in(size_t refs = 0)
135
  : std::time_get<char, input_iterator>(refs) { }
136
};
137
 
138
class gnu_time_put_byname: public std::time_put_byname<char>
139
{
140
public:
141
  explicit
142
  gnu_time_put_byname(const char* c, size_t refs = 0)
143
  : std::time_put_byname<char>(c, refs) { }
144
};
145
 
146
class gnu_time_put_out: public std::time_put<char, output_iterator>
147
{
148
public:
149
  explicit
150
  gnu_time_put_out(size_t refs = 0)
151
  : std::time_put<char, output_iterator>(refs) { }
152
};
153
 
154
class gnu_messages_byname: public std::messages_byname<char>
155
{
156
public:
157
  explicit
158
  gnu_messages_byname(const char* c, size_t refs = 0)
159
  : std::messages_byname<char>(c, refs) { }
160
};
161
 
162
 
163
// 2 or if it is a class derived from locale:;facet and containing a
164
// publicly-accessible declaration as follows:
165
class gnu_facet: public std::locale::facet
166
{
167
public:
168
  static std::locale::id id;
169
};
170
 
171
std::locale::id gnu_facet::id;
172
 
173
void test01()
174
{
175
  bool test __attribute__((unused)) = true;
176
  const std::string name_no("*");
177
  const std::string name_c("C");
178
 
179
  try
180
    {
181
      gnu_collate                       obj01;
182
      gnu_ctype                         obj02;
183
      gnu_codecvt                       obj03;
184
      gnu_moneypunct                    obj04;
185
      gnu_moneypunct_true               obj05;
186
      gnu_money_get                     obj06;
187
      gnu_money_put                     obj07;
188
      gnu_numpunct                      obj08;
189
      gnu_num_get                       obj09;
190
      gnu_num_put                       obj10;
191
      gnu_time_get                      obj11;
192
      gnu_time_put                      obj12;
193
      gnu_messages                      obj13;
194
      gnu_time_put_out                  obj14(0);
195
      gnu_time_put_byname               obj15("C", 0);
196
      gnu_time_get_in                   obj16(0);
197
      gnu_time_get_byname               obj17("C", 0);
198
      gnu_num_put_out                   obj18(0);
199
      gnu_num_get_in                    obj19(0);
200
      gnu_numpunct_byname               obj20("C", 0);
201
      gnu_money_put_out                 obj21(0);
202
      gnu_money_get_in                  obj22(0);
203
      gnu_moneypunct_byname_false       obj23("C", 0);
204
      gnu_moneypunct_byname_true        obj24("C", 0);
205
      gnu_ctype_byname                  obj25("C", 0);
206
      gnu_collate_byname                obj26("C", 0);
207
      gnu_messages_byname               obj27("C", 0);
208
    }
209
  catch (std::runtime_error& obj)
210
    {
211
      // named locale not valid
212
      VERIFY( false );
213
    }
214
  catch (std::exception& obj)
215
    {
216
      // some other error
217
      VERIFY( false );
218
    }
219
 
220
  // 2
221
  try
222
    {
223
      gnu_facet                         obj28;
224
    }
225
  catch (std::runtime_error& obj)
226
    {
227
      // named locale not valid
228
      VERIFY( false );
229
    }
230
  catch (std::exception& obj)
231
    {
232
      // some other error
233
      VERIFY( false );
234
    }
235
}
236
 
237
int main ()
238
{
239
  test01();
240
  return 0;
241
}

powered by: WebSVN 2.1.0

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