|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32svr.h> |
|
22 #include <StifParser.h> |
|
23 #include <Stiftestinterface.h> |
|
24 #include<locale> |
|
25 #include<iostream> |
|
26 #include<string> |
|
27 #include <sstream> |
|
28 #include "tlocale.h" |
|
29 #define STDCPP_OOM FALSE |
|
30 #define testChar unsigned char |
|
31 |
|
32 using namespace std; |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // Ctlocale::Delete |
|
37 // Delete here all resources allocated and opened from test methods. |
|
38 // Called from destructor. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 void Ctlocale::Delete() |
|
42 { |
|
43 |
|
44 } |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // Ctlocale::RunMethodL |
|
51 // Run specified method. Contains also table of test mothods and their names. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 TInt Ctlocale::RunMethodL( |
|
55 CStifItemParser& aItem ) |
|
56 { |
|
57 |
|
58 static TStifFunctionInfo const KFunctions[] = |
|
59 { |
|
60 // Copy this line for every implemented function. |
|
61 // First string is the function name used in TestScripter script file. |
|
62 // Second is the actual implementation member function. |
|
63 ENTRY( "hasfacet", Ctlocale::hasfacet ), |
|
64 ENTRY( "usefacet", Ctlocale::usefacet ), |
|
65 ENTRY( "numget", Ctlocale::numget ), |
|
66 ENTRY( "numput", Ctlocale::numput ), |
|
67 ENTRY( "num_punct", Ctlocale::num_punct ), |
|
68 ENTRY( "numpunctbyname", Ctlocale::numpunctbyname ), |
|
69 ENTRY( "moneyget", Ctlocale::moneyget ), |
|
70 ENTRY( "moneyput", Ctlocale::moneyput ), |
|
71 ENTRY( "money_punct", Ctlocale::money_punct ), |
|
72 ENTRY( "moneypunctbyname", Ctlocale::moneypunctbyname ), |
|
73 ENTRY( "timeget", Ctlocale::timeget ), |
|
74 ENTRY( "timeput", Ctlocale::timeput ), |
|
75 ENTRY( "messagesL", Ctlocale::messagesL ), |
|
76 ENTRY( "messagesbyname", Ctlocale::messagesbyname ), |
|
77 ENTRY( "collateL", Ctlocale::collateL ), |
|
78 ENTRY( "collatebyname", Ctlocale::collatebyname ), |
|
79 ENTRY( "codecvt1", Ctlocale::codecvt1 ), |
|
80 ENTRY( "codecvt2", Ctlocale::codecvt2 ), |
|
81 ENTRY( "codecvtbyname1", Ctlocale::codecvtbyname1 ), |
|
82 ENTRY( "codecvtbyname2", Ctlocale::codecvtbyname2 ), |
|
83 |
|
84 ENTRY( "ctype_byname1", Ctlocale::ctype_byname1L), |
|
85 ENTRY( "moneypunct_byname1", Ctlocale::moneypunct_byname1L), |
|
86 ENTRY( "moneypunct1", Ctlocale::moneypunct1L), |
|
87 ENTRY( "numpunct1", Ctlocale::numpunct1L), |
|
88 ENTRY( "numpunct_byname1", Ctlocale::numpunct_byname1L), |
|
89 }; |
|
90 |
|
91 const TInt count = sizeof( KFunctions ) / |
|
92 sizeof( TStifFunctionInfo ); |
|
93 |
|
94 return RunInternalL( KFunctions, count, aItem ); |
|
95 |
|
96 } |
|
97 |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // Ctlocale::has_facet |
|
101 // has_facet test method function. |
|
102 // |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 |
|
106 |
|
107 TInt Ctlocale::hasfacet( CStifItemParser& aItem ) |
|
108 { |
|
109 int failures=0; |
|
110 __UHEAP_MARK; |
|
111 try |
|
112 { |
|
113 |
|
114 |
|
115 bool result = true; |
|
116 // __UHEAP_MARK; |
|
117 |
|
118 cout<<""; |
|
119 |
|
120 #if STDCPP_OOM |
|
121 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
122 #endif |
|
123 |
|
124 |
|
125 locale loc("en_GB.UTF-8") ; |
|
126 result = has_facet <ctype<char> > ( loc ); |
|
127 #if STDCPP_OOM |
|
128 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
129 #endif |
|
130 |
|
131 //__UHEAP_MARKEND; |
|
132 /* |
|
133 if(result) |
|
134 return KErrNone; |
|
135 else |
|
136 return KErrGeneral; |
|
137 */ |
|
138 if(!result) |
|
139 failures++; |
|
140 |
|
141 } |
|
142 |
|
143 |
|
144 catch(bad_alloc&) |
|
145 { |
|
146 //do nothing |
|
147 } |
|
148 catch(...) |
|
149 { |
|
150 failures++; |
|
151 |
|
152 } |
|
153 __UHEAP_MARKEND; |
|
154 if(failures ) |
|
155 return KErrGeneral; |
|
156 return KErrNone; |
|
157 } |
|
158 |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // Ctlocale::use_facet |
|
162 // use_facet test method function. |
|
163 // |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 |
|
167 |
|
168 TInt Ctlocale::usefacet( CStifItemParser& aItem ) |
|
169 { |
|
170 int failures=0; |
|
171 __UHEAP_MARK; |
|
172 try |
|
173 { |
|
174 |
|
175 |
|
176 locale loc ("en_GB.UTF-8"); |
|
177 cout<<""; |
|
178 #if STDCPP_OOM |
|
179 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
180 #endif |
|
181 bool result = use_facet<ctype<char> > ( loc ).is(ctype_base::alpha, 'b'); |
|
182 #if STDCPP_OOM |
|
183 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
184 #endif |
|
185 |
|
186 // __UHEAP_MARKEND; |
|
187 /* if (result) |
|
188 return KErrNone; |
|
189 else |
|
190 return KErrGeneral; |
|
191 |
|
192 */ |
|
193 |
|
194 if(!result) |
|
195 failures++; |
|
196 |
|
197 } |
|
198 |
|
199 catch(bad_alloc&) |
|
200 { |
|
201 //do nothing |
|
202 } |
|
203 catch(...) |
|
204 { |
|
205 failures++; |
|
206 |
|
207 } |
|
208 __UHEAP_MARKEND; |
|
209 |
|
210 if(failures ) |
|
211 return KErrGeneral; |
|
212 return KErrNone; |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // Ctlocale::num_get |
|
217 // num_get test method function. |
|
218 // |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 |
|
222 |
|
223 TInt Ctlocale::numget( CStifItemParser& aItem ) |
|
224 { |
|
225 int failures=0; |
|
226 __UHEAP_MARK; |
|
227 try |
|
228 { |
|
229 |
|
230 |
|
231 typedef istreambuf_iterator<char,char_traits<char> > |
|
232 iter_type; |
|
233 |
|
234 |
|
235 |
|
236 locale loc; |
|
237 iter_type end; |
|
238 cout<<""; |
|
239 #if STDCPP_OOM |
|
240 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
241 #endif |
|
242 const num_get<char,iter_type>& tg = use_facet<num_get<char,iter_type> >(loc); |
|
243 |
|
244 #if STDCPP_OOM |
|
245 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
246 #endif |
|
247 //return KErrNone; |
|
248 |
|
249 } |
|
250 |
|
251 |
|
252 catch(bad_alloc&) |
|
253 { |
|
254 //do nothing |
|
255 } |
|
256 catch(...) |
|
257 { |
|
258 failures++; |
|
259 |
|
260 } |
|
261 __UHEAP_MARKEND; |
|
262 if(failures ) |
|
263 return KErrGeneral; |
|
264 return KErrNone; |
|
265 } |
|
266 // ----------------------------------------------------------------------------- |
|
267 // Ctlocale::num_put |
|
268 // num_put test method function. |
|
269 // |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 TInt Ctlocale::numput( CStifItemParser& aItem ) |
|
273 { |
|
274 __UHEAP_MARK; |
|
275 int failures=0; |
|
276 try |
|
277 { |
|
278 |
|
279 |
|
280 typedef ostreambuf_iterator<char,char_traits<char> > |
|
281 iter_type; |
|
282 |
|
283 locale loc; |
|
284 |
|
285 |
|
286 // Construct a ostreambuf_iterator on cout |
|
287 iter_type begin(cout); |
|
288 |
|
289 // Get a num_put facet reference |
|
290 cout<<""; |
|
291 #if STDCPP_OOM |
|
292 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
293 #endif |
|
294 const num_put<char,iter_type>& np = use_facet<num_put<char,iter_type> >(loc); |
|
295 #if STDCPP_OOM |
|
296 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
297 #endif |
|
298 |
|
299 //return KErrNone; |
|
300 |
|
301 } |
|
302 |
|
303 |
|
304 |
|
305 catch(bad_alloc&) |
|
306 { |
|
307 //do nothing |
|
308 } |
|
309 catch(...) |
|
310 { |
|
311 failures++; |
|
312 |
|
313 } |
|
314 __UHEAP_MARKEND; |
|
315 if(failures ) |
|
316 return KErrGeneral; |
|
317 return KErrNone; |
|
318 } |
|
319 // ----------------------------------------------------------------------------- |
|
320 // Ctlocale::num_punct |
|
321 // num_punct test method function. |
|
322 // |
|
323 // ----------------------------------------------------------------------------- |
|
324 // |
|
325 TInt Ctlocale::num_punct( CStifItemParser& aItem ) |
|
326 { |
|
327 __UHEAP_MARK; |
|
328 int failures=0; |
|
329 try |
|
330 { |
|
331 |
|
332 |
|
333 locale loc; |
|
334 cout<<""; |
|
335 #if STDCPP_OOM |
|
336 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
337 #endif |
|
338 const numpunct <char> &npunct = use_facet <numpunct <char> >( loc); |
|
339 // const numpunct <unsigned> &n1punct = use_facet <numpunct <unsigned> >( loc); |
|
340 #if STDCPP_OOM |
|
341 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
342 #endif |
|
343 /* |
|
344 if(npunct.truename() == "true") |
|
345 if(npunct.falsename()=="false") |
|
346 if(npunct.decimal_point() =='.') |
|
347 if(npunct.thousands_sep() ==',') |
|
348 |
|
349 |
|
350 |
|
351 return KErrNone; |
|
352 else |
|
353 return KErrGeneral;*/ |
|
354 if(npunct.truename() != "true") |
|
355 failures++; |
|
356 if(npunct.falsename()!="false") |
|
357 failures++; |
|
358 if(npunct.decimal_point() !='.') |
|
359 failures++; |
|
360 if(npunct.thousands_sep() !=',') |
|
361 failures++; |
|
362 |
|
363 } |
|
364 |
|
365 |
|
366 catch(bad_alloc&) |
|
367 { |
|
368 //do nothing |
|
369 } |
|
370 catch(...) |
|
371 { |
|
372 failures++; |
|
373 |
|
374 } |
|
375 __UHEAP_MARKEND; |
|
376 if(failures ) |
|
377 return KErrGeneral; |
|
378 return KErrNone; |
|
379 } |
|
380 // ----------------------------------------------------------------------------- |
|
381 // Ctlocale::numpunct_byname |
|
382 // numpunct_byname test method function. |
|
383 // |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 TInt Ctlocale::numpunctbyname( CStifItemParser& aItem ) |
|
387 { |
|
388 int failures=0; |
|
389 __UHEAP_MARK; |
|
390 try |
|
391 { |
|
392 |
|
393 |
|
394 locale loc; |
|
395 cout<<""; |
|
396 #if STDCPP_OOM |
|
397 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
398 #endif |
|
399 const numpunct_byname <char> &npunct = use_facet <numpunct_byname <char> >( loc); |
|
400 #if STDCPP_OOM |
|
401 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
402 #endif |
|
403 |
|
404 /*if(npunct.truename() == "true") |
|
405 if(npunct.falsename()=="false") |
|
406 if(npunct.decimal_point( ) =='.') |
|
407 if(npunct.thousands_sep( ) ==',') |
|
408 |
|
409 |
|
410 |
|
411 return KErrNone; |
|
412 else |
|
413 return KErrGeneral;*/ |
|
414 |
|
415 if(npunct.truename() != "true") |
|
416 failures++; |
|
417 if(npunct.falsename()!="false") |
|
418 failures++; |
|
419 if(npunct.decimal_point( ) !='.') |
|
420 failures++; |
|
421 if(npunct.thousands_sep( ) !=',') |
|
422 failures++; |
|
423 |
|
424 } |
|
425 |
|
426 catch(bad_alloc&) |
|
427 { |
|
428 //do nothing |
|
429 } |
|
430 catch(...) |
|
431 { |
|
432 failures++; |
|
433 |
|
434 } |
|
435 __UHEAP_MARKEND; |
|
436 if(failures ) |
|
437 return KErrGeneral; |
|
438 return KErrNone; |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // Ctlocale::money_get |
|
443 // money_get test method function. |
|
444 // |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
447 |
|
448 TInt Ctlocale::moneyget( CStifItemParser& aItem ) |
|
449 { |
|
450 int failures=0; |
|
451 __UHEAP_MARK; |
|
452 try |
|
453 { |
|
454 |
|
455 |
|
456 typedef istreambuf_iterator<char,char_traits<char> > |
|
457 iter_type; |
|
458 |
|
459 locale loc; |
|
460 string buffer("$100.02"); |
|
461 string dest; |
|
462 long double ldest; |
|
463 ios_base::iostate state; |
|
464 iter_type end; |
|
465 cout<<""; |
|
466 #if STDCPP_OOM |
|
467 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
468 #endif |
|
469 // Get a money_get facet |
|
470 const money_get<char,iter_type>& mgf = use_facet<money_get<char,iter_type> >(loc); |
|
471 |
|
472 #if STDCPP_OOM |
|
473 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
474 #endif |
|
475 |
|
476 // return KErrNone; |
|
477 |
|
478 } |
|
479 |
|
480 |
|
481 catch(bad_alloc&) |
|
482 { |
|
483 //do nothing |
|
484 } |
|
485 catch(...) |
|
486 { |
|
487 failures++; |
|
488 |
|
489 } |
|
490 __UHEAP_MARKEND; |
|
491 if(failures ) |
|
492 return KErrGeneral; |
|
493 return KErrNone; |
|
494 } |
|
495 // ----------------------------------------------------------------------------- |
|
496 // Ctlocale::money_put |
|
497 // money_put test method function. |
|
498 // |
|
499 // ----------------------------------------------------------------------------- |
|
500 // |
|
501 TInt Ctlocale::moneyput( CStifItemParser& aItem ) |
|
502 { |
|
503 int failures=0; |
|
504 |
|
505 try |
|
506 { |
|
507 |
|
508 |
|
509 typedef ostreambuf_iterator<char,char_traits<char> > |
|
510 iter_type; |
|
511 |
|
512 locale loc; |
|
513 string buffer("10002"); |
|
514 long double ldval = 10002; |
|
515 |
|
516 iter_type begin(cout); |
|
517 cout<<""; |
|
518 #if STDCPP_OOM |
|
519 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
520 #endif |
|
521 const money_put<char,iter_type>& mp = use_facet<money_put<char,iter_type> >(loc); |
|
522 |
|
523 #if STDCPP_OOM |
|
524 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
525 #endif |
|
526 |
|
527 |
|
528 //return KErrNone; |
|
529 |
|
530 } |
|
531 |
|
532 |
|
533 catch(bad_alloc&) |
|
534 { |
|
535 //do nothing |
|
536 } |
|
537 catch(...) |
|
538 { |
|
539 failures++; |
|
540 |
|
541 } |
|
542 __UHEAP_MARKEND; |
|
543 if(failures ) |
|
544 return KErrGeneral; |
|
545 return KErrNone; |
|
546 } |
|
547 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // Ctlocale::moneypunct |
|
550 // moneypunct test method function. |
|
551 // |
|
552 // ----------------------------------------------------------------------------- |
|
553 // |
|
554 TInt Ctlocale::money_punct( CStifItemParser& aItem ) |
|
555 { |
|
556 |
|
557 int failures=0; |
|
558 try |
|
559 { |
|
560 |
|
561 |
|
562 |
|
563 locale loc; |
|
564 cout<<""; |
|
565 #if STDCPP_OOM |
|
566 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
567 #endif |
|
568 const moneypunct<char,false>& mp = |
|
569 use_facet<moneypunct<char,false> >(loc); |
|
570 #if STDCPP_OOM |
|
571 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
572 #endif |
|
573 mp.curr_symbol(); |
|
574 mp.negative_sign(); |
|
575 |
|
576 /* if(mp.decimal_point() == '.') |
|
577 if(mp.thousands_sep() == ',') |
|
578 if( mp.frac_digits() == 0) |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 return KErrNone; |
|
584 else |
|
585 return KErrGeneral;*/ |
|
586 |
|
587 if(mp.decimal_point() != '.') |
|
588 failures++; |
|
589 if(mp.thousands_sep() != ',') |
|
590 failures++; |
|
591 if( mp.frac_digits() != 0) |
|
592 failures++; |
|
593 |
|
594 |
|
595 } |
|
596 |
|
597 |
|
598 |
|
599 catch(bad_alloc&) |
|
600 { |
|
601 //do nothing |
|
602 } |
|
603 catch(...) |
|
604 { |
|
605 failures++; |
|
606 |
|
607 } |
|
608 |
|
609 if(failures ) |
|
610 return KErrGeneral; |
|
611 return KErrNone; |
|
612 } |
|
613 |
|
614 // ----------------------------------------------------------------------------- |
|
615 // Ctlocale::moneypunct_byname |
|
616 // moneypunct_byname test method function. |
|
617 // |
|
618 // ----------------------------------------------------------------------------- |
|
619 // |
|
620 |
|
621 TInt Ctlocale::moneypunctbyname( CStifItemParser& aItem ) |
|
622 { |
|
623 |
|
624 int failures=0; |
|
625 try |
|
626 { |
|
627 |
|
628 |
|
629 |
|
630 locale loc; |
|
631 |
|
632 cout<<""; |
|
633 #if STDCPP_OOM |
|
634 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
635 #endif |
|
636 const moneypunct_byname<char,false>& mp = |
|
637 |
|
638 use_facet<moneypunct_byname<char,false> >(loc); |
|
639 |
|
640 |
|
641 #if STDCPP_OOM |
|
642 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
643 #endif |
|
644 |
|
645 mp.curr_symbol(); |
|
646 mp.negative_sign(); |
|
647 if(mp.decimal_point() != '.') |
|
648 failures++; |
|
649 if(mp.thousands_sep() != ',') |
|
650 failures++; |
|
651 if( mp.frac_digits() != 0) |
|
652 failures++; |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 |
|
658 } |
|
659 |
|
660 catch(bad_alloc&) |
|
661 { |
|
662 //do nothing |
|
663 } |
|
664 catch(...) |
|
665 { |
|
666 failures++; |
|
667 |
|
668 } |
|
669 |
|
670 if(failures ) |
|
671 return KErrGeneral; |
|
672 return KErrNone; |
|
673 } |
|
674 |
|
675 // ----------------------------------------------------------------------------- |
|
676 // Ctlocale::time_get |
|
677 // time_get test method function. |
|
678 // |
|
679 // ----------------------------------------------------------------------------- |
|
680 // |
|
681 |
|
682 |
|
683 TInt Ctlocale::timeget( CStifItemParser& aItem ) |
|
684 { |
|
685 int failures=0; |
|
686 |
|
687 try |
|
688 { |
|
689 |
|
690 |
|
691 typedef std::istreambuf_iterator<char, |
|
692 std::char_traits<char> > Iter; |
|
693 static struct tm timeb; |
|
694 std::ios_base::iostate state; |
|
695 cout<<""; |
|
696 #if STDCPP_OOM |
|
697 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
698 #endif |
|
699 const std::time_get<char, Iter> &tg = |
|
700 std::use_facet<std::time_get<char, Iter> >(std::locale ("C")); |
|
701 #if STDCPP_OOM |
|
702 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
703 #endif |
|
704 //return KErrNone; |
|
705 |
|
706 } |
|
707 |
|
708 |
|
709 catch(bad_alloc&) |
|
710 { |
|
711 //do nothing |
|
712 } |
|
713 catch(...) |
|
714 { |
|
715 failures++; |
|
716 |
|
717 } |
|
718 |
|
719 if(failures ) |
|
720 return KErrGeneral; |
|
721 return KErrNone; |
|
722 } |
|
723 |
|
724 // ----------------------------------------------------------------------------- |
|
725 // Ctlocale::time_put |
|
726 // time_put test method function. |
|
727 // |
|
728 // ----------------------------------------------------------------------------- |
|
729 // |
|
730 TInt Ctlocale::timeput( CStifItemParser& aItem ) |
|
731 { |
|
732 |
|
733 int failures=0; |
|
734 try |
|
735 { |
|
736 |
|
737 |
|
738 std::tm t = std::tm (); |
|
739 |
|
740 t.tm_sec = 56; |
|
741 t.tm_min = 34; |
|
742 t.tm_hour = 14; |
|
743 t.tm_mday = 29; |
|
744 t.tm_mon = 1; |
|
745 t.tm_year = 84; |
|
746 |
|
747 t.tm_yday = 59; |
|
748 t.tm_wday = 3; |
|
749 t.tm_isdst = 0; |
|
750 |
|
751 const char* const fmt[] = { |
|
752 "%a", "%A", "%b", "%B", "%c", "%C", "%d", "%D", |
|
753 "%e", "%F", "%g", "%G", "%h", "%H", "%I", "%j", |
|
754 "%k", "%l", "%m", "%M", "%n", "%p", "%r", "%R", |
|
755 "%S", "%t", "%T", "%u", "%U", "%V", "%w", "%W", "%x", |
|
756 "%X", "%y", "%Y", "%z", "%Z", "%%", "%Ec", "%EC", "%Ex", |
|
757 "%EX", "%Ey", "%EY", "%Od", "%Oe", "%OH", "%OI", "%Om", |
|
758 "%OM", "%OS", "%Ou", "%OU", "%OV", "%Ow", "%OW", "%Oy" |
|
759 }; |
|
760 cout<<""; |
|
761 #if STDCPP_OOM |
|
762 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
763 #endif |
|
764 const std::time_put<char> &tput = |
|
765 std::use_facet<std::time_put<char> >(std::cout.getloc ()); |
|
766 |
|
767 #if STDCPP_OOM |
|
768 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
769 #endif |
|
770 |
|
771 //return KErrNone; |
|
772 |
|
773 } |
|
774 |
|
775 |
|
776 catch(bad_alloc&) |
|
777 { |
|
778 //do nothing |
|
779 } |
|
780 catch(...) |
|
781 { |
|
782 failures++; |
|
783 |
|
784 } |
|
785 |
|
786 if(failures ) |
|
787 return KErrGeneral; |
|
788 return KErrNone; |
|
789 } |
|
790 |
|
791 // ----------------------------------------------------------------------------- |
|
792 // Ctlocale::messages |
|
793 // messages test method function. |
|
794 // |
|
795 // ----------------------------------------------------------------------------- |
|
796 // |
|
797 |
|
798 TInt Ctlocale::messagesL( CStifItemParser& aItem ) |
|
799 { |
|
800 int failures=0; |
|
801 |
|
802 try |
|
803 { |
|
804 |
|
805 |
|
806 locale loc; |
|
807 cout<<""; |
|
808 #if STDCPP_OOM |
|
809 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
810 #endif |
|
811 const messages<char>& mess =use_facet<messages<char> >(loc); |
|
812 #if STDCPP_OOM |
|
813 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
814 #endif |
|
815 // no support to .cat files |
|
816 |
|
817 /* |
|
818 string def("Message Not Found"); |
|
819 messages<char>::catalog cat = |
|
820 mess.open("./rwstdmessages.cat",loc); |
|
821 if (cat != -1) |
|
822 { |
|
823 string msg0 = mess.get(cat,1,1,def); |
|
824 string msg1 = mess.get(cat,1,2,def); |
|
825 string msg2 = mess.get(cat,1,6,def); // invalid msg # |
|
826 string msg3 = mess.get(cat,2,1,def); |
|
827 |
|
828 mess.close(cat); |
|
829 cout << msg0 << endl << msg1 << endl |
|
830 << msg2 << endl << msg3 << endl; |
|
831 } |
|
832 else |
|
833 cout << "Unable to open message catalog" << endl;*/ |
|
834 |
|
835 //return KErrNone; |
|
836 |
|
837 } |
|
838 |
|
839 |
|
840 |
|
841 catch(bad_alloc&) |
|
842 { |
|
843 //do nothing |
|
844 } |
|
845 catch(...) |
|
846 { |
|
847 failures++; |
|
848 |
|
849 } |
|
850 |
|
851 if(failures ) |
|
852 return KErrGeneral; |
|
853 return KErrNone; |
|
854 } |
|
855 |
|
856 // ----------------------------------------------------------------------------- |
|
857 // Ctlocale::messages_byname |
|
858 // messages_byname test method function. |
|
859 // |
|
860 // ----------------------------------------------------------------------------- |
|
861 // |
|
862 TInt Ctlocale::messagesbyname( CStifItemParser& aItem ) |
|
863 { |
|
864 int failures=0; |
|
865 |
|
866 try |
|
867 { |
|
868 |
|
869 |
|
870 locale loc; |
|
871 cout<<""; |
|
872 #if STDCPP_OOM |
|
873 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
874 #endif |
|
875 const messages_byname<char>& mess = |
|
876 |
|
877 use_facet<messages_byname<char> >(loc); |
|
878 #if STDCPP_OOM |
|
879 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
880 #endif |
|
881 |
|
882 // no support to .cat files |
|
883 /* |
|
884 string def("Message Not Found"); |
|
885 messages_byname<char>::catalog cat = |
|
886 mess.open("./rwstdmessages.cat",loc); |
|
887 if (cat != -1) |
|
888 { |
|
889 string msg0 = mess.get(cat,1,1,def); |
|
890 string msg1 = mess.get(cat,1,2,def); |
|
891 string msg2 = mess.get(cat,1,6,def); // invalid msg # |
|
892 string msg3 = mess.get(cat,2,1,def); |
|
893 |
|
894 mess.close(cat); |
|
895 cout << msg0 << endl << msg1 << endl |
|
896 << msg2 << endl << msg3 << endl; |
|
897 } |
|
898 else |
|
899 cout << "Unable to open message catalog" << endl;*/ |
|
900 |
|
901 //return KErrNone; |
|
902 } |
|
903 |
|
904 |
|
905 catch(bad_alloc&) |
|
906 { |
|
907 //do nothing |
|
908 } |
|
909 catch(...) |
|
910 { |
|
911 failures++; |
|
912 |
|
913 } |
|
914 |
|
915 if(failures ) |
|
916 return KErrGeneral; |
|
917 return KErrNone; |
|
918 } |
|
919 |
|
920 // ----------------------------------------------------------------------------- |
|
921 // Ctlocale::collate |
|
922 // collate test method function. |
|
923 // |
|
924 // ----------------------------------------------------------------------------- |
|
925 // |
|
926 TInt Ctlocale::collateL( CStifItemParser& aItem ) |
|
927 { |
|
928 int failures =0; |
|
929 try |
|
930 { |
|
931 |
|
932 |
|
933 locale loc; |
|
934 string s1("blue"); |
|
935 string s2("blues"); |
|
936 cout<<""; |
|
937 #if STDCPP_OOM |
|
938 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
939 #endif |
|
940 const collate<char>& co = |
|
941 use_facet<collate<char> >(loc); |
|
942 |
|
943 if( co.compare(s1.begin(),s1.end(),s2.begin(),s2.end()-1) != 0) |
|
944 failures++; |
|
945 |
|
946 if( co.compare(s1.begin(),s1.end(), s2.begin(),s2.end()) != -1) |
|
947 failures++; |
|
948 |
|
949 // Retrieve hash values for two strings |
|
950 if( co.hash(s1.begin(),s1.end())!= 15636) |
|
951 failures++; |
|
952 #if STDCPP_OOM |
|
953 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
954 #endif |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 } |
|
961 |
|
962 catch(bad_alloc&) |
|
963 { |
|
964 //do nothing |
|
965 } |
|
966 catch(...) |
|
967 { |
|
968 failures++; |
|
969 |
|
970 } |
|
971 |
|
972 if(failures ) |
|
973 return KErrGeneral; |
|
974 return KErrNone; |
|
975 } |
|
976 // ----------------------------------------------------------------------------- |
|
977 // Ctlocale::collatebyname |
|
978 // collatebyname test method function. |
|
979 // |
|
980 // ----------------------------------------------------------------------------- |
|
981 // |
|
982 TInt Ctlocale::collatebyname( CStifItemParser& aItem ) |
|
983 { |
|
984 int failures =0; |
|
985 try |
|
986 { |
|
987 |
|
988 |
|
989 locale loc; |
|
990 string s1("blue"); |
|
991 string s2("blues"); |
|
992 cout<<""; |
|
993 #if STDCPP_OOM |
|
994 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
995 #endif |
|
996 const collate_byname<char>& co = use_facet<collate_byname<char> >(loc); |
|
997 |
|
998 if( co.compare(s1.begin(),s1.end(),s2.begin(),s2.end()-1) != 0) |
|
999 failures++; |
|
1000 |
|
1001 if( co.compare(s1.begin(),s1.end(), s2.begin(),s2.end()) != -1) |
|
1002 failures++; |
|
1003 |
|
1004 // Retrieve hash values for two strings |
|
1005 if( co.hash(s1.begin(),s1.end())!= 15636) |
|
1006 failures++; |
|
1007 #if STDCPP_OOM |
|
1008 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1009 #endif |
|
1010 |
|
1011 |
|
1012 |
|
1013 |
|
1014 |
|
1015 } |
|
1016 |
|
1017 |
|
1018 catch(bad_alloc&) |
|
1019 { |
|
1020 //do nothing |
|
1021 } |
|
1022 catch(...) |
|
1023 { |
|
1024 failures++; |
|
1025 |
|
1026 } |
|
1027 |
|
1028 if(failures ) |
|
1029 return KErrGeneral; |
|
1030 return KErrNone; |
|
1031 } |
|
1032 |
|
1033 |
|
1034 |
|
1035 // ----------------------------------------------------------------------------- |
|
1036 // Ctlocale::codecvt1 |
|
1037 // codecvt1 test method function. |
|
1038 // |
|
1039 // ----------------------------------------------------------------------------- |
|
1040 // |
|
1041 |
|
1042 TInt Ctlocale::codecvt1( CStifItemParser& aItem ) |
|
1043 { |
|
1044 __UHEAP_MARK; |
|
1045 |
|
1046 locale loc ( "de_DE.ISO-8859-1" ); |
|
1047 int failures=0; |
|
1048 try |
|
1049 { |
|
1050 cout<<""; |
|
1051 #if STDCPP_OOM |
|
1052 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1053 #endif |
|
1054 int result = use_facet<codecvt<char, char, mbstate_t> > ( loc ).encoding (); |
|
1055 if(result != 1) |
|
1056 failures++; |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 char* str = "This is the string whose length is to be measured!"; |
|
1062 mbstate_t state = {0}; |
|
1063 locale loc1("C");//English_Britain");//German_Germany |
|
1064 //int res = use_facet<codecvt<wchar_t, char, mbstate_t>>( loc ).length( state,str, &str[strlen(str)], 90 ); |
|
1065 |
|
1066 |
|
1067 int res = use_facet<codecvt<wchar_t, char, mbstate_t> > |
|
1068 ( loc1 ).length( state,str, &str[strlen(str)], 90 ); |
|
1069 |
|
1070 |
|
1071 |
|
1072 if(res!=50) |
|
1073 failures++; |
|
1074 |
|
1075 |
|
1076 |
|
1077 locale loc2( "C");//English_Britain" );//German_Germany |
|
1078 int res2 = use_facet<codecvt<char, char, mbstate_t> > |
|
1079 ( loc ).max_length( ); |
|
1080 if(res2!=1) |
|
1081 failures++; |
|
1082 |
|
1083 |
|
1084 #if STDCPP_OOM |
|
1085 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1086 #endif |
|
1087 |
|
1088 } |
|
1089 |
|
1090 |
|
1091 catch(bad_alloc&) |
|
1092 { |
|
1093 //do nothing |
|
1094 } |
|
1095 catch(...) |
|
1096 { |
|
1097 failures++; |
|
1098 |
|
1099 } |
|
1100 __UHEAP_MARKEND; |
|
1101 |
|
1102 if(failures ) |
|
1103 return KErrGeneral; |
|
1104 return KErrNone; |
|
1105 } |
|
1106 |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 // Ctlocale::codecvt2 |
|
1109 // codecvt2 test method function. |
|
1110 // |
|
1111 // ----------------------------------------------------------------------------- |
|
1112 // |
|
1113 TInt Ctlocale::codecvt2( CStifItemParser& aItem ) |
|
1114 { |
|
1115 int failures=0; |
|
1116 try |
|
1117 { |
|
1118 |
|
1119 |
|
1120 char strout[91]; |
|
1121 wchar_t *strin = L"This is the wchar_t string to be converted."; |
|
1122 memset( &strout[0], 0, ( sizeof( char ) )*( 91 ) ); |
|
1123 char* strnext; |
|
1124 const wchar_t* pwszNext; |
|
1125 mbstate_t state; |
|
1126 locale loc("C"); |
|
1127 cout<<""; |
|
1128 #if STDCPP_OOM |
|
1129 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1130 #endif |
|
1131 int res = use_facet<codecvt<wchar_t, char, mbstate_t> > |
|
1132 ( loc ).out( state,strin, &strin[wcslen( strin )], pwszNext , |
|
1133 strout, &strout[wcslen( strin )], strnext ); |
|
1134 #if STDCPP_OOM |
|
1135 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1136 #endif |
|
1137 strout[wcslen( strin )] = 0; |
|
1138 |
|
1139 string str = "This is the wchar_t string to be converted."; |
|
1140 |
|
1141 /*if(str.compare(&strout[0]) == 0) |
|
1142 return KErrNone; |
|
1143 else |
|
1144 return KErrGeneral; |
|
1145 |
|
1146 */ |
|
1147 |
|
1148 if(str.compare(&strout[0]) != 0) |
|
1149 failures++; |
|
1150 |
|
1151 } |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 catch(bad_alloc&) |
|
1157 { |
|
1158 //do nothing |
|
1159 } |
|
1160 catch(...) |
|
1161 { |
|
1162 failures++; |
|
1163 |
|
1164 } |
|
1165 |
|
1166 if(failures ) |
|
1167 return KErrGeneral; |
|
1168 return KErrNone; |
|
1169 } |
|
1170 |
|
1171 |
|
1172 // ----------------------------------------------------------------------------- |
|
1173 // Ctlocale::codecvtbyname1 |
|
1174 // codecvtbyname1 test method function. |
|
1175 // |
|
1176 // ----------------------------------------------------------------------------- |
|
1177 // |
|
1178 |
|
1179 TInt Ctlocale::codecvtbyname1( CStifItemParser& aItem ) |
|
1180 { |
|
1181 __UHEAP_MARK; |
|
1182 |
|
1183 locale loc ( "de_DE.ISO-8859-1" ); |
|
1184 int failures=0; |
|
1185 try |
|
1186 { |
|
1187 cout<<""; |
|
1188 #if STDCPP_OOM |
|
1189 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1190 #endif |
|
1191 int result = use_facet<codecvt_byname<char, char, mbstate_t> > ( loc ).encoding (); |
|
1192 #if STDCPP_OOM |
|
1193 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1194 #endif |
|
1195 if(result != 1) |
|
1196 failures++; |
|
1197 |
|
1198 |
|
1199 char* str = "This is the string whose length is to be measured!"; |
|
1200 mbstate_t state = {0}; |
|
1201 locale loc1("C"); |
|
1202 |
|
1203 #if STDCPP_OOM |
|
1204 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1205 #endif |
|
1206 int res = use_facet<codecvt_byname<wchar_t, char, mbstate_t> > |
|
1207 ( loc1 ).length( state,str, &str[strlen(str)], 90 ); |
|
1208 |
|
1209 #if STDCPP_OOM |
|
1210 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1211 #endif |
|
1212 |
|
1213 if(res!=50) |
|
1214 failures++; |
|
1215 |
|
1216 |
|
1217 |
|
1218 locale loc2( "C"); |
|
1219 #if STDCPP_OOM |
|
1220 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1221 #endif |
|
1222 int res2 = use_facet<codecvt_byname<char, char, mbstate_t> >( loc ).max_length( ); |
|
1223 #if STDCPP_OOM |
|
1224 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1225 #endif |
|
1226 if(res2!=1) |
|
1227 failures++; |
|
1228 |
|
1229 |
|
1230 } |
|
1231 |
|
1232 |
|
1233 catch(bad_alloc&) |
|
1234 { |
|
1235 //do nothing |
|
1236 } |
|
1237 catch(...) |
|
1238 { |
|
1239 failures++; |
|
1240 |
|
1241 } |
|
1242 __UHEAP_MARKEND; |
|
1243 |
|
1244 if(failures ) |
|
1245 return KErrGeneral; |
|
1246 return KErrNone; |
|
1247 } |
|
1248 |
|
1249 |
|
1250 // ----------------------------------------------------------------------------- |
|
1251 // Ctlocale::codecvtbyname2 |
|
1252 // codecvtbyname2 test method function. |
|
1253 // |
|
1254 // ----------------------------------------------------------------------------- |
|
1255 // |
|
1256 TInt Ctlocale::codecvtbyname2( CStifItemParser& aItem ) |
|
1257 { |
|
1258 int failures=0; |
|
1259 try |
|
1260 { |
|
1261 |
|
1262 |
|
1263 char* strout = "This is the string to be converted!"; |
|
1264 wchar_t strin [91]; |
|
1265 memset(&strin[0], 0, (sizeof(wchar_t))*(91)); |
|
1266 const char* pszNext; |
|
1267 wchar_t* pwszNext; |
|
1268 mbstate_t state = {0}; |
|
1269 locale loc("C"); |
|
1270 cout<<""; |
|
1271 #if STDCPP_OOM |
|
1272 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1273 #endif |
|
1274 int res = use_facet<codecvt<wchar_t, char, mbstate_t> > |
|
1275 ( loc ).in( state, strout, &strout[strlen(strout)], pszNext, |
|
1276 strin, &strin[strlen(strout)], pwszNext ); |
|
1277 #if STDCPP_OOM |
|
1278 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1279 #endif |
|
1280 strin[strlen(strout)] = 0; |
|
1281 |
|
1282 wstring str = L"This is the string to be converted!"; |
|
1283 |
|
1284 /* |
|
1285 if(str.compare(&strin[0]) == 0) |
|
1286 return KErrNone; |
|
1287 else |
|
1288 return KErrGeneral; |
|
1289 |
|
1290 */ |
|
1291 if(str.compare(&strin[0]) != 0) |
|
1292 failures++; |
|
1293 |
|
1294 |
|
1295 } |
|
1296 |
|
1297 |
|
1298 catch(bad_alloc&) |
|
1299 { |
|
1300 //do nothing |
|
1301 } |
|
1302 catch(...) |
|
1303 { |
|
1304 failures++; |
|
1305 |
|
1306 } |
|
1307 |
|
1308 if(failures ) |
|
1309 return KErrGeneral; |
|
1310 return KErrNone; |
|
1311 } |
|
1312 |
|
1313 |
|
1314 |
|
1315 // helper API |
|
1316 template<class _CharT> |
|
1317 void Convert_string2_string_chart(basic_string<_CharT> &dst, string src) |
|
1318 { |
|
1319 int length = src.length(); |
|
1320 const char* str = src.c_str(); |
|
1321 for(int i = 0; i<length;i++) |
|
1322 { |
|
1323 dst.append(1, (_CharT)*str++); |
|
1324 |
|
1325 } |
|
1326 |
|
1327 } |
|
1328 |
|
1329 #if 1 |
|
1330 |
|
1331 // ----------------------------------------------------------------------------- |
|
1332 // Ctlocale::ctype_byname_test1L |
|
1333 // ----------------------------------------------------------------------------- |
|
1334 // |
|
1335 struct MyCtype_bybname : public ctype_byname<testChar> { |
|
1336 MyCtype_bybname(const char *name, size_t refs) |
|
1337 : ctype_byname<testChar>(name, refs) {} |
|
1338 testChar my_do_toupper(testChar ch) const |
|
1339 {return (this->do_toupper(ch)); } |
|
1340 const testChar *my_do_toupper(testChar *first, |
|
1341 const testChar *last) const |
|
1342 {return (this->do_toupper(first, last)); } |
|
1343 testChar my_do_tolower(testChar ch) const |
|
1344 {return (this->do_tolower(ch)); } |
|
1345 const testChar *my_do_tolower(testChar *first, |
|
1346 const testChar *last) const |
|
1347 {return (this->do_tolower(first, last)); } |
|
1348 }; |
|
1349 // ----------------------------------------------------------------------------- |
|
1350 // Ctlocale::ExampleL |
|
1351 // Example test method function. |
|
1352 // (other items were commented in a header). |
|
1353 // ----------------------------------------------------------------------------- |
|
1354 // |
|
1355 |
|
1356 TInt Ctlocale::ctype_byname1L( CStifItemParser& aItem ) |
|
1357 { |
|
1358 |
|
1359 // Print to UI |
|
1360 _LIT( Ktlocale, "tlocale" ); |
|
1361 _LIT( Ktest1, "In Test1" ); |
|
1362 TestModuleIf().Printf( 0, Ktlocale, Ktest1 ); |
|
1363 // Print to log file |
|
1364 iLog->Log( Ktest1 ); |
|
1365 |
|
1366 TInt i = 0; |
|
1367 TPtrC string; |
|
1368 _LIT( KParam, "Param[%i]: %S" ); |
|
1369 |
|
1370 MyCtype_bybname fac("C", 1); |
|
1371 |
|
1372 if (fac.my_do_toupper('a') != 'A') |
|
1373 return KErrGeneral; |
|
1374 |
|
1375 testChar a[] = {"ABc0D"}; |
|
1376 fac.my_do_tolower(a, a + 2); |
|
1377 if (strcmp((const char *)a, "abc0D") != 0) |
|
1378 return KErrGeneral; |
|
1379 |
|
1380 return KErrNone; |
|
1381 |
|
1382 } |
|
1383 |
|
1384 |
|
1385 |
|
1386 // ----------------------------------------------------------------------------- |
|
1387 // Ctlocale::moneypunct_byname_test3L |
|
1388 // ----------------------------------------------------------------------------- |
|
1389 // |
|
1390 struct Mympunct_byname : public moneypunct_byname<testChar, true> { |
|
1391 Mympunct_byname(const char *name, size_t refs) |
|
1392 : moneypunct_byname<testChar, true>(name, refs) {} |
|
1393 testChar my_do_decimal_point() const |
|
1394 {return (do_decimal_point()); } |
|
1395 }; |
|
1396 |
|
1397 TInt Ctlocale::moneypunct_byname1L( CStifItemParser& aItem ) |
|
1398 { |
|
1399 |
|
1400 // Print to UI |
|
1401 |
|
1402 _LIT( Ktlocale, "tlocale" ); |
|
1403 _LIT( Ktest1, "In Test3" ); |
|
1404 TestModuleIf().Printf( 0, Ktlocale, Ktest1 ); |
|
1405 // Print to log file |
|
1406 iLog->Log( Ktest1 ); |
|
1407 |
|
1408 TInt i = 0; |
|
1409 TPtrC string; |
|
1410 _LIT( KParam, "Param[%i]: %S" ); |
|
1411 |
|
1412 Mympunct_byname fac("C", 1); |
|
1413 testChar ch = fac.my_do_decimal_point(); |
|
1414 if (ch != 0) |
|
1415 return KErrGeneral; |
|
1416 return KErrNone; |
|
1417 |
|
1418 |
|
1419 } |
|
1420 // ----------------------------------------------------------------------------- |
|
1421 // Ctlocale::moneypunct_test2L |
|
1422 // ----------------------------------------------------------------------------- |
|
1423 // |
|
1424 struct Mymoneypunct : public moneypunct<testChar, true> { |
|
1425 string_type my_do_positive_sign() const |
|
1426 {return (do_positive_sign()); } |
|
1427 }; |
|
1428 |
|
1429 TInt Ctlocale::moneypunct1L( CStifItemParser& aItem ) |
|
1430 { |
|
1431 |
|
1432 // Print to UI |
|
1433 _LIT( Ktlocale, "tlocale" ); |
|
1434 _LIT( Ktest1, "In Test2" ); |
|
1435 TestModuleIf().Printf( 0, Ktlocale, Ktest1 ); |
|
1436 // Print to log file |
|
1437 iLog->Log( Ktest1 ); |
|
1438 |
|
1439 TInt i = 0; |
|
1440 TPtrC string; |
|
1441 _LIT( KParam, "Param[%i]: %S" ); |
|
1442 |
|
1443 Mymoneypunct fac; |
|
1444 basic_string<testChar> str = fac.my_do_positive_sign(); |
|
1445 if(str.size() != 0) |
|
1446 return KErrGeneral; |
|
1447 |
|
1448 return KErrNone; |
|
1449 |
|
1450 } |
|
1451 |
|
1452 |
|
1453 // ----------------------------------------------------------------------------- |
|
1454 // Ctlocale::numpunct_test4L |
|
1455 // ----------------------------------------------------------------------------- |
|
1456 // |
|
1457 |
|
1458 struct Mynumpunct : public numpunct<testChar> { |
|
1459 protected: |
|
1460 basic_string<testChar> do_truename() const |
|
1461 { basic_string<testChar> str1; |
|
1462 Convert_string2_string_chart(str1,"!"); |
|
1463 return str1; } |
|
1464 basic_string<testChar> do_falsename() const |
|
1465 { |
|
1466 basic_string<testChar> str1; |
|
1467 Convert_string2_string_chart(str1,"!!"); |
|
1468 return str1; } |
|
1469 }; |
|
1470 |
|
1471 TInt Ctlocale::numpunct1L( CStifItemParser& aItem ) |
|
1472 { |
|
1473 |
|
1474 // Print to UI |
|
1475 _LIT( Ktlocale, "tlocale" ); |
|
1476 _LIT( Ktest1, "In Test4" ); |
|
1477 TestModuleIf().Printf( 0, Ktlocale, Ktest1 ); |
|
1478 // Print to log file |
|
1479 iLog->Log( Ktest1 ); |
|
1480 |
|
1481 TInt i = 0; |
|
1482 TPtrC string; |
|
1483 _LIT( KParam, "Param[%i]: %S" ); |
|
1484 |
|
1485 Mynumpunct fac; |
|
1486 |
|
1487 basic_string<testChar> str = fac.truename(); |
|
1488 if (strcmp((char*)str.c_str(), "!") != 0) |
|
1489 return KErrGeneral; |
|
1490 |
|
1491 str = fac.falsename(); |
|
1492 if (strcmp((char*)str.c_str(), "!!") != 0) |
|
1493 return KErrGeneral; |
|
1494 |
|
1495 return KErrNone; |
|
1496 |
|
1497 } |
|
1498 |
|
1499 // ----------------------------------------------------------------------------- |
|
1500 // Ctlocale::numpunct_byname_test5L |
|
1501 // ----------------------------------------------------------------------------- |
|
1502 // |
|
1503 |
|
1504 struct Mynumpunct_byname : public numpunct_byname<testChar> { |
|
1505 Mynumpunct_byname(const char *name, size_t refs) |
|
1506 : numpunct_byname<testChar>(name, refs) {} |
|
1507 string_type my_do_truename() const |
|
1508 {return (do_truename()); } |
|
1509 }; |
|
1510 |
|
1511 TInt Ctlocale::numpunct_byname1L( CStifItemParser& aItem ) |
|
1512 { |
|
1513 |
|
1514 // Print to UI |
|
1515 _LIT( Ktlocale, "tlocale" ); |
|
1516 _LIT( Ktest1, "In Test5" ); |
|
1517 TestModuleIf().Printf( 0, Ktlocale, Ktest1 ); |
|
1518 // Print to log file |
|
1519 iLog->Log( Ktest1 ); |
|
1520 |
|
1521 TInt i = 0; |
|
1522 TPtrC string; |
|
1523 _LIT( KParam, "Param[%i]: %S" ); |
|
1524 |
|
1525 const Mynumpunct_byname fac("C", 1); |
|
1526 basic_string<testChar> str = fac.my_do_truename(); |
|
1527 if(strcmp((char*)str.c_str(),"true") !=0) |
|
1528 return KErrGeneral; |
|
1529 |
|
1530 return KErrNone; |
|
1531 |
|
1532 } |
|
1533 #endif |
|
1534 |
|
1535 #if 0 |
|
1536 |
|
1537 // ----------------------------------------------------------------------------- |
|
1538 // Ctlocale::num_get_test6L |
|
1539 // ----------------------------------------------------------------------------- |
|
1540 // |
|
1541 |
|
1542 typedef char_traits<testChar> mycharite; |
|
1543 typedef istreambuf_iterator<testChar, mycharite> myistrite; |
|
1544 |
|
1545 struct Mynum_get : public num_get<testChar, myistrite> { |
|
1546 iter_type my_do_get(iter_type first, iter_type last, ios_base& str, |
|
1547 ios_base::iostate& st, bool& val) const |
|
1548 {return (do_get(first, last, str, st, val)); } |
|
1549 iter_type my_do_get(iter_type first, iter_type last, ios_base& str, |
|
1550 ios_base::iostate& st, long& val) const |
|
1551 {return (do_get(first, last, str, st, val)); } |
|
1552 iter_type my_do_get(iter_type first, iter_type last, ios_base& str, |
|
1553 ios_base::iostate& st, unsigned long& val) const |
|
1554 {return (do_get(first, last, str, st, val)); } |
|
1555 iter_type my_do_get(iter_type first, iter_type last, ios_base& str, |
|
1556 ios_base::iostate& st, double& val) const |
|
1557 {return (do_get(first, last, str, st, val)); } |
|
1558 #ifndef __SYMBIAN32__ |
|
1559 iter_type my_do_get(iter_type first, iter_type last, ios_base& str, |
|
1560 ios_base::iostate& st, long double& val) const |
|
1561 {return (do_get(first, last, str, st, val)); } |
|
1562 #endif |
|
1563 iter_type my_do_get(iter_type first, iter_type last, ios_base& str, |
|
1564 ios_base::iostate& st, unsigned short& val) const // [NOV95] |
|
1565 {return (do_get(first, last, str, st, val)); } |
|
1566 iter_type my_do_get(iter_type first, iter_type last, ios_base& str, |
|
1567 ios_base::iostate& st, unsigned int& val) const |
|
1568 {return (do_get(first, last, str, st, val)); } |
|
1569 iter_type my_do_get(iter_type first, iter_type last, ios_base& str, |
|
1570 ios_base::iostate& st, float& val) const |
|
1571 {return (do_get(first, last, str, st, val)); } |
|
1572 }; |
|
1573 |
|
1574 TInt Ctlocale::num_get1L( CStifItemParser& aItem ) |
|
1575 { |
|
1576 |
|
1577 // Print to UI |
|
1578 _LIT( Ktlocale, "tlocale" ); |
|
1579 _LIT( Ktest1, "In Test6" ); |
|
1580 TestModuleIf().Printf( 0, Ktlocale, Ktest1 ); |
|
1581 // Print to log file |
|
1582 iLog->Log( Ktest1 ); |
|
1583 |
|
1584 TInt i = 0; |
|
1585 TPtrC string; |
|
1586 _LIT( KParam, "Param[%i]: %S" ); |
|
1587 |
|
1588 Mynum_get fac; |
|
1589 basic_string<testChar> str1; |
|
1590 Convert_string2_string_chart(str1,"1V-2W3X4.00Y6A7B-8.C"); |
|
1591 locale loc; |
|
1592 basic_istringstream<testChar> istr(str1); |
|
1593 myistrite first(istr.rdbuf()), last; |
|
1594 bool bv = false; |
|
1595 ios_base::iostate st = ios_base::goodbit; |
|
1596 first = fac.my_do_get(first, last, istr, st, bv); |
|
1597 if (!bv); |
|
1598 return KErrGeneral; |
|
1599 if ((char)*first!= 'V'); |
|
1600 return KErrGeneral; |
|
1601 |
|
1602 |
|
1603 return KErrNone; |
|
1604 |
|
1605 } |
|
1606 |
|
1607 #endif |
|
1608 |
|
1609 // End of File |
|
1610 |