ReactOS 0.4.15-dev-5884-gab5aff5
LocaleTest Class Reference

#include <locale_test.h>

Inheritance diagram for LocaleTest:
Collaboration diagram for LocaleTest:

Public Member Functions

void locale_by_name ()
 
void loc_has_facet ()
 
void num_put_get ()
 
void numpunct_by_name ()
 
void time_put_get ()
 
void time_by_name ()
 
void collate_facet ()
 
void collate_by_name ()
 
void ctype_facet ()
 
void ctype_by_name ()
 
void locale_init_problem ()
 
void money_put_get ()
 
void money_put_X_bug ()
 
void moneypunct_by_name ()
 
void default_locale ()
 
void combine ()
 
void messages_by_name ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (LocaleTest)
 
 CPPUNIT_TEST (locale_by_name)
 
 CPPUNIT_TEST (moneypunct_by_name)
 
 CPPUNIT_TEST (time_by_name)
 
 CPPUNIT_TEST (numpunct_by_name)
 
 CPPUNIT_TEST (ctype_by_name)
 
 CPPUNIT_TEST (collate_by_name)
 
 CPPUNIT_TEST (messages_by_name)
 
 CPPUNIT_TEST (loc_has_facet)
 
 CPPUNIT_TEST (num_put_get)
 
 CPPUNIT_TEST (money_put_get)
 
 CPPUNIT_TEST (money_put_X_bug)
 
 CPPUNIT_TEST (time_put_get)
 
 CPPUNIT_TEST (collate_facet)
 
 CPPUNIT_TEST (ctype_facet)
 
 CPPUNIT_TEST (locale_init_problem)
 
 CPPUNIT_TEST (default_locale)
 
 CPPUNIT_TEST (combine)
 
 CPPUNIT_TEST_SUITE_END ()
 
void _loc_has_facet (const STD locale &)
 
void _num_put_get (const STD locale &, const ref_locale *)
 
void _time_put_get (const STD locale &)
 
void _ctype_facet (const STD locale &)
 
void _ctype_facet_w (const STD locale &)
 
void _locale_init_problem (const STD locale &)
 
void _money_put_get (const STD locale &, const ref_monetary *)
 
void _money_put_get2 (const STD locale &loc, const STD locale &streamLoc, const ref_monetary *)
 
void _money_put_X_bug (const STD locale &, const ref_monetary *)
 

Static Private Member Functions

static const ref_monetary_get_ref_monetary (size_t)
 
static const char_get_ref_monetary_name (const ref_monetary *)
 

Private Attributes

 CPPUNIT_STOP_IGNORE
 
 CPPUNIT_IGNORE
 

Detailed Description

Definition at line 20 of file locale_test.h.

Member Function Documentation

◆ _ctype_facet()

void LocaleTest::_ctype_facet ( const STD locale )
private

Definition at line 27 of file ctype_facets_test.cpp.

28{
30 ctype<char> const& ct = use_facet<ctype<char> >(loc);
31 //is
32 {
33 CPPUNIT_ASSERT( ct.is(ctype_base::digit, '0') );
34 CPPUNIT_ASSERT( ct.is(ctype_base::upper, 'A') );
35 CPPUNIT_ASSERT( ct.is(ctype_base::lower, 'a') );
36 CPPUNIT_ASSERT( ct.is(ctype_base::alpha, 'A') );
37 CPPUNIT_ASSERT( ct.is(ctype_base::space, ' ') );
38 CPPUNIT_ASSERT( !ct.is(ctype_base::space, '2') );
39 CPPUNIT_ASSERT( ct.is(ctype_base::punct, '.') );
41 }
42
43 //is range
44 {
45 char values[] = "0Aa .";
47 ct.is(values, values + sizeof(values), res);
48 // '0'
52 // 'A'
57 // 'a'
63 // ' '
67 // '.'
71 }
72
73 //scan_is
74 {
75 char range[] = "abAc123 .";
76 const char *rbeg = range;
77 const char *rend = range + sizeof(range);
78
79 const char *res;
80 res = ct.scan_is((ctype_base::mask)(ctype_base::alpha | ctype_base::lower), rbeg, rend);
81 CPPUNIT_ASSERT( res != rend );
82 CPPUNIT_ASSERT( *res == 'a' );
83
84 res = ct.scan_is(ctype_base::upper, rbeg, rend);
85 CPPUNIT_ASSERT( res != rend );
86 CPPUNIT_ASSERT( *res == 'A' );
87
88 res = ct.scan_is(ctype_base::punct, rbeg, rend);
89 CPPUNIT_ASSERT( res != rend );
90 CPPUNIT_ASSERT( *res == '.' );
91 }
92
93 //scan_not
94 {
95 char range[] = "abAc123 .";
96 const char *rbeg = range;
97 const char *rend = range + sizeof(range);
98
99 const char *res;
100 res = ct.scan_not((ctype_base::mask)(ctype_base::alpha | ctype_base::lower), rbeg, rend);
101 CPPUNIT_ASSERT( res != rend );
102 CPPUNIT_ASSERT( *res == '1' );
103
104 res = ct.scan_not(ctype_base::alpha, rbeg, rend);
105 CPPUNIT_ASSERT( res != rend );
106 CPPUNIT_ASSERT( *res == '1' );
107
108 res = ct.scan_not(ctype_base::punct, rbeg, rend);
109 CPPUNIT_ASSERT( res != rend );
110 CPPUNIT_ASSERT( *res == 'a' );
111 }
112
113 //toupper
114 {
115 CPPUNIT_ASSERT( ct.toupper('a') == 'A' );
116 CPPUNIT_ASSERT( ct.toupper('A') == 'A' );
117 CPPUNIT_ASSERT( ct.toupper('1') == '1' );
118 }
119
120 //toupper range
121 {
122 char range[] = "abAc1";
123 char expected_range[] = "ABAC1";
124 ct.toupper(range, range + sizeof(range));
125 CPPUNIT_ASSERT( equal(range, range + sizeof(range), expected_range) );
126 }
127
128 //tolower
129 {
130 CPPUNIT_ASSERT( ct.tolower('A') == 'a' );
131 CPPUNIT_ASSERT( ct.tolower('a') == 'a' );
132 CPPUNIT_ASSERT( ct.tolower('1') == '1' );
133 }
134
135 //tolower range
136 {
137 char range[] = "ABaC1";
138 char expected_range[] = "abac1";
139 ct.tolower(range, range + sizeof(range));
140 CPPUNIT_ASSERT( equal(range, range + sizeof(range), expected_range) );
141 }
142
143 //widen
144 {
145 CPPUNIT_ASSERT( ct.widen('a') == 'a' );
146 }
147
148 //widen range
149 {
150 char range[] = "ABaC1";
151 char res[sizeof(range)];
152 ct.widen(range, range + sizeof(range), res);
153 CPPUNIT_ASSERT( equal(range, range + sizeof(range), res) );
154 }
155
156 //narrow
157 {
158 CPPUNIT_ASSERT( ct.narrow('a', 'b') == 'a' );
159 }
160
161 //narrow range
162 {
163 char range[] = "ABaC1";
164 char res[sizeof(range)];
165 ct.narrow(range, range + sizeof(range), 'b', res);
166 CPPUNIT_ASSERT( equal(range, range + sizeof(range), res) );
167 }
168}
bool has_facet(const locale &__loc) _STLP_NOTHROW
Definition: _locale.h:304
@ alpha
Definition: _ctype.h:47
@ lower
Definition: _ctype.h:46
@ space
Definition: _ctype.h:42
@ xdigit
Definition: _ctype.h:50
@ print
Definition: _ctype.h:43
@ upper
Definition: _ctype.h:45
@ punct
Definition: _ctype.h:49
@ digit
Definition: _ctype.h:48
Definition: _ctype.h:58
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLuint res
Definition: glext.h:9613
GLenum GLint * range
Definition: glext.h:7539
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
#define equal(x, y)
Definition: reader.cc:56

Referenced by ctype_facet().

◆ _ctype_facet_w()

void LocaleTest::_ctype_facet_w ( const STD locale )
private

Definition at line 170 of file ctype_facets_test.cpp.

