Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / testsuite / 22_locale / facet / 1.cc
blob78e1b42117f52cf07bb5d2d4f6f9cd5f0c084aea
1 // 2000-08-31 Benjamin Kosnik <bkoz@redhat.com>
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.
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.
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.
21 // 22.1.1.1.2 - class locale::facet [lib.locale.facet]
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>
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;
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> { };
49 class gnu_collate_byname: public std::collate_byname<char>
51 public:
52 explicit
53 gnu_collate_byname(const char* c, size_t refs = 0)
54 : std::collate_byname<char>(c, refs) { }
55 };
57 class gnu_ctype_byname: public std::ctype_byname<char>
59 public:
60 explicit
61 gnu_ctype_byname(const char* c, size_t refs = 0)
62 : std::ctype_byname<char>(c, refs) { }
63 };
65 class gnu_moneypunct_byname_true: public std::moneypunct_byname<char, true>
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 };
73 class gnu_moneypunct_byname_false: public std::moneypunct_byname<char, false>
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 };
82 class gnu_money_get_in: public std::money_get<char, input_iterator>
84 public:
85 explicit
86 gnu_money_get_in(size_t refs = 0)
87 : std::money_get<char, input_iterator>(refs) { }
90 class gnu_money_put_out: public std::money_put<char, output_iterator>
92 public:
93 explicit
94 gnu_money_put_out(size_t refs = 0)
95 : std::money_put<char, output_iterator>(refs) { }
98 class gnu_numpunct_byname: public std::numpunct_byname<char>
100 public:
101 explicit
102 gnu_numpunct_byname(const char* c, size_t refs = 0)
103 : std::numpunct_byname<char>(c, refs) { }
106 class gnu_num_get_in: public std::num_get<char, input_iterator>
108 public:
109 explicit
110 gnu_num_get_in(size_t refs = 0)
111 : std::num_get<char, input_iterator>(refs) { }
114 class gnu_num_put_out: public std::num_put<char, output_iterator>
116 public:
117 explicit
118 gnu_num_put_out(size_t refs = 0)
119 : std::num_put<char, output_iterator>(refs) { }
122 class gnu_time_get_byname: public std::time_get_byname<char>
124 public:
125 explicit
126 gnu_time_get_byname(const char* c, size_t refs = 0)
127 : std::time_get_byname<char>(c, refs) { }
130 class gnu_time_get_in: public std::time_get<char, input_iterator>
132 public:
133 explicit
134 gnu_time_get_in(size_t refs = 0)
135 : std::time_get<char, input_iterator>(refs) { }
138 class gnu_time_put_byname: public std::time_put_byname<char>
140 public:
141 explicit
142 gnu_time_put_byname(const char* c, size_t refs = 0)
143 : std::time_put_byname<char>(c, refs) { }
146 class gnu_time_put_out: public std::time_put<char, output_iterator>
148 public:
149 explicit
150 gnu_time_put_out(size_t refs = 0)
151 : std::time_put<char, output_iterator>(refs) { }
154 class gnu_messages_byname: public std::messages_byname<char>
156 public:
157 explicit
158 gnu_messages_byname(const char* c, size_t refs = 0)
159 : std::messages_byname<char>(c, refs) { }
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
167 public:
168 static std::locale::id id;
171 std::locale::id gnu_facet::id;
173 void test01()
175 bool test __attribute__((unused)) = true;
176 const std::string name_no("*");
177 const std::string name_c("C");
179 try
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);
209 catch (std::runtime_error& obj)
211 // named locale not valid
212 VERIFY( false );
214 catch (std::exception& obj)
216 // some other error
217 VERIFY( false );
220 // 2
223 gnu_facet obj28;
225 catch (std::runtime_error& obj)
227 // named locale not valid
228 VERIFY( false );
230 catch (std::exception& obj)
232 // some other error
233 VERIFY( false );
237 int main ()
239 test01();
240 return 0;