]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/facet/1.cc
Reshuffle 22_locale testsuite.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / facet / 1.cc
CommitLineData
0479a462
BK
1// 2000-08-31 Benjamin Kosnik <bkoz@redhat.com>
2
5f8d36fe 3// Copyright (C) 2000, 2002, 2003 Free Software Foundation
0479a462
BK
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19// USA.
20
21// 22.1.1.1.2 - class locale::facet [lib.locale.facet]
22
4bc95009 23#include <cwchar> // for mbstate_t
0479a462 24#include <locale>
0214010c
BK
25#include <stdexcept>
26#include <string>
0479a462 27#include <iterator>
aa53f832 28#include <limits>
fe413112 29#include <testsuite_hooks.h>
0479a462
BK
30
31// 1 a class if a facet if it is publicly derived from another facet
3e80ddc7
BK
32typedef std::istreambuf_iterator<char> input_iterator;
33typedef std::ostreambuf_iterator<char> output_iterator;
0479a462
BK
34
35class gnu_collate: public std::collate<char> { };
36class gnu_ctype: public std::ctype<char> { };
4bc95009 37class gnu_codecvt: public std::codecvt<char, char, std::mbstate_t> { };
0479a462
BK
38class gnu_moneypunct: public std::moneypunct<char> { };
39class gnu_moneypunct_true: public std::moneypunct<char, true> { };
40class gnu_money_get: public std::money_get<char> { };
41class gnu_money_put: public std::money_put<char> { };
42class gnu_numpunct: public std::numpunct<char> { };
43class gnu_num_get: public std::num_get<char> { };
44class gnu_num_put: public std::num_put<char> { };
45class gnu_time_get: public std::time_get<char> { };
46class gnu_time_put: public std::time_put<char> { };
47class gnu_messages: public std::messages<char> { };
48
49class gnu_collate_byname: public std::collate_byname<char>
50{
51public:
52 explicit
53 gnu_collate_byname(const char* c, size_t refs = 0)
54 : std::collate_byname<char>(c, refs) { }
55};
56
57class gnu_ctype_byname: public std::ctype_byname<char>
58{
59public:
60 explicit
61 gnu_ctype_byname(const char* c, size_t refs = 0)
62 : std::ctype_byname<char>(c, refs) { }
63};
64
65class gnu_moneypunct_byname_true: public std::moneypunct_byname<char, true>
66{
67public:
68 explicit
69 gnu_moneypunct_byname_true(const char* c, size_t refs = 0)
70 : std::moneypunct_byname<char, true>(c, refs) { }
71};
72
73class gnu_moneypunct_byname_false: public std::moneypunct_byname<char, false>
74{
75public:
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
3e80ddc7 82class gnu_money_get_in: public std::money_get<char, input_iterator>
0479a462
BK
83{
84public:
85 explicit
86 gnu_money_get_in(size_t refs = 0)
3e80ddc7 87 : std::money_get<char, input_iterator>(refs) { }
0479a462
BK
88};
89
3e80ddc7 90class gnu_money_put_out: public std::money_put<char, output_iterator>
0479a462
BK
91{
92public:
93 explicit
94 gnu_money_put_out(size_t refs = 0)
3e80ddc7 95 : std::money_put<char, output_iterator>(refs) { }
0479a462
BK
96};
97
98class gnu_numpunct_byname: public std::numpunct_byname<char>
99{
100public:
101 explicit
102 gnu_numpunct_byname(const char* c, size_t refs = 0)
103 : std::numpunct_byname<char>(c, refs) { }
104};
105
3e80ddc7 106class gnu_num_get_in: public std::num_get<char, input_iterator>
0479a462
BK
107{
108public:
109 explicit
110 gnu_num_get_in(size_t refs = 0)
3e80ddc7 111 : std::num_get<char, input_iterator>(refs) { }
0479a462
BK
112};
113
3e80ddc7 114class gnu_num_put_out: public std::num_put<char, output_iterator>
0479a462
BK
115{
116public:
117 explicit
118 gnu_num_put_out(size_t refs = 0)
3e80ddc7 119 : std::num_put<char, output_iterator>(refs) { }
0479a462
BK
120};
121
122class gnu_time_get_byname: public std::time_get_byname<char>
123{
124public:
125 explicit
126 gnu_time_get_byname(const char* c, size_t refs = 0)
127 : std::time_get_byname<char>(c, refs) { }
128};
129
3e80ddc7 130class gnu_time_get_in: public std::time_get<char, input_iterator>
0479a462
BK
131{
132public:
133 explicit
134 gnu_time_get_in(size_t refs = 0)
3e80ddc7 135 : std::time_get<char, input_iterator>(refs) { }
0479a462
BK
136};
137
138class gnu_time_put_byname: public std::time_put_byname<char>
139{
140public:
141 explicit
142 gnu_time_put_byname(const char* c, size_t refs = 0)
143 : std::time_put_byname<char>(c, refs) { }
144};
145
3e80ddc7 146class gnu_time_put_out: public std::time_put<char, output_iterator>
0479a462
BK
147{
148public:
149 explicit
150 gnu_time_put_out(size_t refs = 0)
3e80ddc7 151 : std::time_put<char, output_iterator>(refs) { }
0479a462
BK
152};
153
154class gnu_messages_byname: public std::messages_byname<char>
155{
156public:
157 explicit
158 gnu_messages_byname(const char* c, size_t refs = 0)
159 : std::messages_byname<char>(c, refs) { }
160};
161
162
def9790d 163// 2 or if it is a class derived from locale:;facet and containing a
0479a462
BK
164// publicly-accessible declaration as follows:
165class gnu_facet: public std::locale::facet
166{
167public:
168 static std::locale::id id;
169};
170
171std::locale::id gnu_facet::id;
172
173void test01()
174{
0214010c
BK
175 bool test = 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 }
0479a462
BK
219
220 // 2
0214010c
BK
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 }
0479a462
BK
235}
236
237int main ()
238{
239 test01();
0479a462
BK
240 return 0;
241}