171{
172# ifndef _STLP_NO_WCHAR_T
174 ctype<wchar_t> const& wct = use_facet<ctype<wchar_t> >(loc);
175 //is
176 {
177 CPPUNIT_CHECK( wct.is(ctype_base::digit, L'0') );
178 CPPUNIT_CHECK( wct.is(ctype_base::upper, L'A') );
179 CPPUNIT_CHECK( wct.is(ctype_base::lower, L'a') );
180 CPPUNIT_CHECK( wct.is(ctype_base::alpha, L'A') );
181 CPPUNIT_CHECK( wct.is(ctype_base::space, L' ') );
182 CPPUNIT_CHECK( !wct.is(ctype_base::space, L'2') );
183 CPPUNIT_CHECK( wct.is(ctype_base::punct, L'.') );
184 CPPUNIT_CHECK( wct.is(ctype_base::xdigit, L'a') );
185 }
186
187 //is range
188 {
189 wchar_t values[] = L"0Aa .";
190 ctype_base::mask res[sizeof(values) / sizeof(wchar_t)];
191 wct.is(values, values + (sizeof(values) / sizeof(wchar_t)), res);
192 // '0'
193 CPPUNIT_CHECK( (res[0] & ctype_base::print) != 0 );
194 CPPUNIT_CHECK( (res[0] & ctype_base::digit) != 0 );
195 CPPUNIT_CHECK( (res[0] & ctype_base::xdigit) != 0 );
196 // 'A'
197 CPPUNIT_CHECK( (res[1] & ctype_base::print) != 0 );
198 CPPUNIT_CHECK( (res[1] & ctype_base::alpha) != 0 );
199 CPPUNIT_CHECK( (res[1] & ctype_base::xdigit) != 0 );
200 CPPUNIT_CHECK( (res[1] & ctype_base::upper) != 0 );
201 // 'a'
202 CPPUNIT_CHECK( (res[2] & ctype_base::print) != 0 );
203 CPPUNIT_CHECK( (res[2] & ctype_base::alpha) != 0 );
204 CPPUNIT_CHECK( (res[2] & ctype_base::xdigit) != 0 );
205 CPPUNIT_CHECK( (res[2] & ctype_base::lower) != 0 );
206 CPPUNIT_CHECK( (res[2] & ctype_base::space) == 0 );
207 // ' '
208 CPPUNIT_CHECK( (res[3] & ctype_base::print) != 0 );
209 CPPUNIT_CHECK( (res[3] & ctype_base::space) != 0 );
210 CPPUNIT_CHECK( (res[3] & ctype_base::digit) == 0 );
211 // '.'
212 CPPUNIT_CHECK( (res[4] & ctype_base::print) != 0 );
213 CPPUNIT_CHECK( (res[4] & ctype_base::punct) != 0 );
214 CPPUNIT_CHECK( (res[4] & ctype_base::digit) == 0 );
215 }
216
217 //scan_is
218 {
219 wchar_t range[] = L"abAc123 .";
220 const wchar_t *rbeg = range;
221 const wchar_t *rend = range + (sizeof(range) / sizeof(wchar_t));
222
223 const wchar_t *res;
224 res = wct.scan_is((ctype_base::mask)(ctype_base::alpha | ctype_base::lower), rbeg, rend);
225 CPPUNIT_CHECK( res != rend );
226 CPPUNIT_CHECK( *res == L'a' );
227
228 res = wct.scan_is(ctype_base::upper, rbeg, rend);
229 CPPUNIT_CHECK( res != rend );
230 CPPUNIT_CHECK( *res == L'A' );
231
232 res = wct.scan_is(ctype_base::punct, rbeg, rend);
233 CPPUNIT_CHECK( res != rend );
234 CPPUNIT_CHECK( *res == L'.' );
235 }
236
237 //scan_not
238 {
239 wchar_t range[] = L"abAc123 .";
240 const wchar_t *rbeg = range;
241 const wchar_t *rend = range + (sizeof(range) / sizeof(wchar_t));
242
243 const wchar_t *res;
244 res = wct.scan_not((ctype_base::mask)(ctype_base::alpha | ctype_base::lower), rbeg, rend);
245 CPPUNIT_CHECK( res != rend );
246 CPPUNIT_CHECK( *res == L'1' );
247
248 res = wct.scan_not(ctype_base::alpha, rbeg, rend);
249 CPPUNIT_CHECK( res != rend );
250 CPPUNIT_CHECK( *res == L'1' );
251
252 res = wct.scan_not(ctype_base::punct, rbeg, rend);
253 CPPUNIT_CHECK( res != rend );
254 CPPUNIT_CHECK( *res == L'a' );
255 }
256
257 //toupper
258 {
259 CPPUNIT_CHECK( wct.toupper(L'a') == L'A' );
260 CPPUNIT_CHECK( wct.toupper(L'A') == L'A' );
261 CPPUNIT_CHECK( wct.toupper(L'1') == L'1' );
262 }
263
264 //toupper range
265 {
266 wchar_t range[] = L"abAc1";
267 wchar_t expected_range[] = L"ABAC1";
268 wct.toupper(range, range + sizeof(range) / sizeof(wchar_t));
269 CPPUNIT_CHECK( equal(range, range + sizeof(range) / sizeof(wchar_t), expected_range) );
270 }
271
272 //tolower
273 {
274 CPPUNIT_CHECK( wct.tolower(L'A') == L'a' );
275 CPPUNIT_CHECK( wct.tolower(L'a') == L'a' );
276 CPPUNIT_CHECK( wct.tolower(L'1') == L'1' );
277 }
278
279 //tolower range
280 {
281 wchar_t range[] = L"ABaC1";
282 wchar_t expected_range[] = L"abac1";
283 wct.tolower(range, range + sizeof(range) / sizeof(wchar_t));
284 CPPUNIT_CHECK( equal(range, range + sizeof(range) / sizeof(wchar_t), expected_range) );
285 }
286
287 //widen
288 {
289 CPPUNIT_CHECK( wct.widen('a') == L'a' );
290 }
291
292 //widen range
293 {
294 char range[] = "ABaC1";
295 wchar_t res[sizeof(range)];
296 wchar_t expected_res[] = L"ABaC1";
297 wct.widen(range, range + sizeof(range), res);
298 CPPUNIT_CHECK( equal(expected_res, expected_res + sizeof(range), res) );
299 }
300
301 //narrow
302 {
303 CPPUNIT_CHECK( wct.narrow(L'a', 'b') == L'a' );
304 }
305
306 //narrow range
307 {
308 wchar_t range[] = L"ABaC1";
309 char res[sizeof(range) / sizeof(wchar_t)];
310 char expected_res[] = "ABaC1";
311 wct.narrow(range, range + sizeof(range) / sizeof(wchar_t), 'b', res);
312 CPPUNIT_CHECK( equal(expected_res, expected_res + sizeof(range) / sizeof(wchar_t), res) );
313 }
314# endif
315}
#define CPPUNIT_CHECK(X)
Definition: cppunit_mini.h:195
#define L(x)
Definition: ntvdm.h:50
#define wchar_t
Definition: wchar.h:102

Referenced by ctype_facet().

◆ _get_ref_monetary()

const ref_monetary * LocaleTest::_get_ref_monetary ( size_t  i)
staticprivate

Definition at line 39 of file money_facets_test.cpp.

40{
41 if (i < sizeof(tested_locales) / sizeof(tested_locales[0])) {
42 return tested_locales + i;
43 }
44 return 0;
45}
static const char * tested_locales[]
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by combine().

◆ _get_ref_monetary_name()

const char * LocaleTest::_get_ref_monetary_name ( const ref_monetary _ref)
staticprivate

Definition at line 47 of file money_facets_test.cpp.

48{
49 return _ref->name;
50}
const char * name

Referenced by combine().

◆ _loc_has_facet()

void LocaleTest::_loc_has_facet ( const STD locale )
private

◆ _locale_init_problem()

void LocaleTest::_locale_init_problem ( const STD locale )
private

Definition at line 170 of file locale_test.cpp.

171{
172# if !defined (__APPLE__) && !defined (__FreeBSD__) || \
173 !defined(__GNUC__) || ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__> 3)))
174 typedef codecvt<char,char,mbstate_t> my_facet;
175# else
176// std::mbstate_t required for gcc 3.3.2 on FreeBSD...
177// I am not sure what key here---FreeBSD or 3.3.2...
178// - ptr 2005-04-04
179 typedef codecvt<char,char,std::mbstate_t> my_facet;
180# endif
181
182 locale loc_ref(global_loc);
183 {
184 locale gloc( loc_ref, new my_facet() );
185 CPPUNIT_ASSERT( has_facet<my_facet>( gloc ) );
186 //The following code is just here to try to confuse the reference counting underlying mecanism:
188 locale::global( gloc );
189 }
190
191# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
192 try {
193# endif
194 ostringstream os("test") ;
195 locale loc2( loc, new my_facet() );
196 CPPUNIT_ASSERT( has_facet<my_facet>( loc2 ) );
197 os.imbue( loc2 );
198# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
199 }
200 catch ( runtime_error& ) {
202 }
203 catch ( ... ) {
205 }
206# endif
207
208# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
209 try {
210# endif
211 ostringstream os2("test2");
212# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
213 }
214 catch ( runtime_error& ) {
216 }
217 catch ( ... ) {
219 }
220# endif
221}
Definition: _locale.h:75
static locale _STLP_CALL global(const locale &)
Definition: locale.cpp:409
static const locale &_STLP_CALL classic()
Definition: locale.cpp:404
#define CPPUNIT_FAIL
Definition: cppunit_mini.h:206
static locale global_loc

Referenced by locale_init_problem().

◆ _money_put_get()

void LocaleTest::_money_put_get ( const STD locale ,
const ref_monetary  
)
private

Definition at line 52 of file money_facets_test.cpp.

53{
54 _money_put_get2(loc, loc, rl);
55}
void _money_put_get2(const STD locale &loc, const STD locale &streamLoc, const ref_monetary *)

Referenced by money_put_get().

◆ _money_put_get2()

void LocaleTest::_money_put_get2 ( const STD locale loc,
const STD locale streamLoc,
const ref_monetary  
)
private

Definition at line 57 of file money_facets_test.cpp.

