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