2005-04-26 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / libstdc++-v3 / testsuite / testsuite_character.cc
blobb5bd4122e14f3cd483dd67c2793231193a0b885a
1 // -*- C++ -*-
3 // Utility subroutines for the C++ library testsuite.
4 //
5 // Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 2, or (at your option)
11 // any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING. If not, write to the Free
20 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // USA.
23 // As a special exception, you may use this file as part of a free software
24 // library without restriction. Specifically, if other files instantiate
25 // templates or use macros or inline functions from this file, or you compile
26 // this file and link it with other files to produce an executable, this
27 // file does not by itself cause the resulting executable to be covered by
28 // the GNU General Public License. This exception does not however
29 // invalidate any other reasons why the executable file might be covered by
30 // the GNU General Public License.
32 #include <testsuite_character.h>
34 namespace std
36 locale::id
37 codecvt<__gnu_test::pod_uchar, char, __gnu_test::pod_state>::id;
39 locale::id
40 ctype<__gnu_test::pod_uchar>::id;
42 // Member specializations for the existing facet classes.
43 // NB: This isn't especially portable. Perhaps a better way would be
44 // to just specialize all of numpunct and ctype.
45 using __gnu_test::pod_ushort;
46 typedef pod_ushort::value_type value_type;
48 template<>
49 bool
50 ctype<pod_ushort>::
51 do_is(mask, char_type) const { return true; }
53 template<>
54 const pod_ushort*
55 ctype<pod_ushort>::
56 do_is(const char_type* __lo, const char_type*, mask*) const
57 { return __lo; }
59 template<>
60 const pod_ushort*
61 ctype<pod_ushort>::
62 do_scan_is(mask, const char_type* __lo, const char_type*) const
63 { return __lo; }
65 template<>
66 const pod_ushort*
67 ctype<pod_ushort>::
68 do_scan_not(mask, const char_type* __lo, const char_type*) const
69 { return __lo; }
71 template<>
72 pod_ushort
73 ctype<pod_ushort>::
74 do_toupper(char_type __c) const
75 { return __c; }
77 template<>
78 const pod_ushort*
79 ctype<pod_ushort>::
80 do_toupper(char_type*, const char_type* __hi) const
81 { return __hi; }
83 template<>
84 pod_ushort
85 ctype<pod_ushort>::
86 do_tolower(char_type __c) const
87 { return __c; }
89 template<>
90 const pod_ushort*
91 ctype<pod_ushort>::
92 do_tolower(char_type*, const char_type* __hi) const
93 { return __hi; }
95 template<>
96 pod_ushort
97 ctype<pod_ushort>::
98 do_widen(char __c) const
100 char_type ret = { value_type(__c) };
101 return ret;
104 template<>
105 const char*
106 ctype<pod_ushort>::
107 do_widen(const char* __lo, const char* __hi, char_type* __dest) const
109 while (__lo < __hi)
111 *__dest = this->do_widen(*__lo);
112 ++__lo;
113 ++__dest;
115 return __hi;
118 template<>
119 char
120 ctype<pod_ushort>::
121 do_narrow(char_type __wc, char) const
122 { return static_cast<char>(__wc.value); }
124 template<>
125 const pod_ushort*
126 ctype<pod_ushort>::
127 do_narrow(const pod_ushort* __lo, const pod_ushort* __hi,
128 char, char* __dest) const
130 while (__lo < __hi)
132 *__dest = this->do_narrow(*__lo, char());
133 ++__lo;
134 ++__dest;
136 return __hi;
139 template<>
140 ctype<pod_ushort>::~ctype() { }
142 template<>
143 void
144 numpunct<pod_ushort>::_M_initialize_numpunct(__c_locale)
146 if (!_M_data)
147 _M_data = new __numpunct_cache<pod_ushort>;
149 _M_data->_M_grouping = "";
150 _M_data->_M_use_grouping = false;
152 _M_data->_M_decimal_point.value = value_type('.');
153 _M_data->_M_thousands_sep.value = value_type(',');
155 for (size_t i = 0; i < __num_base::_S_oend; ++i)
157 value_type v = __num_base::_S_atoms_out[i];
158 _M_data->_M_atoms_out[i].value = v;
160 _M_data->_M_atoms_out[__num_base::_S_oend] = pod_ushort();
162 for (size_t j = 0; j < __num_base::_S_iend; ++j)
163 _M_data->_M_atoms_in[j].value = value_type(__num_base::_S_atoms_in[j]);
164 _M_data->_M_atoms_in[__num_base::_S_iend] = pod_ushort();
166 // "true"
167 pod_ushort* __truename = new pod_ushort[4 + 1];
168 __truename[0].value = value_type('t');
169 __truename[1].value = value_type('r');
170 __truename[2].value = value_type('u');
171 __truename[3].value = value_type('e');
172 __truename[4] = pod_ushort();
173 _M_data->_M_truename = __truename;
175 // "false"
176 pod_ushort* __falsename = new pod_ushort[5 + 1];
177 __falsename[0].value = value_type('f');
178 __falsename[1].value = value_type('a');
179 __falsename[2].value = value_type('l');
180 __falsename[3].value = value_type('s');
181 __falsename[4].value = value_type('e');
182 __falsename[5] = pod_ushort();
183 _M_data->_M_falsename = __falsename;
186 template<>
187 numpunct<pod_ushort>::~numpunct()
188 { delete _M_data; }
189 } // namespace std