58{
59 const ref_monetary &rl = *prl;
61 money_put<char> const& fmp = use_facet<money_put<char> >(loc);
63 money_get<char> const& fmg = use_facet<money_get<char> >(loc);
64
65 ostringstream ostr;
66 ostr.imbue(streamLoc);
67 ostr << showbase;
68
69 //Check a positive value (international format)
70 {
71 string str_res;
72 //money_put
73 {
75 moneypunct<char, true> const& intl_fmp = use_facet<moneypunct<char, true> >(loc);
76
77 ostreambuf_iterator<char, char_traits<char> > res = fmp.put(ostr, true, ostr, ' ', 123456);
78
79 CPPUNIT_ASSERT( !res.failed() );
80 str_res = ostr.str();
81 //CPPUNIT_MESSAGE(str_res.c_str());
82
83 size_t fieldIndex = 0;
84 size_t index = 0;
85
86 //On a positive value we skip the sign field if exists:
87 if (intl_fmp.pos_format().field[fieldIndex] == money_base::sign) {
88 ++fieldIndex;
89 }
90 // international currency abbreviation, if it is before value
91
92 /*
93 * int_curr_symbol
94 *
95 * The international currency symbol. The operand is a four-character
96 * string, with the first three characters containing the alphabetic
97 * international currency symbol in accordance with those specified
98 * in the ISO 4217 specification. The fourth character is the character used
99 * to separate the international currency symbol from the monetary quantity.
100 *
101 * (http://www.opengroup.org/onlinepubs/7990989775/xbd/locale.html)
102 */
103 string::size_type p = strlen( rl.money_int_prefix );
104 if (p != 0) {
105 CPPUNIT_ASSERT( intl_fmp.pos_format().field[fieldIndex] == money_base::symbol );
106 string::size_type p_old = strlen( rl.money_int_prefix_old );
107 CPPUNIT_ASSERT( (str_res.substr(index, p) == rl.money_int_prefix) ||
108 ((p_old != 0) &&
109 (str_res.substr(index, p_old) == rl.money_int_prefix_old)) );
110 if ( str_res.substr(index, p) == rl.money_int_prefix ) {
111 index += p;
112 } else {
113 index += p_old;
114 }
115 ++fieldIndex;
116 }
117
118 // space after currency
119 if (intl_fmp.pos_format().field[fieldIndex] == money_base::space ||
120 intl_fmp.pos_format().field[fieldIndex] == money_base::none) {
121 // iternational currency symobol has four chars, one of these chars
122 // is separator, so if format has space on this place, it should
123 // be skipped.
124 ++fieldIndex;
125 }
126
127 // sign
128 if (intl_fmp.pos_format().field[fieldIndex] == money_base::sign) {
129 ++fieldIndex;
130 }
131
132 // value
133 CPPUNIT_ASSERT( str_res[index++] == '1' );
134 if (!intl_fmp.grouping().empty()) {
135 CPPUNIT_ASSERT( str_res[index++] == /* intl_fmp.thousands_sep() */ *rl.money_thousands_sep );
136 }
137 CPPUNIT_ASSERT( str_res[index++] == '2' );
138 CPPUNIT_ASSERT( str_res[index++] == '3' );
139 CPPUNIT_ASSERT( str_res[index++] == '4' );
140 if (intl_fmp.frac_digits() != 0) {
141 CPPUNIT_ASSERT( str_res[index++] == /* intl_fmp.decimal_point() */ *rl.money_decimal_point );
142 }
143 CPPUNIT_ASSERT( str_res[index++] == '5' );
144 CPPUNIT_ASSERT( str_res[index++] == '6' );
145 ++fieldIndex;
146
147 // sign
148 if (intl_fmp.pos_format().field[fieldIndex] == money_base::sign) {
149 ++fieldIndex;
150 }
151
152 // space
153 if (intl_fmp.pos_format().field[fieldIndex] == money_base::space ) {
154 CPPUNIT_ASSERT( str_res[index++] == ' ' );
155 ++fieldIndex;
156 }
157
158 // sign
159 if (intl_fmp.pos_format().field[fieldIndex] == money_base::sign) {
160 ++fieldIndex;
161 }
162
163 //as space cannot be last the only left format can be none:
164 while ( fieldIndex < 3 ) {
165 CPPUNIT_ASSERT( intl_fmp.pos_format().field[fieldIndex] == money_base::none );
166 ++fieldIndex;
167 }
168 }
169
170 //money_get
171 {
172 ios_base::iostate err = ios_base::goodbit;
173 string digits;
174
175 istringstream istr(str_res);
176 ostr.str( "" );
177 ostr.clear();
178 fmg.get(istr, istreambuf_iterator<char, char_traits<char> >(), true, ostr, err, digits);
179 CPPUNIT_ASSERT( (err & (ios_base::failbit | ios_base::badbit)) == 0 );
180 CPPUNIT_ASSERT( digits == "123456" );
181 }
182 }
183
184 ostr.str("");
185 //Check a negative value (national format)
186 {
188 moneypunct<char, false> const& dom_fmp = use_facet<moneypunct<char, false> >(loc);
189 string str_res;
190 //Check money_put
191 {
192 ostreambuf_iterator<char, char_traits<char> > res = fmp.put(ostr, false, ostr, ' ', -123456);
193
194 CPPUNIT_ASSERT( !res.failed() );
195 str_res = ostr.str();
196 //CPPUNIT_MESSAGE(str_res.c_str());
197
198 size_t fieldIndex = 0;
199 size_t index = 0;
200
201 if (dom_fmp.neg_format().field[fieldIndex] == money_base::sign) {
202 CPPUNIT_ASSERT( str_res.substr(index, dom_fmp.negative_sign().size()) == dom_fmp.negative_sign() );
203 index += dom_fmp.negative_sign().size();
204 ++fieldIndex;
205 }
206
207 string::size_type p = strlen( rl.money_prefix );
208 if (p != 0) {
209 CPPUNIT_ASSERT( str_res.substr(index, p) == rl.money_prefix );
210 index += p;
211 ++fieldIndex;
212 }
213 if (dom_fmp.neg_format().field[fieldIndex] == money_base::space ||
214 dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
215 CPPUNIT_ASSERT( str_res[index++] == ' ' );
216 ++fieldIndex;
217 }
218
219 CPPUNIT_ASSERT( str_res[index++] == '1' );
220 if (!dom_fmp.grouping().empty()) {
221 CPPUNIT_ASSERT( str_res[index++] == dom_fmp.thousands_sep() );
222 }
223 CPPUNIT_ASSERT( str_res[index++] == '2' );
224 CPPUNIT_ASSERT( str_res[index++] == '3' );
225 CPPUNIT_ASSERT( str_res[index++] == '4' );
226 if (dom_fmp.frac_digits() != 0) {
227 CPPUNIT_ASSERT( str_res[index++] == dom_fmp.decimal_point() );
228 }
229 CPPUNIT_ASSERT( str_res[index++] == '5' );
230 CPPUNIT_ASSERT( str_res[index++] == '6' );
231 ++fieldIndex;
232
233 //space cannot be last:
234 if ((fieldIndex < 3) &&
235 dom_fmp.neg_format().field[fieldIndex] == money_base::space) {
236 CPPUNIT_ASSERT( str_res[index++] == ' ' );
237 ++fieldIndex;
238 }
239
240 if (fieldIndex == 3) {
241 //If none is last we should not add anything to the resulting string:
242 if (dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
243 CPPUNIT_ASSERT( index == str_res.size() );
244 } else {
245 CPPUNIT_ASSERT( dom_fmp.neg_format().field[fieldIndex] == money_base::symbol );
246 CPPUNIT_ASSERT( str_res.substr(index, strlen(rl.money_suffix)) == rl.money_suffix );
247 }
248 }
249 }
250
251 //money_get
252 {
253 ios_base::iostate err = ios_base::goodbit;
254# if defined (STLPORT)
256# else
257 long double val;
258# endif
259
260 istringstream istr(str_res);
261 fmg.get(istr, istreambuf_iterator<char, char_traits<char> >(), false, ostr, err, val);
262 CPPUNIT_ASSERT( (err & (ios_base::failbit | ios_base::badbit)) == 0 );
263 if (dom_fmp.negative_sign().empty()) {
264 //Without negative sign there is no way to guess the resulting amount sign ("C" locale):
265 CPPUNIT_ASSERT( val == 123456 );
266 }
267 else {
268 CPPUNIT_ASSERT( val == -123456 );
269 }
270 }
271 }
272}
ios_base &_STLP_CALL showbase(ios_base &__s)
Definition: _ios_base.h:273
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
locale imbue(const locale &)
Definition: _ios.c:69
_Self substr(size_type __pos=0, size_type __n=npos) const
Definition: _string.h:1022
int iostate
Definition: _ios_base.h:58
iter_type get(iter_type __s, iter_type __end, bool __intl, ios_base &__str, ios_base::iostate &__err, _STLP_LONGEST_FLOAT_TYPE &__units) const
Definition: _monetary.h:61
iter_type put(iter_type __s, bool __intl, ios_base &__str, char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const
Definition: _monetary.h:395
#define _STLP_LONGEST_FLOAT_TYPE
Definition: features.h:213
GLuint index
Definition: glext.h:6031
GLuint GLfloat * val
Definition: glext.h:7180
GLfloat GLfloat p
Definition: glext.h:8902
static const int digits[]
Definition: decode.c:71
#define err(...)
const char * money_decimal_point
const char * money_prefix
const char * money_int_prefix
const char * money_int_prefix_old
const char * money_suffix
const char * money_thousands_sep

Referenced by _money_put_get(), and combine().

◆ _money_put_X_bug()

void LocaleTest::_money_put_X_bug ( const STD locale ,
const ref_monetary  
)
private

Definition at line 279 of file money_facets_test.cpp.

280{
281 const ref_monetary &rl = *prl;
283 money_put<char> const& fmp = use_facet<money_put<char> >(loc);
284
285 ostringstream ostr;
286 ostr.imbue(loc);
287 ostr << showbase;
288
289 // ostr.str("");
290 // Check value with one decimal digit:
291 {
293 moneypunct<char, false> const& dom_fmp = use_facet<moneypunct<char, false> >(loc);
294 string str_res;
295 // Check money_put
296 {
297 ostreambuf_iterator<char, char_traits<char> > res = fmp.put(ostr, false, ostr, ' ', 9);
298
299 CPPUNIT_ASSERT( !res.failed() );
300 str_res = ostr.str();
301
302 size_t fieldIndex = 0;
303 size_t index = 0;
304
305 if (dom_fmp.pos_format().field[fieldIndex] == money_base::sign) {
306 CPPUNIT_ASSERT( str_res.substr(index, dom_fmp.positive_sign().size()) == dom_fmp.positive_sign() );
307 index += dom_fmp.positive_sign().size();
308 ++fieldIndex;
309 }
310
311 string::size_type p = strlen( rl.money_prefix );
312 if (p != 0) {
313 CPPUNIT_ASSERT( str_res.substr(index, p) == rl.money_prefix );
314 index += p;
315 ++fieldIndex;
316 }
317 if (dom_fmp.neg_format().field[fieldIndex] == money_base::space ||
318 dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
319 CPPUNIT_ASSERT( str_res[index++] == ' ' );
320 ++fieldIndex;
321 }
322 if (dom_fmp.frac_digits() != 0) {
323 CPPUNIT_ASSERT( str_res[index++] == '0' );
324 CPPUNIT_ASSERT( str_res[index++] == dom_fmp.decimal_point() );
325 for ( int fd = 1; fd < dom_fmp.frac_digits(); ++fd ) {
326 CPPUNIT_ASSERT( str_res[index++] == '0' );
327 }
328 }
329 CPPUNIT_ASSERT( str_res[index++] == '9' );
330 ++fieldIndex;
331
332 //space cannot be last:
333 if ((fieldIndex < 3) &&
334 dom_fmp.neg_format().field[fieldIndex] == money_base::space) {
335 CPPUNIT_ASSERT( str_res[index++] == ' ' );
336 ++fieldIndex;
337 }
338
339 if (fieldIndex == 3) {
340 //If none is last we should not add anything to the resulting string:
341 if (dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
342 CPPUNIT_ASSERT( index == str_res.size() );
343 } else {
344 CPPUNIT_ASSERT( dom_fmp.neg_format().field[fieldIndex] == money_base::symbol );
345 CPPUNIT_ASSERT( str_res.substr(index, strlen(rl.money_suffix)) == rl.money_suffix );
346 }
347 }
348 }
349 }
350
351 ostr.str("");
352 // Check value with two decimal digit:
353 {
355 moneypunct<char, false> const& dom_fmp = use_facet<moneypunct<char, false> >(loc);
356 string str_res;
357 // Check money_put
358 {
359 ostreambuf_iterator<char, char_traits<char> > res = fmp.put(ostr, false, ostr, ' ', 90);
360
361 CPPUNIT_ASSERT( !res.failed() );
362 str_res = ostr.str();
363
364 size_t fieldIndex = 0;
365 size_t index = 0;
366
367 if (dom_fmp.pos_format().field[fieldIndex] == money_base::sign) {
368 CPPUNIT_ASSERT( str_res.substr(index, dom_fmp.positive_sign().size()) == dom_fmp.positive_sign() );
369 index += dom_fmp.positive_sign().size();
370 ++fieldIndex;
371 }
372
373 string::size_type p = strlen( rl.money_prefix );
374 if (p != 0) {
375 CPPUNIT_ASSERT( str_res.substr(index, p) == rl.money_prefix );
376 index += p;
377 ++fieldIndex;
378 }
379 if (dom_fmp.neg_format().field[fieldIndex] == money_base::space ||
380 dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
381 CPPUNIT_ASSERT( str_res[index++] == ' ' );
382 ++fieldIndex;
383 }
384 if (dom_fmp.frac_digits() != 0) {
385 CPPUNIT_ASSERT( str_res[index++] == '0' );
386 CPPUNIT_ASSERT( str_res[index++] == dom_fmp.decimal_point() );
387 for ( int fd = 1; fd < dom_fmp.frac_digits() - 1; ++fd ) {
388 CPPUNIT_ASSERT( str_res[index++] == '0' );
389 }
390 }
391 CPPUNIT_ASSERT( str_res[index++] == '9' );
392 if (dom_fmp.frac_digits() != 0) {
393 CPPUNIT_ASSERT( str_res[index++] == '0' );
394 }
395 ++fieldIndex;
396
397 //space cannot be last:
398 if ((fieldIndex < 3) &&
399 dom_fmp.neg_format().field[fieldIndex] == money_base::space) {
400 CPPUNIT_ASSERT( str_res[index++] == ' ' );
401 ++fieldIndex;
402 }
403
404 if (fieldIndex == 3) {
405 //If none is last we should not add anything to the resulting string:
406 if (dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
407 CPPUNIT_ASSERT( index == str_res.size() );
408 } else {
409 CPPUNIT_ASSERT( dom_fmp.neg_format().field[fieldIndex] == money_base::symbol );
410 CPPUNIT_ASSERT( str_res.substr(index, strlen(rl.money_suffix)) == rl.money_suffix );
411 }
412 }
413 }
414 }
415}
static int fd
Definition: io.c:51

Referenced by money_put_X_bug().

◆ _num_put_get()

void LocaleTest::_num_put_get ( const STD locale ,
const ref_locale  
)
private

Definition at line 34 of file num_facets_test.cpp.

34 {
35 const ref_locale& rl = *prl;
37 numpunct<char> const& npct = use_facet<numpunct<char> >(loc);
38 CPPUNIT_ASSERT( npct.decimal_point() == *rl.decimal_point );
39
40 float val = 1234.56f;
41 ostringstream fostr;
42 fostr.imbue(loc);
43 fostr << val;
44
45 string ref = "1";
46 if (!npct.grouping().empty()) {
47 ref += npct.thousands_sep();
48 }
49 ref += "234";
50 ref += npct.decimal_point();
51 ref += "56";
52 //cout << "In " << loc.name() << " 1234.56 is written: " << fostr.str() << endl;
53 CPPUNIT_ASSERT( fostr.str() == ref );
54
55 val = 12345678.9f;
56 ref = "1";
57 ref += npct.decimal_point();
58 ref += "23457e+";
59 string digits = "7";
61 ref += digits;
62 fostr.str("");
63 fostr << val;
64 CPPUNIT_ASSERT( fostr.str() == ref );
65
66 val = 1000000000.0f;
67 fostr.str("");
68 fostr << val;
69 digits = "9";
71 CPPUNIT_ASSERT( fostr.str() == string("1e+") + digits );
72
73 val = 1234.0f;
74 ref = "1";
75 if (!npct.grouping().empty()) {
76 ref += npct.thousands_sep();
77 }
78 ref += "234";
79 fostr.str("");
80 fostr << val;
81 CPPUNIT_ASSERT( fostr.str() == ref );
82
83 val = 10000001.0f;
84 fostr.str("");
85 fostr << val;
86 digits = "7";
88 CPPUNIT_ASSERT( fostr.str() == string("1e+") + digits );
89
90 if (npct.grouping().size() == 1 && npct.grouping()[0] == 3) {
91 int ival = 1234567890;
92 fostr.str("");
93 fostr << ival;
94 ref = "1";
95 ref += npct.thousands_sep();
96 ref += "234";
97 ref += npct.thousands_sep();
98 ref += "567";
99 ref += npct.thousands_sep();
100 ref += "890";
101 CPPUNIT_ASSERT( fostr.str() == ref );
102 }
103
104#if defined (__BORLANDC__)
105 num_put<char> const& nput = use_facet<num_put<char> >(loc);
106 typedef numeric_limits<double> limd;
107 fostr.setf(ios_base::uppercase | ios_base::showpos);
108
109 if (limd::has_infinity) {
110 double infinity = limd::infinity();
111 fostr.str("");
112 nput.put(fostr, fostr, ' ', infinity);
113 CPPUNIT_ASSERT( fostr.str() == string("+Inf") );
114 }
115
116 if (limd::has_quiet_NaN) {
117 /* Ignore FPU exceptions */
118 unsigned int _float_control_word = _control87(0, 0);
119 _control87(EM_INVALID|EM_INEXACT, MCW_EM);
120 double qnan = limd::quiet_NaN();
121 /* Reset floating point control word */
122 _clear87();
123 _control87(_float_control_word, MCW_EM);
124 fostr.str("");
125 nput.put(fostr, fostr, ' ', qnan);
126 CPPUNIT_ASSERT( fostr.str() == string("+NaN") );
127 }
128#endif
129}
_String str() const
Definition: _sstream.h:184
fmtflags setf(fmtflags __flag)
Definition: _ios_base.h:114
iter_type put(iter_type __s, ios_base &__f, char_type __fill, bool __val) const
Definition: _num_put.h:60
void complete_digits(std::string &digits)
#define _clear87
Definition: float.h:139
unsigned int __cdecl _control87(unsigned int, unsigned int)
Definition: _control87.c:16
const char * decimal_point
Definition: send.c:48

Referenced by num_put_get().

◆ _time_put_get()

void LocaleTest::_time_put_get ( const STD locale )
private

Definition at line 25 of file time_facets_test.cpp.

26{
27 {
29 CPPUNIT_ASSERT( has_facet<time_put_facet>(loc) );
30 const time_put_facet& tmp = use_facet<time_put_facet>(loc);
31
32 struct tm xmas = { 0, 0, 12, 25, 11, 93 };
33 ostringstream ostr;
34 ostr.imbue(loc);
35 string format = "%B %d %Y";
36
37 time_put_facet::iter_type ret = tmp.put(ostr, ostr, ' ', &xmas, format.data(), format.data() + format.size());
38 CPPUNIT_ASSERT( !ret.failed() );
39
40 /*
41 * In other words, user conformation is required for reliable parsing
42 * of user-entered dates and times, but machine-generated formats can be
43 * parsed reliably. This allows parsers to be aggressive about interpreting
44 * user variations on standard format.
45 *
46 * ISO/IEC 14882, 22.2.5.1
47 */
49 CPPUNIT_ASSERT( has_facet<time_get_facet>(loc) );
50 const time_get_facet& tmg = use_facet<time_get_facet>(loc);
52 io.imbue(loc);
53
54 istringstream istr( ostr.str() );
57 ios_base::iostate err = ios_base::goodbit;
58 struct tm other = { 15, 20, 9, 14, 7, 105 };
59
60 i = tmg.get_monthname( i, e, io, err, &other );
61 CPPUNIT_ASSERT( err == ios_base::goodbit );
62 CPPUNIT_ASSERT( other.tm_mon == xmas.tm_mon );
63
64 ++i; ++i; ++i; ++i; // skip day of month and spaces around it
65 i = tmg.get_year( i, e, io, err, &other );
66
67 CPPUNIT_ASSERT( err == ios_base::eofbit );
68 CPPUNIT_ASSERT( other.tm_year == xmas.tm_year );
69
70 ostringstream ostrX;
71 ostrX.imbue(loc);
72 format = "%x %X";
73
74 ret = tmp.put(ostrX, ostrX, ' ', &xmas, format.data(), format.data() + format.size());
75 CPPUNIT_ASSERT( !ret.failed() );
76
77 istringstream istrX( ostrX.str() );
79
80 err = ios_base::goodbit;
81
82 struct tm yet_more = { 15, 20, 9, 14, 7, 105 };
83
84 j = tmg.get_date( j, e, io, err, &yet_more );
85
86 CPPUNIT_ASSERT( err == ios_base::goodbit );
87
88 CPPUNIT_ASSERT( yet_more.tm_sec != xmas.tm_sec );
89 CPPUNIT_ASSERT( yet_more.tm_min != xmas.tm_min );
90 CPPUNIT_ASSERT( yet_more.tm_hour != xmas.tm_hour );
91 CPPUNIT_ASSERT( yet_more.tm_mday == xmas.tm_mday );
92 CPPUNIT_ASSERT( yet_more.tm_mon == xmas.tm_mon );
93 CPPUNIT_ASSERT( yet_more.tm_year == xmas.tm_year );
94
95 ++j; // skip space
96
97 j = tmg.get_time( j, e, io, err, &yet_more );
98
99 CPPUNIT_ASSERT( err == ios_base::eofbit || err == ios_base::goodbit );
100
101 CPPUNIT_ASSERT( yet_more.tm_sec == xmas.tm_sec );
102 CPPUNIT_ASSERT( yet_more.tm_min == xmas.tm_min );
103 CPPUNIT_ASSERT( yet_more.tm_hour == xmas.tm_hour );
104 CPPUNIT_ASSERT( yet_more.tm_mday == xmas.tm_mday );
105 CPPUNIT_ASSERT( yet_more.tm_mon == xmas.tm_mon );
106 CPPUNIT_ASSERT( yet_more.tm_year == xmas.tm_year );
107 }
108# if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
109 {
111 CPPUNIT_ASSERT( has_facet<time_put_facet>(loc) );
112 const time_put_facet& tmp = use_facet<time_put_facet>(loc);
113
114 struct tm xmas = { 0, 0, 12, 25, 11, 93 };
115 wostringstream ostr;
116 ostr.imbue(loc);
117 wstring format = L"%B %d %Y";
118
119 time_put_facet::iter_type ret = tmp.put(ostr, ostr, ' ', &xmas, format.data(), format.data() + format.size());
120 CPPUNIT_ASSERT( !ret.failed() );
121
122 /*
123 * In other words, user conformation is required for reliable parsing
124 * of user-entered dates and times, but machine-generated formats can be
125 * parsed reliably. This allows parsers to be aggressive about interpreting
126 * user variations on standard format.
127 *
128 * ISO/IEC 14882, 22.2.5.1
129 */
131 CPPUNIT_ASSERT( has_facet<time_get_facet>(loc) );
132 const time_get_facet& tmg = use_facet<time_get_facet>(loc);
133 // Intentional instantiation with char to show a bug in a previous STLport version.
135 io.imbue(loc);
136
137 wistringstream istr( ostr.str() );
140 ios_base::iostate err = ios_base::goodbit;
141 struct tm other = { 15, 20, 9, 14, 7, 105 };
142
143 i = tmg.get_monthname( i, e, io, err, &other );
144 CPPUNIT_ASSERT( err == ios_base::goodbit );
145 CPPUNIT_ASSERT( other.tm_mon == xmas.tm_mon );
146
147 ++i; ++i; ++i; ++i; // skip day of month and spaces around it
148 i = tmg.get_year( i, e, io, err, &other );
149
150 CPPUNIT_ASSERT( err == ios_base::eofbit );
151 CPPUNIT_ASSERT( other.tm_year == xmas.tm_year );
152
153 wostringstream ostrX;
154 ostrX.imbue(loc);
155 format = L"%x %X";
156
157 ret = tmp.put(ostrX, ostrX, ' ', &xmas, format.data(), format.data() + format.size());
158 CPPUNIT_ASSERT( !ret.failed() );
159
160 wistringstream istrX( ostrX.str() );
162
163 err = ios_base::goodbit;
164
165 struct tm yet_more = { 15, 20, 9, 14, 7, 105 };
166
167 j = tmg.get_date( j, e, io, err, &yet_more );
168
169 CPPUNIT_ASSERT( err == ios_base::goodbit );
170
171 CPPUNIT_ASSERT( yet_more.tm_sec != xmas.tm_sec );
172 CPPUNIT_ASSERT( yet_more.tm_min != xmas.tm_min );
173 CPPUNIT_ASSERT( yet_more.tm_hour != xmas.tm_hour );
174 CPPUNIT_ASSERT( yet_more.tm_mday == xmas.tm_mday );
175 CPPUNIT_ASSERT( yet_more.tm_mon == xmas.tm_mon );
176 CPPUNIT_ASSERT( yet_more.tm_year == xmas.tm_year );
177
178 ++j; // skip space
179
180 j = tmg.get_time( j, e, io, err, &yet_more );
181
182 CPPUNIT_ASSERT( err == ios_base::eofbit || err == ios_base::goodbit );
183
184 CPPUNIT_ASSERT( yet_more.tm_sec == xmas.tm_sec );
185 CPPUNIT_ASSERT( yet_more.tm_min == xmas.tm_min );
186 CPPUNIT_ASSERT( yet_more.tm_hour == xmas.tm_hour );
187 CPPUNIT_ASSERT( yet_more.tm_mday == xmas.tm_mday );
188 CPPUNIT_ASSERT( yet_more.tm_mon == xmas.tm_mon );
189 CPPUNIT_ASSERT( yet_more.tm_year == xmas.tm_year );
190 }
191# endif
192}
Definition: _ios.h:48
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define e
Definition: ke_i.h:82
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:100
int other
Definition: msacm.c:1376
Definition: time.h:68
int tm_mon
Definition: time.h:73
int tm_year
Definition: time.h:74
int tm_hour
Definition: time.h:71
int tm_sec
Definition: time.h:69
int tm_mday
Definition: time.h:72
int tm_min
Definition: time.h:70
int ret

Referenced by time_put_get().

◆ collate_by_name()

void LocaleTest::collate_by_name ( )

Definition at line 141 of file collate_facets_test.cpp.

142{
143 /*
144 * Check of the 22.1.1.2.7 standard point. Construction of a locale
145 * instance from a null pointer or an unknown name should result in
146 * a runtime_error exception.
147 */
148# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
149# if defined (STLPORT) || !defined (__GNUC__)
150 try {
151 locale loc(locale::classic(), new collate_byname<char>(static_cast<char const*>(0)));
153 }
154 catch (runtime_error const& /* e */) {
155 //CPPUNIT_MESSAGE( e.what() );
156 }
157 catch (...) {
159 }
160# endif
161
162 try {
163 locale loc(locale::classic(), new collate_byname<char>("yasli_language"));
165 }
166 catch (runtime_error const& /* e */) {
167 //CPPUNIT_MESSAGE( e.what() );
168 }
169 catch (...) {
171 }
172
173 try {
174 string veryLongFacetName("LC_COLLATE=");
175 veryLongFacetName.append(512, '?');
176 locale loc(locale::classic(), new collate_byname<char>(veryLongFacetName.c_str()));
178 }
179 catch (runtime_error const& /* e */) {
180 //CPPUNIT_MESSAGE( e.what() );
181 }
182 catch (...) {
184 }
185
186 try {
187 locale loc(locale::classic(), "C", locale::collate);
188 }
189 catch (runtime_error const& e) {
190 CPPUNIT_MESSAGE( e.what() );
192 }
193 catch (...) {
195 }
196
197 try {
198 // On platform without real localization support we should rely on the "C" facet.
199 locale loc(locale::classic(), "", locale::collate);
200 }
201 catch (runtime_error const& e) {
202 CPPUNIT_MESSAGE( e.what() );
204 }
205 catch (...) {
207 }
208
209 try {
211
212 //We check that the C locale gives a lexicographical comparison:
213 collate<char> const& cfacet_byname = use_facet<collate<char> >(loc);
214 collate<char> const& cfacet = use_facet<collate<char> >(locale::classic());
215
216 char const str1[] = "abcdef1";
217 char const str2[] = "abcdef2";
218 const size_t size1 = sizeof(str1) / sizeof(str1[0]) - 1;
219 const size_t size2 = sizeof(str2) / sizeof(str2[0]) - 1;
220
221 CPPUNIT_ASSERT( cfacet_byname.compare(str1, str1 + size1 - 1, str2, str2 + size2 - 1) ==
222 cfacet.compare(str1, str1 + size1 - 1, str2, str2 + size2 - 1) );
223 CPPUNIT_ASSERT( cfacet_byname.compare(str1, str1 + size1, str2, str2 + size2) ==
224 cfacet.compare(str1, str1 + size1, str2, str2 + size2) );
225
226 //Smallest string should be before largest one:
227 CPPUNIT_ASSERT( cfacet_byname.compare(str1, str1 + size1 - 2, str2, str2 + size2 - 1) ==
228 cfacet.compare(str1, str1 + size1 - 2, str2, str2 + size2 - 1) );
229 CPPUNIT_ASSERT( cfacet_byname.compare(str1, str1 + size1 - 1, str2, str2 + size2 - 2) ==
230 cfacet.compare(str1, str1 + size1 - 1, str2, str2 + size2 - 2) );
231
232 // We cannot play with 'Á' char here because doing so would make test result
233 // dependant on char being consider as signed or not...
234 string strs[] = {"abdd", /* "abÁd",*/ "abbd", "abcd"};
235
236 vector<string> v1(strs, strs + sizeof(strs) / sizeof(strs[0]));
237 sort(v1.begin(), v1.end(), loc);
238 vector<string> v2(strs, strs + sizeof(strs) / sizeof(strs[0]));
239 sort(v2.begin(), v2.end(), locale::classic());
240 CPPUNIT_ASSERT( v1 == v2 );
241
242 CPPUNIT_ASSERT( (cfacet_byname.transform(v1[0].data(), v1[0].data() + v1[0].size()).compare(cfacet_byname.transform(v1[1].data(), v1[1].data() + v1[1].size())) ==
243 v1[0].compare(v1[1])) );
244 }
245 catch (runtime_error const& /* e */) {
246 /* CPPUNIT_MESSAGE( e.what() ); */
248 }
249 catch (...) {
251 }
252
253# if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
254# if defined (STLPORT) || !defined (__GNUC__)
255 try {
256 locale loc(locale::classic(), new collate_byname<wchar_t>(static_cast<char const*>(0)));
258 }
259 catch (runtime_error const&) {
260 }
261 catch (...) {
263 }
264# endif
265
266 try {
267 locale loc(locale::classic(), new collate_byname<wchar_t>("yasli_language"));
269 }
270 catch (runtime_error const&) {
271 }
272 catch (...) {
274 }
275# endif
276# endif
277}
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
#define CPPUNIT_MESSAGE(m)
Definition: cppunit_mini.h:223
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
#define const
Definition: zconf.h:233

◆ collate_facet()

void LocaleTest::collate_facet ( )

Definition at line 16 of file collate_facets_test.cpp.

17{
18 {
20 collate<char> const& col = use_facet<collate<char> >(locale::classic());
21
22 char const str1[] = "abcdef1";
23 char const str2[] = "abcdef2";
24 const size_t size1 = sizeof(str1) / sizeof(str1[0]) - 1;
25 const size_t size2 = sizeof(str2) / sizeof(str2[0]) - 1;
26
27 CPPUNIT_ASSERT( col.compare(str1, str1 + size1 - 1, str2, str2 + size2 - 1) == 0 );
28 CPPUNIT_ASSERT( col.compare(str1, str1 + size1, str2, str2 + size2) == -1 );
29
30 //Smallest string should be before largest one:
31 CPPUNIT_ASSERT( col.compare(str1, str1 + size1 - 2, str2, str2 + size2 - 1) == -1 );
32 CPPUNIT_ASSERT( col.compare(str1, str1 + size1 - 1, str2, str2 + size2 - 2) == 1 );
33 }
34
35# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
36 try {
37 locale loc("fr_FR");
38 {
40 collate<char> const& col = use_facet<collate<char> >(loc);
41
42 char const str1[] = "abcdef1";
43 char const str2[] = "abcdef2";
44 const size_t size1 = sizeof(str1) / sizeof(str1[0]) - 1;
45 const size_t size2 = sizeof(str2) / sizeof(str2[0]) - 1;
46
47 CPPUNIT_ASSERT( col.compare(str1, str1 + size1 - 1, str2, str2 + size2 - 1) == 0 );
48 CPPUNIT_ASSERT( col.compare(str1, str1 + size1, str2, str2 + size2) == -1 );
49
50 //Smallest string should be before largest one:
51 CPPUNIT_ASSERT( col.compare(str1, str1 + size1 - 2, str2, str2 + size2 - 1) == -1 );
52 CPPUNIT_ASSERT( col.compare(str1, str1 + size1 - 1, str2, str2 + size2 - 2) == 1 );
53 }
54 {
56 collate<char> const& col = use_facet<collate<char> >(loc);
57
58 string strs[] = {"abdd", "abÁd", "abbd", "abcd"};
59
60 string transformed[4];
61 for (size_t i = 0; i < 4; ++i) {
62 transformed[i] = col.transform(strs[i].data(), strs[i].data() + strs[i].size());
63 }
64
65 sort(strs, strs + 4, loc);
66 CPPUNIT_ASSERT( strs[0] == "abbd" );
67 CPPUNIT_ASSERT( strs[1] == "abcd" );
68 CPPUNIT_ASSERT( strs[2] == "abÁd" );
69 CPPUNIT_ASSERT( strs[3] == "abdd" );
70
71 sort(transformed, transformed + 4);
72
73 CPPUNIT_ASSERT( col.transform(strs[0].data(), strs[0].data() + strs[0].size()) == transformed[0] );
74 CPPUNIT_ASSERT( col.transform(strs[1].data(), strs[1].data() + strs[1].size()) == transformed[1] );
75 CPPUNIT_ASSERT( col.transform(strs[2].data(), strs[2].data() + strs[2].size()) == transformed[2] );
76 CPPUNIT_ASSERT( col.transform(strs[3].data(), strs[3].data() + strs[3].size()) == transformed[3] );
77
78 // Check empty string result in empty key.
79 CPPUNIT_ASSERT( col.transform(strs[0].data(), strs[0].data()).empty() );
80
81 // Check that only characters that matter are taken into accout to build the key.
82 CPPUNIT_ASSERT( col.transform(strs[0].data(), strs[0].data() + 2) == col.transform(strs[1].data(), strs[1].data() + 2) );
83 }
84# if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
85 {
87 collate<wchar_t> const& col = use_facet<collate<wchar_t> >(loc);
88
89 wchar_t const str1[] = L"abcdef1";
90 wchar_t const str2[] = L"abcdef2";
91 const size_t size1 = sizeof(str1) / sizeof(str1[0]) - 1;
92 const size_t size2 = sizeof(str2) / sizeof(str2[0]) - 1;
93
94 CPPUNIT_ASSERT( col.compare(str1, str1 + size1 - 1, str2, str2 + size2 - 1) == 0 );
95 CPPUNIT_ASSERT( col.compare(str1, str1 + size1, str2, str2 + size2) == -1 );
96
97 //Smallest string should be before largest one:
98 CPPUNIT_ASSERT( col.compare(str1, str1 + size1 - 2, str2, str2 + size2 - 1) == -1 );
99 CPPUNIT_ASSERT( col.compare(str1, str1 + size1 - 1, str2, str2 + size2 - 2) == 1 );
100 }
101 {
102 size_t i;
104 collate<wchar_t> const& col = use_facet<collate<wchar_t> >(loc);
105
106 // Here we would like to use L"abÁd" but it looks like all compilers
107 // do not support storage of unicode characters in exe resulting in
108 // compilation error. We avoid this test for the moment.
109 wstring strs[] = {L"abdd", L"abcd", L"abbd", L"abcd"};
110
111 wstring transformed[4];
112 for (i = 0; i < 4; ++i) {
113 transformed[i] = col.transform(strs[i].data(), strs[i].data() + strs[i].size());
114 }
115
116 sort(strs, strs + 4, loc);
117 CPPUNIT_ASSERT( strs[0] == L"abbd" );
118 CPPUNIT_ASSERT( strs[1] == L"abcd" );
119 CPPUNIT_ASSERT( strs[2] == L"abcd" );
120 CPPUNIT_ASSERT( strs[3] == L"abdd" );
121
122 sort(transformed, transformed + 4);
123
124 CPPUNIT_ASSERT( col.transform(strs[0].data(), strs[0].data() + strs[0].size()) == transformed[0] );
125 CPPUNIT_ASSERT( col.transform(strs[1].data(), strs[1].data() + strs[1].size()) == transformed[1] );
126 CPPUNIT_ASSERT( col.transform(strs[2].data(), strs[2].data() + strs[2].size()) == transformed[2] );
127 CPPUNIT_ASSERT( col.transform(strs[3].data(), strs[3].data() + strs[3].size()) == transformed[3] );
128
129 CPPUNIT_ASSERT( col.transform(strs[0].data(), strs[0].data()).empty() );
130
131 CPPUNIT_ASSERT( col.transform(strs[0].data(), strs[0].data() + 2) == col.transform(strs[1].data(), strs[1].data() + 2) );
132 }
133# endif
134 }
135 catch (runtime_error const&) {
136 CPPUNIT_MESSAGE("No french locale to check collate facet");
137 }
138# endif
139}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

◆ combine()

void LocaleTest::combine ( )

Definition at line 236 of file locale_test.cpp.

237{
238# if (!defined (STLPORT) || \
239 (defined (_STLP_USE_EXCEPTIONS) && !defined (_STLP_NO_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS)))
240 {
241 try {
242 locale loc("");
243 if (!has_facet<messages<char> >(loc)) {
244 loc.combine<messages<char> >(loc);
246 }
247 }
248 catch (const runtime_error & /* e */) {
249 /* CPPUNIT_MESSAGE( e.what() ); */
250 }
251
252 try {
253 locale loc;
254 if (!has_facet<dummy_facet>(loc)) {
255 loc.combine<dummy_facet>(loc);
257 }
258 }
259 catch (const runtime_error & /* e */) {
260 /* CPPUNIT_MESSAGE( e.what() ); */
261 }
262 }
263
264 locale loc1(locale::classic()), loc2;
265 size_t loc1_index = 0;
266 for (size_t i = 0; _get_ref_monetary(i) != 0; ++i) {
267 try {
268 {
270 if (loc1 == locale::classic())
271 {
272 loc1 = loc;
273 loc1_index = i;
274 continue;
275 }
276 else
277 {
278 loc2 = loc;
279 }
280 }
281
282 //We can start the test
283 ostringstream ostr;
284 ostr << "combining '" << loc2.name() << "' money facets with '" << loc1.name() << "'";
285 CPPUNIT_MESSAGE( ostr.str().c_str() );
286
287 //We are going to combine money facets as all formats are different.
288 {
289 //We check that resulting locale has correctly acquire loc2 facets.
290 locale loc = loc1.combine<moneypunct<char, true> >(loc2);
291 loc = loc.combine<moneypunct<char, false> >(loc2);
292 loc = loc.combine<money_put<char> >(loc2);
293 loc = loc.combine<money_get<char> >(loc2);
294
295 //Check loc has the correct facets:
297
298 //Check loc1 has not been impacted:
299 _money_put_get2(loc1, loc1, _get_ref_monetary(loc1_index));
300
301 //Check loc2 has not been impacted:
302 _money_put_get2(loc2, loc2, _get_ref_monetary(i));
303 }
304 {
305 //We check that resulting locale has not wrongly acquire loc1 facets that hasn't been combine:
306 locale loc = loc2.combine<numpunct<char> >(loc1);
307 loc = loc.combine<time_put<char> >(loc1);
308 loc = loc.combine<time_get<char> >(loc1);
309
310 //Check loc has the correct facets:
312
313 //Check loc1 has not been impacted:
314 _money_put_get2(loc1, loc1, _get_ref_monetary(loc1_index));
315
316 //Check loc2 has not been impacted:
317 _money_put_get2(loc2, loc2, _get_ref_monetary(i));
318 }
319
320 {
321 // Check auto combination do not result in weird reference counting behavior
322 // (might generate a crash).
323 loc1.combine<numpunct<char> >(loc1);
324 }
325
326 loc1 = loc2;
327 loc1_index = i;
328 }
329 catch (runtime_error const&) {
330 //This locale is not supported.
331 continue;
332 }
333 }
334# endif
335}
static const char * _get_ref_monetary_name(const ref_monetary *)
static const ref_monetary * _get_ref_monetary(size_t)
const _CharT * c_str() const
Definition: _string.h:949
string name() const
Definition: locale.cpp:388

◆ CPPUNIT_TEST() [1/17]

LocaleTest::CPPUNIT_TEST ( collate_by_name  )
private

◆ CPPUNIT_TEST() [2/17]

LocaleTest::CPPUNIT_TEST ( collate_facet  )
private

◆ CPPUNIT_TEST() [3/17]

LocaleTest::CPPUNIT_TEST ( combine  )
private

◆ CPPUNIT_TEST() [4/17]

LocaleTest::CPPUNIT_TEST ( ctype_by_name  )
private

◆ CPPUNIT_TEST() [5/17]

LocaleTest::CPPUNIT_TEST ( ctype_facet  )
private

◆ CPPUNIT_TEST() [6/17]

LocaleTest::CPPUNIT_TEST ( default_locale  )
private

◆ CPPUNIT_TEST() [7/17]

LocaleTest::CPPUNIT_TEST ( loc_has_facet  )
private

◆ CPPUNIT_TEST() [8/17]

LocaleTest::CPPUNIT_TEST ( locale_by_name  )
private

◆ CPPUNIT_TEST() [9/17]

LocaleTest::CPPUNIT_TEST ( locale_init_problem  )
private

◆ CPPUNIT_TEST() [10/17]

LocaleTest::CPPUNIT_TEST ( messages_by_name  )
private

◆ CPPUNIT_TEST() [11/17]

LocaleTest::CPPUNIT_TEST ( money_put_get  )
private

◆ CPPUNIT_TEST() [12/17]

LocaleTest::CPPUNIT_TEST ( money_put_X_bug  )
private

◆ CPPUNIT_TEST() [13/17]

LocaleTest::CPPUNIT_TEST ( moneypunct_by_name  )
private

◆ CPPUNIT_TEST() [14/17]

LocaleTest::CPPUNIT_TEST ( num_put_get  )
private

◆ CPPUNIT_TEST() [15/17]

LocaleTest::CPPUNIT_TEST ( numpunct_by_name  )
private

◆ CPPUNIT_TEST() [16/17]

LocaleTest::CPPUNIT_TEST ( time_by_name  )
private

◆ CPPUNIT_TEST() [17/17]

LocaleTest::CPPUNIT_TEST ( time_put_get  )
private

◆ CPPUNIT_TEST_SUITE()

LocaleTest::CPPUNIT_TEST_SUITE ( LocaleTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

LocaleTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ ctype_by_name()

void LocaleTest::ctype_by_name ( )

Definition at line 366 of file ctype_facets_test.cpp.

367{
368 /*
369 * Check of the 22.1.1.2.7 standard point. Construction of a locale
370 * instance from a null pointer or an unknown name should result in
371 * a runtime_error exception.
372 */
373# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
374# if defined (STLPORT) || (!defined(__GNUC__) && (!defined (_MSC_VER) || (_MSC_VER > 1400)))
375 // libstdc++ call freelocate on bad locale
376 try {
377 locale loc(locale::classic(), new ctype_byname<char>(static_cast<char const*>(0)));
378 CPPUNIT_ASSERT( false );
379 }
380 catch (runtime_error const& /* e */) {
381 //CPPUNIT_MESSAGE( e.what() );
382 }
383 catch (...) {
384 CPPUNIT_ASSERT( false );
385 }
386# endif
387
388 try {
389 locale loc(locale::classic(), new ctype_byname<char>("yasli_language"));
391 }
392 catch (runtime_error const& /* e */) {
393 //CPPUNIT_MESSAGE( e.what() );
394 }
395 catch (...) {
397 }
398
399# if defined(STLPORT) || !defined(__GNUC__)
400 try {
401 locale loc(locale::classic(), new codecvt_byname<char, char, mbstate_t>(static_cast<char const*>(0)));
403 }
404 catch (runtime_error const& /* e */) {
405 //CPPUNIT_MESSAGE( e.what() );
406 }
407 catch (...) {
409 }
410# endif
411
412 try {
414 //STLport implementation do not care about name pass to this facet.
415# if !defined (STLPORT)
417# endif
418 }
419 catch (runtime_error const& /* e */) {
420 //CPPUNIT_MESSAGE( e.what() );
421 }
422 catch (...) {
424 }
425
426 try {
427 locale loc(locale::classic(), new ctype_byname<char>("fr_FR"));
429 ctype<char> const& ct = use_facet<ctype<char> >(loc);
431 }
432 catch (runtime_error const& /* e */) {
433 //CPPUNIT_MESSAGE( e.what() );
434 }
435 catch (...) {
437 }
438
439 try {
441 ctype<char> const& cfacet_byname = use_facet<ctype<char> >(loc);
442 ctype<char> const& cfacet = use_facet<ctype<char> >(locale::classic());
443
444 for (char c = 0;; ++c) {
445 CPPUNIT_CHECK(cfacet_byname.is(ctype_base::space, c) == cfacet.is(ctype_base::space, c));
446 if (cfacet_byname.is(ctype_base::print, c) != cfacet.is(ctype_base::print, c))
447 {
448 CPPUNIT_CHECK(cfacet_byname.is(ctype_base::print, c) == cfacet.is(ctype_base::print, c));
449 }
450 CPPUNIT_CHECK(cfacet_byname.is(ctype_base::cntrl, c) == cfacet.is(ctype_base::cntrl, c));
451 CPPUNIT_CHECK(cfacet_byname.is(ctype_base::upper, c) == cfacet.is(ctype_base::upper, c));
452 CPPUNIT_CHECK(cfacet_byname.is(ctype_base::lower, c) == cfacet.is(ctype_base::lower, c));
453 CPPUNIT_CHECK(cfacet_byname.is(ctype_base::alpha, c) == cfacet.is(ctype_base::alpha, c));
454 CPPUNIT_CHECK(cfacet_byname.is(ctype_base::digit, c) == cfacet.is(ctype_base::digit, c));
455 CPPUNIT_CHECK(cfacet_byname.is(ctype_base::punct, c) == cfacet.is(ctype_base::punct, c));
456 CPPUNIT_CHECK(cfacet_byname.is(ctype_base::xdigit, c) == cfacet.is(ctype_base::xdigit, c));
457 CPPUNIT_CHECK(cfacet_byname.is(ctype_base::alnum, c) == cfacet.is(ctype_base::alnum, c));
458 CPPUNIT_CHECK(cfacet_byname.is(ctype_base::graph, c) == cfacet.is(ctype_base::graph, c));
459 if (c == 127) break;
460 }
461 }
462 catch (runtime_error const& /* e */) {
463 /* CPPUNIT_MESSAGE( e.what() ); */
465 }
466 catch (...) {
468 }
469
470# if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
471# if defined(STLPORT) || !defined(__GNUC__)
472 try {
473 locale loc(locale::classic(), new ctype_byname<wchar_t>(static_cast<char const*>(0)));
475 }
476 catch (runtime_error const&) {
477 }
478 catch (...) {
480 }
481# endif
482
483 try {
484 locale loc(locale::classic(), new ctype_byname<wchar_t>("yasli_language"));
486 }
487 catch (runtime_error const&) {
488 }
489 catch (...) {
491 }
492
493# if defined(STLPORT) || !defined(__GNUC__)
494 try {
495 locale loc(locale::classic(), new codecvt_byname<wchar_t, char, mbstate_t>(static_cast<char const*>(0)));
497 }
498 catch (runtime_error const& /* e */) {
499 //CPPUNIT_MESSAGE( e.what() );
500 }
501 catch (...) {
503 }
504# endif
505
506 try {
509 }
510 catch (runtime_error const& /* e */) {
511 //CPPUNIT_MESSAGE( e.what() );
512 }
513 catch (...) {
515 }
516# endif
517# endif
518}
@ cntrl
Definition: _ctype.h:44
@ alnum
Definition: _ctype.h:51
@ graph
Definition: _ctype.h:52
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80

◆ ctype_facet()

void LocaleTest::ctype_facet ( )

Definition at line 358 of file ctype_facets_test.cpp.

359{
361#ifndef _STLP_NO_WCHAR_T
363#endif
364}
void _ctype_facet(const STD locale &)
void _ctype_facet_w(const STD locale &)
static void test_supported_locale(LocaleTest &inst, _Test __test)

◆ default_locale()

void LocaleTest::default_locale ( )

Definition at line 224 of file locale_test.cpp.

225{
226 locale loc( "" );
227}

◆ loc_has_facet()

void LocaleTest::loc_has_facet ( )

Definition at line 145 of file locale_test.cpp.

145 {
146 locale loc("C");
147 typedef numpunct<char> implemented_facet;
148 CPPUNIT_ASSERT( has_facet<implemented_facet>(loc) );
149 /*
150 typedef num_put<char, back_insert_iterator<string> > not_implemented_facet;
151 CPPUNIT_ASSERT( !has_facet<not_implemented_facet>(loc) );
152 */
153}

◆ locale_by_name()

void LocaleTest::locale_by_name ( )

Definition at line 51 of file locale_test.cpp.

51 {
52# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
53 /*
54 * Check of the 22.1.1.2.7 standard point. Construction of a locale
55 * instance from a null pointer or an unknown name should result in
56 * a runtime_error exception.
57 */
58 try {
59 locale loc(static_cast<char const*>(0));
61 }
62 catch (runtime_error const&) {
63 }
64 catch (...) {
66 }
67
68 try {
69 locale loc("yasli_language");
71 }
72 catch (runtime_error const& /* e */) {
73 //CPPUNIT_MESSAGE( e.what() );
74 }
75 catch (...) {
77 }
78
79 try {
80 string very_large_locale_name(1024, '?');
81 locale loc(very_large_locale_name.c_str());
83 }
84 catch (runtime_error const& /* e */) {
85 //CPPUNIT_MESSAGE( e.what() );
86 }
87 catch (...) {
89 }
90
91#if defined (STLPORT) || !defined (_MSC_VER) || (_MSC_VER > 1400)
92 try {
93 string very_large_locale_name("LC_CTYPE=");
94 very_large_locale_name.append(1024, '?');
95 locale loc(very_large_locale_name.c_str());
97 }
98 catch (runtime_error const& /* e */) {
99 //CPPUNIT_MESSAGE( e.what() );
100 }
101 catch (...) {
103 }
104
105 try {
106 string very_large_locale_name("LC_ALL=");
107 very_large_locale_name.append(1024, '?');
108 locale loc(very_large_locale_name.c_str());
110 }
111 catch (runtime_error const& /* e */) {
112 //CPPUNIT_MESSAGE( e.what() );
113 }
114 catch (...) {
116 }
117#endif
118
119 try {
120 locale loc("C");
121 }
122 catch (runtime_error const& /* e */) {
123 /* CPPUNIT_MESSAGE( e.what() ); */
125 }
126 catch (...) {
128 }
129
130 try {
131 // On platform without real localization support we should rely on the "C" locale facet.
132 locale loc("");
133 }
134 catch (runtime_error const& /* e */) {
135 /* CPPUNIT_MESSAGE( e.what() ); */
137 }
138 catch (...) {
140 }
141
142# endif
143}

◆ locale_init_problem()

void LocaleTest::locale_init_problem ( )

Definition at line 155 of file locale_test.cpp.

155 {
156# if !defined (STLPORT) || !defined (_STLP_NO_MEMBER_TEMPLATES)
158# endif
159}
void _locale_init_problem(const STD locale &)

◆ messages_by_name()

void LocaleTest::messages_by_name ( )

Definition at line 14 of file messages_facets_test.cpp.

15{
16 /*
17 * Check of the 22.1.1.2.7 standard point. Construction of a locale
18 * instance from a null pointer or an unknown name should result in
19 * a runtime_error exception.
20 */
21# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
22# if defined (STLPORT) || !defined (__GNUC__)
23 try {
24 locale loc(locale::classic(), new messages_byname<char>(static_cast<char const*>(0)));
26 }
27 catch (runtime_error const& /* e */) {
28 //CPPUNIT_MESSAGE( e.what() );
29 }
30 catch (...) {
32 }
33# endif
34
35 try {
36 locale loc(locale::classic(), new messages_byname<char>("yasli_language"));
38 }
39 catch (runtime_error const& /* e */) {
40 //CPPUNIT_MESSAGE( e.what() );
41 }
42 catch (...) {
44 }
45
46 /*
47 try {
48 locale loc(locale::classic(), new messages_byname<char>(""));
49 CPPUNIT_FAIL;
50 }
51 catch (runtime_error const& e) {
52 CPPUNIT_MESSAGE( e.what() );
53 }
54 catch (...) {
55 CPPUNIT_FAIL;
56 }
57 */
58
59# if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
60# if defined (STLPORT) || !defined (__GNUC__)
61 try {
62 locale loc(locale::classic(), new messages_byname<wchar_t>(static_cast<char const*>(0)));
64 }
65 catch (runtime_error const&) {
66 }
67 catch (...) {
69 }
70# endif
71
72 try {
73 locale loc(locale::classic(), new messages_byname<wchar_t>("yasli_language"));
75 }
76 catch (runtime_error const&) {
77 }
78 catch (...) {
80 }
81# endif
82# endif
83}

◆ money_put_get()

void LocaleTest::money_put_get ( )

Definition at line 453 of file money_facets_test.cpp.

void _money_put_get(const STD locale &, const ref_monetary *)

◆ money_put_X_bug()

void LocaleTest::money_put_X_bug ( )

Definition at line 456 of file money_facets_test.cpp.

void _money_put_X_bug(const STD locale &, const ref_monetary *)

◆ moneypunct_by_name()

void LocaleTest::moneypunct_by_name ( )

Definition at line 459 of file money_facets_test.cpp.

460{
461 /*
462 * Check of the 22.1.1.2.7 standard point. Construction of a locale
463 * instance from a null pointer or an unknown name should result in
464 * a runtime_error exception.
465 */
466# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
467# if defined (STLPORT) || !defined (__GNUC__)
468 try {
469 locale loc(locale::classic(), new moneypunct_byname<char, true>(static_cast<char const*>(0)));
471 }
472 catch (runtime_error const&) {
473 }
474 catch (...) {
476 }
477# endif
478
479 try {
480 locale loc(locale::classic(), new moneypunct_byname<char, true>("yasli_language"));
482 }
483 catch (runtime_error const&) {
484 }
485 catch (...) {
487 }
488
489 try {
490 string veryLongFacetName("LC_MONETARY=");
491 veryLongFacetName.append(512, '?');
492 locale loc(locale::classic(), new moneypunct_byname<char, true>(veryLongFacetName.c_str()));
494 }
495 catch (runtime_error const& /* e */) {
496 //CPPUNIT_MESSAGE( e.what() );
497 }
498 catch (...) {
500 }
501
502# if defined (STLPORT) || !defined (__GNUC__)
503 try {
504 locale loc(locale::classic(), new moneypunct_byname<char, false>(static_cast<char const*>(0)));
506 }
507 catch (runtime_error const&) {
508 }
509 catch (...) {
511 }
512# endif
513
514 try {
515 locale loc(locale::classic(), new moneypunct_byname<char, false>("yasli_language"));
517 }
518 catch (runtime_error const&) {
519 }
520 catch (...) {
522 }
523
524 try {
525 string veryLongFacetName("LC_MONETARY=");
526 veryLongFacetName.append(512, '?');
527 locale loc(locale::classic(), new moneypunct_byname<char, false>(veryLongFacetName.c_str()));
529 }
530 catch (runtime_error const& /* e */) {
531 //CPPUNIT_MESSAGE( e.what() );
532 }
533 catch (...) {
535 }
536
537 try {
539 moneypunct<char, false> const& cfacet_byname = use_facet<moneypunct<char, false> >(loc);
540 moneypunct<char, false> const& cfacet = use_facet<moneypunct<char, false> >(locale::classic());
541
542 money_base::pattern cp = cfacet.pos_format();
543 money_base::pattern cp_bn = cfacet_byname.pos_format();
544 CPPUNIT_CHECK( cp_bn.field[0] == cp.field[0] );
545 CPPUNIT_CHECK( cp_bn.field[1] == cp.field[1] );
546 CPPUNIT_CHECK( cp_bn.field[2] == cp.field[2] );
547 CPPUNIT_CHECK( cp_bn.field[3] == cp.field[3] );
548
549 CPPUNIT_CHECK( cfacet_byname.frac_digits() == cfacet.frac_digits() );
550 if (cfacet_byname.frac_digits() != 0)
551 CPPUNIT_CHECK( cfacet_byname.decimal_point() == cfacet.decimal_point() );
552 CPPUNIT_CHECK( cfacet_byname.grouping() == cfacet.grouping() );
553 if (!cfacet_byname.grouping().empty())
554 CPPUNIT_CHECK( cfacet_byname.thousands_sep() == cfacet.thousands_sep() );
555 CPPUNIT_CHECK( cfacet_byname.positive_sign() == cfacet.positive_sign() );
556 CPPUNIT_CHECK( cfacet_byname.negative_sign() == cfacet.negative_sign() );
557 }
558 catch (runtime_error const& /* e */) {
559 /* CPPUNIT_MESSAGE( e.what() ); */
561 }
562 catch (...) {
564 }
565
566 try {
568 moneypunct<char, true> const& cfacet_byname = use_facet<moneypunct<char, true> >(loc);
569 moneypunct<char, true> const& cfacet = use_facet<moneypunct<char, true> >(locale::classic());
570
571 money_base::pattern cp = cfacet.pos_format();
572 money_base::pattern cp_bn = cfacet_byname.pos_format();
573 CPPUNIT_CHECK( cp_bn.field[0] == cp.field[0] );
574 CPPUNIT_CHECK( cp_bn.field[1] == cp.field[1] );
575 CPPUNIT_CHECK( cp_bn.field[2] == cp.field[2] );
576 CPPUNIT_CHECK( cp_bn.field[3] == cp.field[3] );
577
578 CPPUNIT_CHECK( cfacet_byname.frac_digits() == cfacet.frac_digits() );
579 if (cfacet_byname.frac_digits() != 0)
580 CPPUNIT_CHECK( cfacet_byname.decimal_point() == cfacet.decimal_point() );
581 CPPUNIT_CHECK( cfacet_byname.grouping() == cfacet.grouping() );
582 if (!cfacet_byname.grouping().empty())
583 CPPUNIT_CHECK( cfacet_byname.thousands_sep() == cfacet.thousands_sep() );
584 CPPUNIT_CHECK( cfacet_byname.positive_sign() == cfacet.positive_sign() );
585 CPPUNIT_CHECK( cfacet_byname.negative_sign() == cfacet.negative_sign() );
586 }
587 catch (runtime_error const& /* e */) {
588 /* CPPUNIT_MESSAGE( e.what() ); */
590 }
591 catch (...) {
593 }
594
595 try {
596 // On platform without real localization support we should rely on the "C" locale facet.
598 }
599 catch (runtime_error const& /* e */) {
600 /* CPPUNIT_MESSAGE( e.what() ); */
602 }
603 catch (...) {
605 }
606
607# if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
608# if defined (STLPORT) || !defined (__GNUC__)
609 try {
610 locale loc(locale::classic(), new moneypunct_byname<wchar_t, true>(static_cast<char const*>(0)));
612 }
613 catch (runtime_error const&) {
614 }
615 catch (...) {
617 }
618# endif
619
620 try {
621 locale loc(locale::classic(), new moneypunct_byname<wchar_t, true>("yasli_language"));
623 }
624 catch (runtime_error const&) {
625 }
626 catch (...) {
628 }
629
630# if defined (STLPORT) || !defined (__GNUC__)
631 try {
632 locale loc(locale::classic(), new moneypunct_byname<wchar_t, false>(static_cast<char const*>(0)));
634 }
635 catch (runtime_error const&) {
636 }
637 catch (...) {
639 }
640# endif
641
642 try {
643 locale loc(locale::classic(), new moneypunct_byname<wchar_t, false>("yasli_language"));
645 }
646 catch (runtime_error const&) {
647 }
648 catch (...) {
650 }
651# endif
652# endif
653}
POINT cp
Definition: magnifier.c:59

◆ num_put_get()

void LocaleTest::num_put_get ( )

Definition at line 166 of file num_facets_test.cpp.

void _num_put_get(const STD locale &, const ref_locale *)

◆ numpunct_by_name()

void LocaleTest::numpunct_by_name ( )

Definition at line 169 of file num_facets_test.cpp.

170{
171 /*
172 * Check of the 22.1.1.2.7 standard point. Construction of a locale
173 * instance from a null pointer or an unknown name should result in
174 * a runtime_error exception.
175 */
176# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
177# if defined (STLPORT) || !defined (__GNUC__)
178 try {
179 locale loc(locale::classic(), new numpunct_byname<char>(static_cast<char const*>(0)));
181 }
182 catch (runtime_error const& /* e */) {
183 //CPPUNIT_MESSAGE( e.what() );
184 }
185 catch (...) {
187 }
188# endif
189
190 try {
191 locale loc(locale::classic(), new numpunct_byname<char>("yasli_language"));
193 }
194 catch (runtime_error const& /* e */) {
195 //CPPUNIT_MESSAGE( e.what() );
196 }
197 catch (...) {
199 }
200
201 try {
202 string veryLongFacetName("LC_NUMERIC=");
203 veryLongFacetName.append(512, '?');
204 locale loc(locale::classic(), new numpunct_byname<char>(veryLongFacetName.c_str()));
206 }
207 catch (runtime_error const& /* e */) {
208 //CPPUNIT_MESSAGE( e.what() );
209 }
210 catch (...) {
212 }
213
214 try {
215 locale loc(locale::classic(), "C", locale::numeric);
216 }
217 catch (runtime_error const& e) {
218 CPPUNIT_MESSAGE( e.what() );
220 }
221 catch (...) {
223 }
224
225 try {
226 // On platform without real localization support we should rely on the "C" facet.
227 locale loc(locale::classic(), "", locale::numeric);
228 }
229 catch (runtime_error const& e) {
230 CPPUNIT_MESSAGE( e.what() );
232 }
233 catch (...) {
235 }
236
237 try {
239 numpunct<char> const& cfacet_byname = use_facet<numpunct<char> >(loc);
240 numpunct<char> const& cfacet = use_facet<numpunct<char> >(locale::classic());
241
242 CPPUNIT_CHECK( cfacet_byname.decimal_point() == cfacet.decimal_point() );
243 CPPUNIT_CHECK( cfacet_byname.grouping() == cfacet.grouping() );
244 if (!cfacet.grouping().empty())
245 CPPUNIT_CHECK( cfacet_byname.thousands_sep() == cfacet.thousands_sep() );
246# if !defined (STLPORT) || !defined (__GLIBC__)
247 CPPUNIT_CHECK( cfacet_byname.truename() == cfacet.truename() );
248 CPPUNIT_CHECK( cfacet_byname.falsename() == cfacet.falsename() );
249# endif
250 }
251 catch (runtime_error const& /* e */) {
252 //CPPUNIT_MESSAGE( e.what() );
254 }
255 catch (...) {
257 }
258
259 try {
260 // On platform without real localization support we should rely on the "C" locale facet.
262 }
263 catch (runtime_error const& e) {
264 CPPUNIT_MESSAGE( e.what() );
266 }
267 catch (...) {
269 }
270
271# if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
272# if defined (STLPORT) || !defined (__GNUC__)
273 try {
274 locale loc(locale::classic(), new numpunct_byname<wchar_t>(static_cast<char const*>(0)));
276 }
277 catch (runtime_error const&) {
278 }
279 catch (...) {
281 }
282# endif
283
284 try {
285 locale loc(locale::classic(), new numpunct_byname<wchar_t>("yasli_language"));
287 }
288 catch (runtime_error const&) {
289 }
290 catch (...) {
292 }
293# endif
294# endif
295}

◆ time_by_name()

void LocaleTest::time_by_name ( )

Definition at line 235 of file time_facets_test.cpp.

236{
237# if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
238 /*
239 * Check of the 22.1.1.2.7 standard point. Construction of a locale
240 * instance from a null pointer or an unknown name should result in
241 * a runtime_error exception.
242 */
243# if defined (STLPORT) || !defined (_MSC_VER) || (_MSC_VER > 1400)
244 try {
245 locale loc(locale::classic(), new time_put_byname<char, ostreambuf_iterator<char, char_traits<char> > >(static_cast<char const*>(0)));
247 }
248 catch (runtime_error const&) {
249 }
250 catch (...) {
252 }
253# endif
254
255 try {
256 locale loc(locale::classic(), new time_put_byname<char, ostreambuf_iterator<char, char_traits<char> > >("yasli_language"));
258 }
259 catch (runtime_error const&) {
260 }
261 catch (...) {
263 }
264
265 try {
266 string veryLongFacetName("LC_TIME=");
267 veryLongFacetName.append(512, '?');
268 locale loc(locale::classic(), new time_put_byname<char, ostreambuf_iterator<char, char_traits<char> > >(veryLongFacetName.c_str()));
270 }
271 catch (runtime_error const& /* e */) {
272 //CPPUNIT_MESSAGE( e.what() );
273 }
274 catch (...) {
276 }
277
278 try {
279 locale loc(locale::classic(), new time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >(static_cast<char const*>(0)));
281 }
282 catch (runtime_error const&) {
283 }
284 catch (...) {
286 }
287
288 try {
289 locale loc(locale::classic(), new time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >("yasli_language"));
291 }
292 catch (runtime_error const&) {
293 }
294 catch (...) {
296 }
297
298 try {
299 string veryLongFacetName("LC_TIME=");
300 veryLongFacetName.append(512, '?');
301 locale loc(locale::classic(), new time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >(veryLongFacetName.c_str()));
303 }
304 catch (runtime_error const& /* e */) {
305 //CPPUNIT_MESSAGE( e.what() );
306 }
307 catch (...) {
309 }
310
311 try {
312 locale loc(locale::classic(), "C", locale::time);
313 }
314 catch (runtime_error const& /* e */) {
315 /* CPPUNIT_MESSAGE( e.what() ); */
317 }
318 catch (...) {
320 }
321
322 try {
323 // On platform without real localization support we should rely on the "C" facet.
324 locale loc(locale::classic(), "", locale::time);
325 }
326 catch (runtime_error const& /* e */) {
327 /* CPPUNIT_MESSAGE( e.what() ); */
329 }
330 catch (...) {
332 }
333
334 try {
336 }
337 catch (runtime_error const& /* e */) {
338 /* CPPUNIT_MESSAGE( e.what() ); */
340 }
341 catch (...) {
343 }
344
345 try {
346 // On platform without real localization support we should rely on the "C" locale facet.
348 }
349 catch (runtime_error const& /* e */) {
350 /* CPPUNIT_MESSAGE( e.what() ); */
352 }
353 catch (...) {
355 }
356
357# if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
358 try {
359 locale loc(locale::classic(), new time_put_byname<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(static_cast<char const*>(0)));
361 }
362 catch (runtime_error const&) {
363 }
364 catch (...) {
366 }
367
368 try {
369 locale loc(locale::classic(), new time_put_byname<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >("yasli_language"));
371 }
372 catch (runtime_error const&) {
373 }
374 catch (...) {
376 }
377
378 try {
379 locale loc(locale::classic(), new time_get_byname<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(static_cast<char const*>(0)));
381 }
382 catch (runtime_error const&) {
383 }
384 catch (...) {
386 }
387
388 try {
389 locale loc(locale::classic(), new time_get_byname<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >("yasli_language"));
391 }
392 catch (runtime_error const&) {
393 }
394 catch (...) {
396 }
397
398# endif
399# endif
400}

◆ time_put_get()

void LocaleTest::time_put_get ( )

Definition at line 232 of file time_facets_test.cpp.

void _time_put_get(const STD locale &)

Member Data Documentation

◆ CPPUNIT_IGNORE

LocaleTest::CPPUNIT_IGNORE
private

Definition at line 48 of file locale_test.h.

◆ CPPUNIT_STOP_IGNORE

LocaleTest::CPPUNIT_STOP_IGNORE
private

Definition at line 33 of file locale_test.h.


The documentation for this class was generated from the following files: