os/ossrv/stdcpp/tsrc/BC/apps/tlocale/src/tlocaleblocks.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/stdcpp/tsrc/BC/apps/tlocale/src/tlocaleblocks.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1610 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:       
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +// INCLUDE FILES
    1.24 +#include <e32svr.h>
    1.25 +#include <StifParser.h>
    1.26 +#include <Stiftestinterface.h>
    1.27 +#include<locale>
    1.28 +#include<iostream>
    1.29 +#include<string>
    1.30 +#include <sstream>
    1.31 +#include "tlocale.h"
    1.32 +#define STDCPP_OOM FALSE
    1.33 +#define	testChar	unsigned char
    1.34 +
    1.35 +using namespace std;
    1.36 +// ============================ MEMBER FUNCTIONS ===============================
    1.37 +
    1.38 +// -----------------------------------------------------------------------------
    1.39 +// Ctlocale::Delete
    1.40 +// Delete here all resources allocated and opened from test methods. 
    1.41 +// Called from destructor. 
    1.42 +// -----------------------------------------------------------------------------
    1.43 +//
    1.44 +void Ctlocale::Delete() 
    1.45 +    {
    1.46 +
    1.47 +    }
    1.48 +
    1.49 +
    1.50 +
    1.51 +
    1.52 +// -----------------------------------------------------------------------------
    1.53 +// Ctlocale::RunMethodL
    1.54 +// Run specified method. Contains also table of test mothods and their names.
    1.55 +// -----------------------------------------------------------------------------
    1.56 +//
    1.57 +TInt Ctlocale::RunMethodL( 
    1.58 +    CStifItemParser& aItem ) 
    1.59 +    {
    1.60 +
    1.61 +    static TStifFunctionInfo const KFunctions[] =
    1.62 +        {  
    1.63 +        // Copy this line for every implemented function.
    1.64 +        // First string is the function name used in TestScripter script file.
    1.65 +        // Second is the actual implementation member function. 
    1.66 +					 ENTRY( "hasfacet", Ctlocale::hasfacet ),
    1.67 +					 ENTRY( "usefacet", Ctlocale::usefacet ),
    1.68 +					 ENTRY( "numget", Ctlocale::numget ),
    1.69 +					 ENTRY( "numput", Ctlocale::numput ),
    1.70 +					 ENTRY( "num_punct", Ctlocale::num_punct ),  
    1.71 +					 ENTRY( "numpunctbyname", Ctlocale::numpunctbyname ),
    1.72 +					 ENTRY( "moneyget", Ctlocale::moneyget ),
    1.73 +					 ENTRY( "moneyput", Ctlocale::moneyput ),
    1.74 +					 ENTRY( "money_punct", Ctlocale::money_punct ),  
    1.75 +					 ENTRY( "moneypunctbyname", Ctlocale::moneypunctbyname ),
    1.76 +					 ENTRY( "timeget", Ctlocale::timeget ),
    1.77 +					 ENTRY( "timeput", Ctlocale::timeput ),
    1.78 +					 ENTRY( "messagesL", Ctlocale::messagesL ),
    1.79 +					 ENTRY( "messagesbyname", Ctlocale::messagesbyname ),
    1.80 +					 ENTRY( "collateL", Ctlocale::collateL ),
    1.81 +					 ENTRY( "collatebyname", Ctlocale::collatebyname ),
    1.82 +					 ENTRY( "codecvt1", Ctlocale::codecvt1 ),
    1.83 +					 ENTRY( "codecvt2", Ctlocale::codecvt2 ),
    1.84 +					 ENTRY( "codecvtbyname1", Ctlocale::codecvtbyname1 ),
    1.85 +					 ENTRY( "codecvtbyname2", Ctlocale::codecvtbyname2 ),
    1.86 +				 
    1.87 +					 ENTRY( "ctype_byname1", Ctlocale::ctype_byname1L),
    1.88 +					 ENTRY( "moneypunct_byname1", Ctlocale::moneypunct_byname1L),
    1.89 +					 ENTRY( "moneypunct1", Ctlocale::moneypunct1L),
    1.90 +					 ENTRY( "numpunct1", Ctlocale::numpunct1L),
    1.91 +					 ENTRY( "numpunct_byname1", Ctlocale::numpunct_byname1L),
    1.92 +        };
    1.93 +
    1.94 +    const TInt count = sizeof( KFunctions ) / 
    1.95 +                        sizeof( TStifFunctionInfo );
    1.96 +
    1.97 +    return RunInternalL( KFunctions, count, aItem );
    1.98 +
    1.99 +    }
   1.100 +
   1.101 +
   1.102 +// -----------------------------------------------------------------------------
   1.103 +// Ctlocale::has_facet
   1.104 +// has_facet test method function.
   1.105 +//  
   1.106 +// -----------------------------------------------------------------------------
   1.107 +//
   1.108 +
   1.109 +
   1.110 +TInt Ctlocale::hasfacet( CStifItemParser& aItem )
   1.111 +    {
   1.112 +    int failures=0;
   1.113 +__UHEAP_MARK;
   1.114 +    try
   1.115 +    {
   1.116 +    	
   1.117 +    
   1.118 + bool result = true;
   1.119 + // __UHEAP_MARK;
   1.120 + 
   1.121 +   cout<<"";  
   1.122 + 
   1.123 + #if  STDCPP_OOM
   1.124 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.125 +  #endif 
   1.126 + 
   1.127 + 
   1.128 +  locale loc("en_GB.UTF-8") ;
   1.129 + result = has_facet <ctype<char> > ( loc );
   1.130 + #if  STDCPP_OOM
   1.131 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.132 +  #endif 
   1.133 +
   1.134 +//__UHEAP_MARKEND;
   1.135 +/*
   1.136 + if(result)
   1.137 + return KErrNone;
   1.138 + else
   1.139 + return KErrGeneral;
   1.140 + */
   1.141 + if(!result)
   1.142 + failures++;
   1.143 + 
   1.144 +    }
   1.145 +
   1.146 +
   1.147 + catch(bad_alloc&)
   1.148 +   {
   1.149 +   	//do nothing
   1.150 +    }
   1.151 +   catch(...)
   1.152 +   {
   1.153 +   	failures++;
   1.154 +   	
   1.155 +   }
   1.156 +__UHEAP_MARKEND;   
   1.157 +		  if(failures  )
   1.158 +		  return KErrGeneral;
   1.159 +		  return KErrNone;
   1.160 +    }
   1.161 +
   1.162 +
   1.163 +// -----------------------------------------------------------------------------
   1.164 +// Ctlocale::use_facet
   1.165 +// use_facet test method function.
   1.166 +//  
   1.167 +// -----------------------------------------------------------------------------
   1.168 +//
   1.169 +
   1.170 +
   1.171 +TInt Ctlocale::usefacet( CStifItemParser& aItem )
   1.172 +    {
   1.173 +    int failures=0;
   1.174 +__UHEAP_MARK;
   1.175 +try
   1.176 +{
   1.177 +	
   1.178 +
   1.179 + locale   loc ("en_GB.UTF-8");
   1.180 + cout<<"";
   1.181 + #if  STDCPP_OOM
   1.182 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.183 +  #endif 
   1.184 + bool result = use_facet<ctype<char> > ( loc ).is(ctype_base::alpha, 'b');
   1.185 + #if  STDCPP_OOM
   1.186 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.187 +  #endif 
   1.188 + 
   1.189 +// __UHEAP_MARKEND;
   1.190 +/* if (result)
   1.191 + return KErrNone;
   1.192 + else
   1.193 + return KErrGeneral;
   1.194 +
   1.195 +*/
   1.196 +
   1.197 +if(!result)
   1.198 + failures++;
   1.199 + 
   1.200 + }
   1.201 +
   1.202 + catch(bad_alloc&)
   1.203 +   {
   1.204 +   	//do nothing
   1.205 +    }
   1.206 +   catch(...)
   1.207 +   {
   1.208 +   	failures++;
   1.209 +   	
   1.210 +   }
   1.211 +__UHEAP_MARKEND;
   1.212 +   
   1.213 +		  if(failures  )
   1.214 +		  return KErrGeneral;
   1.215 +		  return KErrNone;
   1.216 +    }
   1.217 +
   1.218 +// -----------------------------------------------------------------------------
   1.219 +// Ctlocale::num_get
   1.220 +// num_get test method function.
   1.221 +//  
   1.222 +// -----------------------------------------------------------------------------
   1.223 +//
   1.224 +
   1.225 +
   1.226 +TInt Ctlocale::numget( CStifItemParser& aItem )
   1.227 +    {
   1.228 +    int failures=0;
   1.229 + __UHEAP_MARK;   
   1.230 +    try
   1.231 +    {
   1.232 +    	
   1.233 +    
   1.234 + typedef istreambuf_iterator<char,char_traits<char> >
   1.235 + iter_type;
   1.236 +
   1.237 +
   1.238 + 
   1.239 + locale loc;
   1.240 + iter_type end;
   1.241 + cout<<"";
   1.242 +#if  STDCPP_OOM
   1.243 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.244 +  #endif 
   1.245 +  const num_get<char,iter_type>& tg = use_facet<num_get<char,iter_type> >(loc);
   1.246 +    
   1.247 + 	#if  STDCPP_OOM
   1.248 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.249 +  #endif 
   1.250 + //return KErrNone;
   1.251 +	
   1.252 +	}
   1.253 +
   1.254 +
   1.255 + catch(bad_alloc&)
   1.256 +   {
   1.257 +   	//do nothing
   1.258 +    }
   1.259 +   catch(...)
   1.260 +   {
   1.261 +   	failures++;
   1.262 +   	
   1.263 +   }
   1.264 + __UHEAP_MARKEND;  
   1.265 +		  if(failures  )
   1.266 +		  return KErrGeneral;
   1.267 +		  return KErrNone;
   1.268 +    }
   1.269 +// -----------------------------------------------------------------------------
   1.270 +// Ctlocale::num_put
   1.271 +// num_put test method function.
   1.272 +//  
   1.273 +// -----------------------------------------------------------------------------
   1.274 +//
   1.275 +TInt Ctlocale::numput( CStifItemParser& aItem )
   1.276 +    {
   1.277 +__UHEAP_MARK;
   1.278 +    int failures=0;
   1.279 +    try
   1.280 +    {
   1.281 +    	
   1.282 +    
   1.283 + typedef ostreambuf_iterator<char,char_traits<char> >
   1.284 + iter_type;
   1.285 +
   1.286 + locale loc;
   1.287 +      
   1.288 +
   1.289 + // Construct a ostreambuf_iterator on cout
   1.290 + iter_type begin(cout);
   1.291 +
   1.292 + // Get a num_put facet reference
   1.293 + cout<<"";
   1.294 + #if  STDCPP_OOM
   1.295 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.296 +  #endif 
   1.297 + const num_put<char,iter_type>& np = use_facet<num_put<char,iter_type> >(loc);
   1.298 +  #if  STDCPP_OOM
   1.299 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.300 +  #endif     
   1.301 +  
   1.302 +//return KErrNone;
   1.303 +
   1.304 + }
   1.305 + 
   1.306 + 
   1.307 +
   1.308 + catch(bad_alloc&)
   1.309 +   {
   1.310 +   	//do nothing
   1.311 +    }
   1.312 +   catch(...)
   1.313 +   {
   1.314 +   	failures++;
   1.315 +   	
   1.316 +   }
   1.317 +__UHEAP_MARKEND;   
   1.318 +		  if(failures  )
   1.319 +		  return KErrGeneral;
   1.320 +		  return KErrNone;
   1.321 +    }
   1.322 +// -----------------------------------------------------------------------------
   1.323 +// Ctlocale::num_punct
   1.324 +// num_punct test method function.
   1.325 +//  
   1.326 +// -----------------------------------------------------------------------------
   1.327 +// 
   1.328 +TInt Ctlocale::num_punct( CStifItemParser& aItem )
   1.329 + {
   1.330 +__UHEAP_MARK;
   1.331 + int failures=0;
   1.332 + try
   1.333 + {
   1.334 + 	
   1.335 + 
   1.336 + locale loc;
   1.337 +cout<<"";
   1.338 +#if  STDCPP_OOM
   1.339 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.340 +  #endif 
   1.341 + const numpunct <char> &npunct = use_facet <numpunct <char> >( loc);
   1.342 +   // const numpunct <unsigned> &n1punct = use_facet <numpunct <unsigned> >( loc);
   1.343 +#if  STDCPP_OOM
   1.344 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.345 +  #endif 
   1.346 +/*   
   1.347 + if(npunct.truename() ==  "true")
   1.348 + if(npunct.falsename()=="false")  
   1.349 + if(npunct.decimal_point() =='.')
   1.350 + if(npunct.thousands_sep() ==',')
   1.351 +   
   1.352 +    
   1.353 +  
   1.354 + return KErrNone;
   1.355 + else
   1.356 + return KErrGeneral;*/
   1.357 +  if(npunct.truename() !=  "true")
   1.358 +  failures++;
   1.359 + if(npunct.falsename()!="false")  
   1.360 + failures++;
   1.361 + if(npunct.decimal_point() !='.')
   1.362 + failures++;
   1.363 + if(npunct.thousands_sep() !=',')
   1.364 + failures++;
   1.365 +
   1.366 + }
   1.367 +
   1.368 +
   1.369 + catch(bad_alloc&)
   1.370 +   {
   1.371 +   	//do nothing
   1.372 +    }
   1.373 +   catch(...)
   1.374 +   {
   1.375 +   	failures++;
   1.376 +   	
   1.377 +   }
   1.378 +__UHEAP_MARKEND;   
   1.379 +		  if(failures  )
   1.380 +		  return KErrGeneral;
   1.381 +		  return KErrNone;
   1.382 +    }
   1.383 +// -----------------------------------------------------------------------------
   1.384 +// Ctlocale::numpunct_byname
   1.385 +// numpunct_byname test method function.
   1.386 +//  
   1.387 +// -----------------------------------------------------------------------------
   1.388 +//
   1.389 +TInt Ctlocale::numpunctbyname( CStifItemParser& aItem )
   1.390 +    {
   1.391 +    int failures=0;
   1.392 +__UHEAP_MARK;    
   1.393 +    try
   1.394 +    {
   1.395 +    	
   1.396 +    
   1.397 + locale loc;
   1.398 +cout<<"";
   1.399 +#if  STDCPP_OOM
   1.400 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.401 +  #endif 
   1.402 + const numpunct_byname <char> &npunct = use_facet <numpunct_byname <char> >( loc);
   1.403 +   #if  STDCPP_OOM
   1.404 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.405 +  #endif 
   1.406 +    
   1.407 + /*if(npunct.truename() ==  "true")
   1.408 + if(npunct.falsename()=="false") 
   1.409 + if(npunct.decimal_point( ) =='.')
   1.410 + if(npunct.thousands_sep( ) ==',')
   1.411 +   
   1.412 + 
   1.413 +  
   1.414 +return KErrNone;
   1.415 +else
   1.416 +return KErrGeneral;*/
   1.417 +
   1.418 +if(npunct.truename() !=  "true")
   1.419 +failures++;
   1.420 + if(npunct.falsename()!="false") 
   1.421 + failures++;
   1.422 + if(npunct.decimal_point( ) !='.')
   1.423 + failures++;
   1.424 + if(npunct.thousands_sep( ) !=',')
   1.425 + failures++;
   1.426 +   
   1.427 + }
   1.428 +
   1.429 + catch(bad_alloc&)
   1.430 +   {
   1.431 +   	//do nothing
   1.432 +    }
   1.433 +   catch(...)
   1.434 +   {
   1.435 +   	failures++;
   1.436 +   	
   1.437 +   }
   1.438 + __UHEAP_MARKEND;  
   1.439 +		  if(failures  )
   1.440 +		  return KErrGeneral;
   1.441 +		  return KErrNone;
   1.442 +    }
   1.443 +
   1.444 +// -----------------------------------------------------------------------------
   1.445 +// Ctlocale::money_get
   1.446 +// money_get test method function.
   1.447 +//  
   1.448 +// -----------------------------------------------------------------------------
   1.449 +//
   1.450 +
   1.451 +TInt Ctlocale::moneyget( CStifItemParser& aItem )
   1.452 +    {
   1.453 +    int failures=0;
   1.454 + __UHEAP_MARK;   
   1.455 +    try
   1.456 +    {
   1.457 +    	
   1.458 +    
   1.459 + typedef istreambuf_iterator<char,char_traits<char> >
   1.460 + iter_type;
   1.461 +
   1.462 + locale loc;
   1.463 + string buffer("$100.02");
   1.464 + string dest;
   1.465 + long double ldest;
   1.466 + ios_base::iostate state;
   1.467 + iter_type end;
   1.468 + cout<<"";
   1.469 +#if  STDCPP_OOM
   1.470 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.471 +  #endif 
   1.472 + // Get a money_get facet
   1.473 + const money_get<char,iter_type>& mgf =  use_facet<money_get<char,iter_type> >(loc);
   1.474 +     
   1.475 +#if  STDCPP_OOM
   1.476 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.477 +  #endif 
   1.478 +	
   1.479 +// return KErrNone;
   1.480 +	
   1.481 +	}
   1.482 +
   1.483 +
   1.484 + catch(bad_alloc&)
   1.485 +   {
   1.486 +   	//do nothing
   1.487 +    }
   1.488 +   catch(...)
   1.489 +   {
   1.490 +   	failures++;
   1.491 +   	
   1.492 +   }
   1.493 + __UHEAP_MARKEND;  
   1.494 +		  if(failures  )
   1.495 +		  return KErrGeneral;
   1.496 +		  return KErrNone;
   1.497 +    }
   1.498 +// -----------------------------------------------------------------------------
   1.499 +// Ctlocale::money_put
   1.500 +// money_put test method function.
   1.501 +//  
   1.502 +// -----------------------------------------------------------------------------
   1.503 +//
   1.504 +TInt Ctlocale::moneyput( CStifItemParser& aItem )
   1.505 +    {
   1.506 +    int failures=0;
   1.507 +    
   1.508 +    try
   1.509 +    {
   1.510 +    	
   1.511 +    
   1.512 + typedef ostreambuf_iterator<char,char_traits<char> >
   1.513 + iter_type;
   1.514 +
   1.515 + locale loc;
   1.516 + string buffer("10002");
   1.517 + long double ldval = 10002;
   1.518 +
   1.519 +  iter_type begin(cout);
   1.520 +  cout<<"";
   1.521 +#if  STDCPP_OOM
   1.522 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.523 +  #endif 
   1.524 +  const money_put<char,iter_type>& mp =   use_facet<money_put<char,iter_type> >(loc);
   1.525 +
   1.526 +    #if  STDCPP_OOM
   1.527 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.528 +  #endif  
   1.529 +
   1.530 +  
   1.531 +//return KErrNone;
   1.532 +
   1.533 + }
   1.534 + 
   1.535 + 
   1.536 + catch(bad_alloc&)
   1.537 +   {
   1.538 +   	//do nothing
   1.539 +    }
   1.540 +   catch(...)
   1.541 +   {
   1.542 +   	failures++;
   1.543 +   	
   1.544 +   }
   1.545 + __UHEAP_MARKEND;  
   1.546 +		  if(failures  )
   1.547 +		  return KErrGeneral;
   1.548 +		  return KErrNone;
   1.549 +    }
   1.550 +
   1.551 +// -----------------------------------------------------------------------------
   1.552 +// Ctlocale::moneypunct
   1.553 +// moneypunct test method function.
   1.554 +//  
   1.555 +// -----------------------------------------------------------------------------
   1.556 +//
   1.557 +TInt Ctlocale::money_punct( CStifItemParser& aItem )
   1.558 +    {
   1.559 +     
   1.560 +     int failures=0;
   1.561 +     try
   1.562 +     {
   1.563 +     	
   1.564 +     
   1.565 + 
   1.566 + locale loc;
   1.567 + cout<<"";
   1.568 +#if  STDCPP_OOM
   1.569 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.570 +  #endif 
   1.571 +  const moneypunct<char,false>& mp =
   1.572 + use_facet<moneypunct<char,false> >(loc);
   1.573 +   #if  STDCPP_OOM
   1.574 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.575 +  #endif    
   1.576 + mp.curr_symbol();
   1.577 + mp.negative_sign();
   1.578 +
   1.579 +/* if(mp.decimal_point() == '.')
   1.580 + if(mp.thousands_sep() == ',')
   1.581 + if( mp.frac_digits() == 0)
   1.582 + 
   1.583 +
   1.584 +    
   1.585 +  
   1.586 +return KErrNone;
   1.587 +else
   1.588 +return KErrGeneral;*/
   1.589 +
   1.590 +if(mp.decimal_point() != '.')
   1.591 +failures++;
   1.592 + if(mp.thousands_sep() != ',')
   1.593 + failures++;
   1.594 + if( mp.frac_digits() != 0)
   1.595 + failures++;
   1.596 +
   1.597 +
   1.598 + }
   1.599 + 
   1.600 + 
   1.601 + 
   1.602 + catch(bad_alloc&)
   1.603 +   {
   1.604 +   	//do nothing
   1.605 +    }
   1.606 +   catch(...)
   1.607 +   {
   1.608 +   	failures++;
   1.609 +   	
   1.610 +   }
   1.611 +   
   1.612 +		  if(failures  )
   1.613 +		  return KErrGeneral;
   1.614 +		  return KErrNone;
   1.615 +    }
   1.616 +
   1.617 +// -----------------------------------------------------------------------------
   1.618 +// Ctlocale::moneypunct_byname
   1.619 +// moneypunct_byname test method function.
   1.620 +//  
   1.621 +// -----------------------------------------------------------------------------
   1.622 +// 
   1.623 + 
   1.624 +TInt Ctlocale::moneypunctbyname( CStifItemParser& aItem )
   1.625 +    {
   1.626 +    
   1.627 +    int failures=0;
   1.628 +    try
   1.629 +    {
   1.630 +    	
   1.631 +    
   1.632 +                 
   1.633 + locale loc;
   1.634 +  
   1.635 + cout<<"";
   1.636 + #if  STDCPP_OOM
   1.637 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.638 +  #endif 
   1.639 +  const moneypunct_byname<char,false>& mp = 
   1.640 +     
   1.641 + use_facet<moneypunct_byname<char,false> >(loc);
   1.642 +   
   1.643 +   
   1.644 +   #if  STDCPP_OOM
   1.645 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.646 +  #endif 
   1.647 +   
   1.648 + mp.curr_symbol();
   1.649 + mp.negative_sign();
   1.650 + if(mp.decimal_point() != '.')
   1.651 + failures++;
   1.652 + if(mp.thousands_sep() != ',')
   1.653 + failures++;
   1.654 + if( mp.frac_digits() != 0)
   1.655 + failures++;
   1.656 + 
   1.657 +
   1.658 +    
   1.659 +  
   1.660 +
   1.661 + }
   1.662 +
   1.663 + catch(bad_alloc&)
   1.664 +   {
   1.665 +   	//do nothing
   1.666 +    }
   1.667 +   catch(...)
   1.668 +   {
   1.669 +   	failures++;
   1.670 +   	
   1.671 +   }
   1.672 +   
   1.673 +		  if(failures  )
   1.674 +		  return KErrGeneral;
   1.675 +		  return KErrNone;
   1.676 +    }
   1.677 +
   1.678 +// -----------------------------------------------------------------------------
   1.679 +// Ctlocale::time_get
   1.680 +// time_get  test method function.
   1.681 +//  
   1.682 +// -----------------------------------------------------------------------------
   1.683 +// 
   1.684 +
   1.685 +
   1.686 +TInt Ctlocale::timeget( CStifItemParser& aItem )
   1.687 +    {
   1.688 +    int failures=0;
   1.689 +    
   1.690 +    try
   1.691 +    {
   1.692 +    	
   1.693 +    
   1.694 +  typedef std::istreambuf_iterator<char,
   1.695 +  std::char_traits<char> > Iter;
   1.696 +  static struct tm timeb;  
   1.697 +  std::ios_base::iostate state;
   1.698 +cout<<"";
   1.699 +    #if  STDCPP_OOM
   1.700 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.701 +  #endif 
   1.702 + const std::time_get<char, Iter> &tg =
   1.703 + std::use_facet<std::time_get<char, Iter> >(std::locale ("C"));
   1.704 + #if  STDCPP_OOM
   1.705 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.706 +  #endif 
   1.707 + //return KErrNone;
   1.708 +	
   1.709 +	}
   1.710 +	
   1.711 +	
   1.712 + catch(bad_alloc&)
   1.713 +   {
   1.714 +   	//do nothing
   1.715 +    }
   1.716 +   catch(...)
   1.717 +   {
   1.718 +   	failures++;
   1.719 +   	
   1.720 +   }
   1.721 +   
   1.722 +		  if(failures  )
   1.723 +		  return KErrGeneral;
   1.724 +		  return KErrNone;
   1.725 +    }
   1.726 +
   1.727 +// -----------------------------------------------------------------------------
   1.728 +// Ctlocale::time_put
   1.729 +// time_put  test method function.
   1.730 +//  
   1.731 +// -----------------------------------------------------------------------------
   1.732 +// 
   1.733 +TInt Ctlocale::timeput( CStifItemParser& aItem )
   1.734 +    { 
   1.735 +    
   1.736 +    int failures=0; 
   1.737 +    try
   1.738 +    {
   1.739 +    	
   1.740 +   
   1.741 +    std::tm t = std::tm ();
   1.742 +   
   1.743 +    t.tm_sec   = 56;    
   1.744 +    t.tm_min   = 34;    
   1.745 +    t.tm_hour  = 14;    
   1.746 +    t.tm_mday  = 29;   
   1.747 +    t.tm_mon   =  1;    
   1.748 +    t.tm_year  = 84;    
   1.749 +                       
   1.750 +    t.tm_yday  = 59;    
   1.751 +    t.tm_wday  =  3;   
   1.752 +    t.tm_isdst =  0;   
   1.753 +
   1.754 +    const char* const fmt[] = {
   1.755 +      "%a", "%A", "%b", "%B", "%c", "%C", "%d", "%D",
   1.756 +      "%e", "%F", "%g", "%G", "%h", "%H", "%I", "%j",
   1.757 +      "%k", "%l", "%m", "%M", "%n", "%p", "%r", "%R",
   1.758 +      "%S", "%t", "%T", "%u", "%U", "%V", "%w", "%W", "%x",
   1.759 +      "%X", "%y", "%Y", "%z", "%Z", "%%", "%Ec", "%EC", "%Ex",
   1.760 +      "%EX", "%Ey", "%EY", "%Od", "%Oe", "%OH", "%OI", "%Om",
   1.761 +      "%OM", "%OS", "%Ou", "%OU", "%OV", "%Ow", "%OW", "%Oy"         
   1.762 +    };
   1.763 +    cout<<"";
   1.764 +#if  STDCPP_OOM
   1.765 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.766 +  #endif 
   1.767 +     const std::time_put<char> &tput =
   1.768 +        std::use_facet<std::time_put<char> >(std::cout.getloc ());
   1.769 +
   1.770 +#if  STDCPP_OOM
   1.771 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.772 +  #endif 
   1.773 +  
   1.774 +//return KErrNone;
   1.775 +
   1.776 + }
   1.777 + 
   1.778 + 
   1.779 + catch(bad_alloc&)
   1.780 +   {
   1.781 +   	//do nothing
   1.782 +    }
   1.783 +   catch(...)
   1.784 +   {
   1.785 +   	failures++;
   1.786 +   	
   1.787 +   }
   1.788 +   
   1.789 +		  if(failures  )
   1.790 +		  return KErrGeneral;
   1.791 +		  return KErrNone;
   1.792 +    }
   1.793 + 
   1.794 +// -----------------------------------------------------------------------------
   1.795 +// Ctlocale::messages
   1.796 +// messages  test method function.
   1.797 +//  
   1.798 +// -----------------------------------------------------------------------------
   1.799 +// 
   1.800 + 
   1.801 +TInt Ctlocale::messagesL( CStifItemParser& aItem )
   1.802 +{
   1.803 +int failures=0;
   1.804 +
   1.805 +try
   1.806 +{
   1.807 +	
   1.808 + 
   1.809 +      locale loc;
   1.810 +      cout<<"";
   1.811 +#if  STDCPP_OOM
   1.812 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.813 +  #endif 
   1.814 +       const messages<char>& mess =use_facet<messages<char> >(loc);
   1.815 +#if  STDCPP_OOM
   1.816 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.817 +  #endif 
   1.818 +  // no support to .cat files
   1.819 +
   1.820 +      /*  
   1.821 +      string def("Message Not Found");
   1.822 +      messages<char>::catalog cat =
   1.823 +              mess.open("./rwstdmessages.cat",loc);
   1.824 +      if (cat != -1)
   1.825 +       {
   1.826 +        string msg0 = mess.get(cat,1,1,def);
   1.827 +        string msg1 = mess.get(cat,1,2,def);
   1.828 +        string msg2 = mess.get(cat,1,6,def); // invalid msg #
   1.829 +        string msg3 = mess.get(cat,2,1,def);
   1.830 +
   1.831 +        mess.close(cat);
   1.832 +        cout << msg0 << endl << msg1 << endl
   1.833 +              << msg2 << endl << msg3 << endl;
   1.834 +       }
   1.835 +      else
   1.836 +        cout << "Unable to open message catalog" << endl;*/
   1.837 +
   1.838 +      //return KErrNone;
   1.839 +	
   1.840 +}
   1.841 +
   1.842 +
   1.843 +
   1.844 + catch(bad_alloc&)
   1.845 +   {
   1.846 +   	//do nothing
   1.847 +    }
   1.848 +   catch(...)
   1.849 +   {
   1.850 +   	failures++;
   1.851 +   	
   1.852 +   }
   1.853 +   
   1.854 +		  if(failures  )
   1.855 +		  return KErrGeneral;
   1.856 +		  return KErrNone;
   1.857 +    }
   1.858 +
   1.859 +// -----------------------------------------------------------------------------
   1.860 +// Ctlocale::messages_byname
   1.861 +// messages_byname  test method function.
   1.862 +//  
   1.863 +// -----------------------------------------------------------------------------
   1.864 +// 
   1.865 +TInt Ctlocale::messagesbyname( CStifItemParser& aItem )
   1.866 +{
   1.867 +int failures=0;
   1.868 +
   1.869 +try
   1.870 +{
   1.871 +	
   1.872 + 
   1.873 + locale loc;
   1.874 + cout<<"";
   1.875 +#if  STDCPP_OOM
   1.876 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.877 +  #endif 
   1.878 + const messages_byname<char>& mess =
   1.879 +      
   1.880 +        use_facet<messages_byname<char> >(loc);
   1.881 +#if  STDCPP_OOM
   1.882 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.883 +  #endif 
   1.884 +    
   1.885 +// no support to .cat files
   1.886 +    /*    
   1.887 +      string def("Message Not Found");
   1.888 +      messages_byname<char>::catalog cat =
   1.889 +              mess.open("./rwstdmessages.cat",loc);
   1.890 +      if (cat != -1)
   1.891 +       {
   1.892 +        string msg0 = mess.get(cat,1,1,def);
   1.893 +        string msg1 = mess.get(cat,1,2,def);
   1.894 +        string msg2 = mess.get(cat,1,6,def); // invalid msg #
   1.895 +        string msg3 = mess.get(cat,2,1,def);
   1.896 +
   1.897 +        mess.close(cat);
   1.898 +        cout << msg0 << endl << msg1 << endl
   1.899 +              << msg2 << endl << msg3 << endl;
   1.900 +       }
   1.901 +      else
   1.902 +        cout << "Unable to open message catalog" << endl;*/
   1.903 +
   1.904 +      //return KErrNone;	
   1.905 +}
   1.906 +
   1.907 +
   1.908 + catch(bad_alloc&)
   1.909 +   {
   1.910 +   	//do nothing
   1.911 +    }
   1.912 +   catch(...)
   1.913 +   {
   1.914 +   	failures++;
   1.915 +   	
   1.916 +   }
   1.917 +   
   1.918 +		  if(failures  )
   1.919 +		  return KErrGeneral;
   1.920 +		  return KErrNone;
   1.921 +    }
   1.922 +
   1.923 +// -----------------------------------------------------------------------------
   1.924 +// Ctlocale::collate
   1.925 +// collate  test method function.
   1.926 +//  
   1.927 +// -----------------------------------------------------------------------------
   1.928 +// 
   1.929 +TInt Ctlocale::collateL( CStifItemParser& aItem )
   1.930 +{
   1.931 + int failures =0;
   1.932 + try
   1.933 + {
   1.934 + 	
   1.935 + 
   1.936 + locale loc;
   1.937 + string s1("blue");
   1.938 + string s2("blues");
   1.939 + cout<<"";
   1.940 + #if  STDCPP_OOM
   1.941 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.942 +  #endif 
   1.943 + const collate<char>& co =
   1.944 + use_facet<collate<char> >(loc);
   1.945 +    
   1.946 + if( co.compare(s1.begin(),s1.end(),s2.begin(),s2.end()-1) != 0)
   1.947 + failures++;
   1.948 +                         
   1.949 + if( co.compare(s1.begin(),s1.end(), s2.begin(),s2.end()) != -1)
   1.950 + failures++;
   1.951 +                         
   1.952 + // Retrieve hash values for two strings
   1.953 + if( co.hash(s1.begin(),s1.end())!= 15636)
   1.954 + failures++;
   1.955 +   #if  STDCPP_OOM
   1.956 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.957 +  #endif    
   1.958 +  
   1.959 +      
   1.960 +      
   1.961 +       
   1.962 +	
   1.963 +}
   1.964 +
   1.965 + catch(bad_alloc&)
   1.966 +   {
   1.967 +   	//do nothing
   1.968 +    }
   1.969 +   catch(...)
   1.970 +   {
   1.971 +   	failures++;
   1.972 +   	
   1.973 +   }
   1.974 +   
   1.975 +		  if(failures  )
   1.976 +		  return KErrGeneral;
   1.977 +		  return KErrNone;
   1.978 +    }
   1.979 +// -----------------------------------------------------------------------------
   1.980 +// Ctlocale::collatebyname
   1.981 +// collatebyname  test method function.
   1.982 +//  
   1.983 +// -----------------------------------------------------------------------------
   1.984 +// 
   1.985 +TInt Ctlocale::collatebyname( CStifItemParser& aItem )
   1.986 +{
   1.987 + int failures =0;
   1.988 + try
   1.989 + {
   1.990 + 	
   1.991 + 
   1.992 + locale loc;
   1.993 + string s1("blue");
   1.994 + string s2("blues");
   1.995 + cout<<"";
   1.996 + #if  STDCPP_OOM
   1.997 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.998 +  #endif 
   1.999 + const collate_byname<char>& co = use_facet<collate_byname<char> >(loc);
  1.1000 +     
  1.1001 + if( co.compare(s1.begin(),s1.end(),s2.begin(),s2.end()-1) != 0)
  1.1002 + failures++;
  1.1003 +                         
  1.1004 + if( co.compare(s1.begin(),s1.end(),  s2.begin(),s2.end()) != -1)
  1.1005 + failures++;
  1.1006 +                         
  1.1007 + // Retrieve hash values for two strings
  1.1008 + if( co.hash(s1.begin(),s1.end())!= 15636)
  1.1009 + failures++;
  1.1010 +   #if  STDCPP_OOM
  1.1011 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1012 +  #endif    
  1.1013 +  
  1.1014 +      
  1.1015 +      
  1.1016 +       
  1.1017 +	
  1.1018 +}
  1.1019 +
  1.1020 +
  1.1021 + catch(bad_alloc&)
  1.1022 +   {
  1.1023 +   	//do nothing
  1.1024 +    }
  1.1025 +   catch(...)
  1.1026 +   {
  1.1027 +   	failures++;
  1.1028 +   	
  1.1029 +   }
  1.1030 +   
  1.1031 +		  if(failures  )
  1.1032 +		  return KErrGeneral;
  1.1033 +		  return KErrNone;
  1.1034 +    }
  1.1035 +
  1.1036 +
  1.1037 +
  1.1038 +// -----------------------------------------------------------------------------
  1.1039 +// Ctlocale::codecvt1
  1.1040 +// codecvt1  test method function.
  1.1041 +//  
  1.1042 +// -----------------------------------------------------------------------------
  1.1043 +// 
  1.1044 +
  1.1045 +TInt Ctlocale::codecvt1( CStifItemParser& aItem )
  1.1046 +{
  1.1047 + __UHEAP_MARK;   
  1.1048 +
  1.1049 +	locale loc ( "de_DE.ISO-8859-1" );
  1.1050 +	int failures=0;
  1.1051 +	try
  1.1052 +	{
  1.1053 +	cout<<"";	
  1.1054 +	#if  STDCPP_OOM
  1.1055 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1056 +  #endif 
  1.1057 +    int result = use_facet<codecvt<char, char, mbstate_t> > ( loc ).encoding ();
  1.1058 +    if(result != 1)
  1.1059 +    failures++;
  1.1060 +   
  1.1061 +     
  1.1062 +  
  1.1063 +  
  1.1064 +    char* str = "This is the string whose length is to be measured!";
  1.1065 +    mbstate_t state = {0};
  1.1066 +    locale loc1("C");//English_Britain");//German_Germany
  1.1067 +   //int res = use_facet<codecvt<wchar_t, char, mbstate_t>>( loc ).length( state,str, &str[strlen(str)], 90 );
  1.1068 +
  1.1069 +  
  1.1070 +    int res = use_facet<codecvt<wchar_t, char, mbstate_t> >
  1.1071 +     ( loc1 ).length( state,str, &str[strlen(str)], 90 );
  1.1072 +
  1.1073 +  
  1.1074 +  
  1.1075 +    if(res!=50)
  1.1076 +    failures++;
  1.1077 +  
  1.1078 +  
  1.1079 + 
  1.1080 +     locale loc2( "C");//English_Britain" );//German_Germany
  1.1081 +     int res2 = use_facet<codecvt<char, char, mbstate_t> >
  1.1082 +     ( loc ).max_length( );
  1.1083 +     if(res2!=1)
  1.1084 +     failures++;
  1.1085 +
  1.1086 +  
  1.1087 +   #if  STDCPP_OOM
  1.1088 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1089 +  #endif 
  1.1090 +    
  1.1091 +}
  1.1092 +
  1.1093 +
  1.1094 + catch(bad_alloc&)
  1.1095 +   {
  1.1096 +   	//do nothing
  1.1097 +    }
  1.1098 +   catch(...)
  1.1099 +   {
  1.1100 +   	failures++;
  1.1101 +   	
  1.1102 +   }
  1.1103 +  __UHEAP_MARKEND;  
  1.1104 +  
  1.1105 +		  if(failures  )
  1.1106 +		  return KErrGeneral;
  1.1107 +		  return KErrNone;
  1.1108 +    }
  1.1109 +
  1.1110 +// -----------------------------------------------------------------------------
  1.1111 +// Ctlocale::codecvt2
  1.1112 +// codecvt2 test method function.
  1.1113 +//  
  1.1114 +// -----------------------------------------------------------------------------
  1.1115 +// 
  1.1116 +TInt Ctlocale::codecvt2( CStifItemParser& aItem )
  1.1117 +{
  1.1118 +int failures=0;
  1.1119 +try
  1.1120 +{
  1.1121 +	
  1.1122 + 
  1.1123 + char strout[91];
  1.1124 + wchar_t *strin = L"This is the wchar_t string to be converted.";
  1.1125 + memset( &strout[0], 0, ( sizeof( char ) )*( 91 ) );
  1.1126 + char* strnext;
  1.1127 + const wchar_t* pwszNext;
  1.1128 + mbstate_t state;
  1.1129 + locale loc("C"); 
  1.1130 + cout<<"";
  1.1131 + #if  STDCPP_OOM
  1.1132 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1133 +  #endif 
  1.1134 + int res = use_facet<codecvt<wchar_t, char, mbstate_t> >
  1.1135 +      ( loc ).out( state,strin, &strin[wcslen( strin )], pwszNext ,
  1.1136 + strout, &strout[wcslen( strin )], strnext );
  1.1137 + #if  STDCPP_OOM
  1.1138 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1139 +  #endif 
  1.1140 + strout[wcslen( strin )] = 0;
  1.1141 +    
  1.1142 +  string str = "This is the wchar_t string to be converted.";
  1.1143 + 
  1.1144 +/*if(str.compare(&strout[0]) == 0)
  1.1145 +return KErrNone;
  1.1146 +else
  1.1147 +return KErrGeneral;
  1.1148 +
  1.1149 +*/
  1.1150 +
  1.1151 +if(str.compare(&strout[0]) != 0)
  1.1152 +failures++;
  1.1153 +
  1.1154 +}
  1.1155 +
  1.1156 +
  1.1157 +
  1.1158 +
  1.1159 + catch(bad_alloc&)
  1.1160 +   {
  1.1161 +   	//do nothing
  1.1162 +    }
  1.1163 +   catch(...)
  1.1164 +   {
  1.1165 +   	failures++;
  1.1166 +   	
  1.1167 +   }
  1.1168 +   
  1.1169 +		  if(failures  )
  1.1170 +		  return KErrGeneral;
  1.1171 +		  return KErrNone;
  1.1172 +    }
  1.1173 +
  1.1174 +
  1.1175 +// -----------------------------------------------------------------------------
  1.1176 +// Ctlocale::codecvtbyname1
  1.1177 +// codecvtbyname1 test method function.
  1.1178 +//  
  1.1179 +// -----------------------------------------------------------------------------
  1.1180 +// 
  1.1181 +
  1.1182 +TInt Ctlocale::codecvtbyname1( CStifItemParser& aItem )
  1.1183 +{
  1.1184 + __UHEAP_MARK;   
  1.1185 +
  1.1186 + locale loc ( "de_DE.ISO-8859-1" );
  1.1187 + int failures=0;
  1.1188 + try
  1.1189 + {
  1.1190 + cout<<"";	
  1.1191 + #if  STDCPP_OOM
  1.1192 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1193 +  #endif 
  1.1194 + int result = use_facet<codecvt_byname<char, char, mbstate_t> > ( loc ).encoding ();
  1.1195 + #if  STDCPP_OOM
  1.1196 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1197 +  #endif 
  1.1198 + if(result != 1)
  1.1199 + failures++;
  1.1200 + 
  1.1201 +  
  1.1202 + char* str = "This is the string whose length is to be measured!";
  1.1203 + mbstate_t state = {0};
  1.1204 + locale loc1("C"); 
  1.1205 + 
  1.1206 +  #if  STDCPP_OOM
  1.1207 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1208 +  #endif 
  1.1209 +  int res = use_facet<codecvt_byname<wchar_t, char, mbstate_t> >
  1.1210 +     ( loc1 ).length( state,str, &str[strlen(str)], 90 );
  1.1211 +
  1.1212 +  #if  STDCPP_OOM
  1.1213 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1214 +  #endif 
  1.1215 +  
  1.1216 +  if(res!=50)
  1.1217 +  failures++;
  1.1218 +  
  1.1219 +   
  1.1220 +  
  1.1221 + locale loc2( "C"); 
  1.1222 + #if  STDCPP_OOM
  1.1223 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1224 +  #endif 
  1.1225 + int res2 = use_facet<codecvt_byname<char, char, mbstate_t> >( loc ).max_length( );
  1.1226 + #if  STDCPP_OOM
  1.1227 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1228 +  #endif 
  1.1229 + if(res2!=1)
  1.1230 + failures++;
  1.1231 + 
  1.1232 +  
  1.1233 +}
  1.1234 +
  1.1235 +
  1.1236 + catch(bad_alloc&)
  1.1237 +   {
  1.1238 +   	//do nothing
  1.1239 +    }
  1.1240 +   catch(...)
  1.1241 +   {
  1.1242 +   	failures++;
  1.1243 +   	
  1.1244 +   }
  1.1245 + __UHEAP_MARKEND;  
  1.1246 +   
  1.1247 +		  if(failures  )
  1.1248 +		  return KErrGeneral;
  1.1249 +		  return KErrNone;
  1.1250 +    }
  1.1251 +
  1.1252 +
  1.1253 +// -----------------------------------------------------------------------------
  1.1254 +// Ctlocale::codecvtbyname2
  1.1255 +// codecvtbyname2 test method function.
  1.1256 +//  
  1.1257 +// -----------------------------------------------------------------------------
  1.1258 +// 
  1.1259 +TInt Ctlocale::codecvtbyname2( CStifItemParser& aItem )
  1.1260 +{
  1.1261 +int failures=0;
  1.1262 +try
  1.1263 +{
  1.1264 +	
  1.1265 +
  1.1266 + char* strout = "This is the string to be converted!";
  1.1267 + wchar_t strin [91];
  1.1268 + memset(&strin[0], 0, (sizeof(wchar_t))*(91));
  1.1269 + const char* pszNext;
  1.1270 + wchar_t* pwszNext;
  1.1271 + mbstate_t state = {0};
  1.1272 + locale loc("C"); 
  1.1273 + cout<<"";
  1.1274 + #if  STDCPP_OOM
  1.1275 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1276 +  #endif 
  1.1277 + int res = use_facet<codecvt<wchar_t, char, mbstate_t> >
  1.1278 +     ( loc ).in( state, strout, &strout[strlen(strout)], pszNext,
  1.1279 +          strin, &strin[strlen(strout)], pwszNext );
  1.1280 +      #if  STDCPP_OOM
  1.1281 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1282 +  #endif     
  1.1283 + strin[strlen(strout)] = 0;
  1.1284 + 
  1.1285 + wstring str = L"This is the string to be converted!";
  1.1286 +
  1.1287 +/*
  1.1288 +if(str.compare(&strin[0]) == 0)
  1.1289 +return KErrNone;
  1.1290 +else
  1.1291 +return KErrGeneral;
  1.1292 +
  1.1293 +   */
  1.1294 + if(str.compare(&strin[0]) != 0)
  1.1295 + failures++;
  1.1296 +  
  1.1297 +    
  1.1298 +}
  1.1299 +
  1.1300 +
  1.1301 + catch(bad_alloc&)
  1.1302 +   {
  1.1303 +   	//do nothing
  1.1304 +    }
  1.1305 +   catch(...)
  1.1306 +   {
  1.1307 +   	failures++;
  1.1308 +   	
  1.1309 +   }
  1.1310 +   
  1.1311 +		  if(failures  )
  1.1312 +		  return KErrGeneral;
  1.1313 +		  return KErrNone;
  1.1314 +    }
  1.1315 +    
  1.1316 +    
  1.1317 +    
  1.1318 +// helper API
  1.1319 +template<class _CharT>
  1.1320 +void Convert_string2_string_chart(basic_string<_CharT> &dst, string src)
  1.1321 +	{
  1.1322 +		int length = src.length();
  1.1323 +		const char* str = src.c_str();
  1.1324 +		for(int i = 0; i<length;i++)
  1.1325 +		{
  1.1326 +			dst.append(1, (_CharT)*str++);
  1.1327 +			
  1.1328 +		}
  1.1329 +			
  1.1330 +	}
  1.1331 +    
  1.1332 + #if 1   
  1.1333 +
  1.1334 +// -----------------------------------------------------------------------------
  1.1335 +// Ctlocale::ctype_byname_test1L
  1.1336 +// -----------------------------------------------------------------------------
  1.1337 +//
  1.1338 +struct MyCtype_bybname : public ctype_byname<testChar> {
  1.1339 +	MyCtype_bybname(const char *name, size_t refs)
  1.1340 +		: ctype_byname<testChar>(name, refs) {}
  1.1341 +	testChar my_do_toupper(testChar ch) const
  1.1342 +		{return (this->do_toupper(ch)); }
  1.1343 +	const testChar *my_do_toupper(testChar *first,
  1.1344 +		const testChar *last) const
  1.1345 +		{return (this->do_toupper(first, last)); }
  1.1346 +	testChar my_do_tolower(testChar ch) const
  1.1347 +		{return (this->do_tolower(ch)); }
  1.1348 +	const testChar *my_do_tolower(testChar *first,
  1.1349 +		const testChar *last) const
  1.1350 +		{return (this->do_tolower(first, last)); }
  1.1351 +	};
  1.1352 +// -----------------------------------------------------------------------------
  1.1353 +// Ctlocale::ExampleL
  1.1354 +// Example test method function.
  1.1355 +// (other items were commented in a header).
  1.1356 +// -----------------------------------------------------------------------------
  1.1357 +//
  1.1358 +	
  1.1359 +TInt Ctlocale::ctype_byname1L( CStifItemParser& aItem )
  1.1360 +    {
  1.1361 +
  1.1362 +    // Print to UI
  1.1363 +    _LIT( Ktlocale, "tlocale" );
  1.1364 +    _LIT( Ktest1, "In Test1" );
  1.1365 +    TestModuleIf().Printf( 0, Ktlocale, Ktest1 );
  1.1366 +    // Print to log file
  1.1367 +    iLog->Log( Ktest1 );
  1.1368 +
  1.1369 +    TInt i = 0;
  1.1370 +    TPtrC string;
  1.1371 +    _LIT( KParam, "Param[%i]: %S" );
  1.1372 +    
  1.1373 +    MyCtype_bybname fac("C", 1);
  1.1374 +    
  1.1375 +    if (fac.my_do_toupper('a') != 'A')
  1.1376 +    	return KErrGeneral;
  1.1377 +    
  1.1378 +    testChar a[] = {"ABc0D"};
  1.1379 +    fac.my_do_tolower(a, a + 2);
  1.1380 +    if (strcmp((const char *)a, "abc0D") != 0)
  1.1381 +    	return KErrGeneral;
  1.1382 +    
  1.1383 +    return KErrNone;
  1.1384 +
  1.1385 +    }
  1.1386 +
  1.1387 +
  1.1388 +
  1.1389 +// -----------------------------------------------------------------------------
  1.1390 +// Ctlocale::moneypunct_byname_test3L
  1.1391 +// -----------------------------------------------------------------------------
  1.1392 +//
  1.1393 +struct Mympunct_byname : public moneypunct_byname<testChar, true> {
  1.1394 +	Mympunct_byname(const char *name, size_t refs)
  1.1395 +		: moneypunct_byname<testChar, true>(name, refs) {}
  1.1396 +	testChar my_do_decimal_point() const
  1.1397 +		{return (do_decimal_point()); }
  1.1398 +	};
  1.1399 +	
  1.1400 +TInt Ctlocale::moneypunct_byname1L( CStifItemParser& aItem )
  1.1401 +    {
  1.1402 +
  1.1403 +    // Print to UI
  1.1404 +    
  1.1405 +    _LIT( Ktlocale, "tlocale" );
  1.1406 +    _LIT( Ktest1, "In Test3" );
  1.1407 +    TestModuleIf().Printf( 0, Ktlocale, Ktest1 );
  1.1408 +    // Print to log file
  1.1409 +    iLog->Log( Ktest1 );
  1.1410 +
  1.1411 +    TInt i = 0;
  1.1412 +    TPtrC string;
  1.1413 +    _LIT( KParam, "Param[%i]: %S" );
  1.1414 +    
  1.1415 +    Mympunct_byname fac("C", 1);
  1.1416 +	testChar ch = fac.my_do_decimal_point();
  1.1417 +	if (ch != 0)
  1.1418 +		return KErrGeneral;
  1.1419 +    return KErrNone;
  1.1420 +
  1.1421 +    
  1.1422 +    }
  1.1423 +// -----------------------------------------------------------------------------
  1.1424 +// Ctlocale::moneypunct_test2L
  1.1425 +// -----------------------------------------------------------------------------
  1.1426 +//
  1.1427 +struct Mymoneypunct : public moneypunct<testChar, true> {
  1.1428 +	string_type my_do_positive_sign() const
  1.1429 +		{return (do_positive_sign()); }
  1.1430 +	};
  1.1431 +
  1.1432 +TInt Ctlocale::moneypunct1L( CStifItemParser& aItem )
  1.1433 +    {
  1.1434 +
  1.1435 +    // Print to UI
  1.1436 +    _LIT( Ktlocale, "tlocale" );
  1.1437 +    _LIT( Ktest1, "In Test2" );
  1.1438 +    TestModuleIf().Printf( 0, Ktlocale, Ktest1 );
  1.1439 +    // Print to log file
  1.1440 +    iLog->Log( Ktest1 );
  1.1441 +
  1.1442 +    TInt i = 0;
  1.1443 +    TPtrC string;
  1.1444 +    _LIT( KParam, "Param[%i]: %S" );
  1.1445 +    
  1.1446 +    Mymoneypunct fac;
  1.1447 +	basic_string<testChar> str = fac.my_do_positive_sign();
  1.1448 +	if(str.size() != 0)
  1.1449 +		return KErrGeneral;
  1.1450 +    
  1.1451 +    return KErrNone;
  1.1452 +
  1.1453 +    }
  1.1454 +
  1.1455 +
  1.1456 +// -----------------------------------------------------------------------------
  1.1457 +// Ctlocale::numpunct_test4L
  1.1458 +// -----------------------------------------------------------------------------
  1.1459 +//
  1.1460 +
  1.1461 +struct Mynumpunct : public numpunct<testChar> {
  1.1462 +protected:
  1.1463 +	basic_string<testChar> do_truename() const
  1.1464 +		{	basic_string<testChar> str1;
  1.1465 +			Convert_string2_string_chart(str1,"!");
  1.1466 +			return str1; }
  1.1467 +	basic_string<testChar> do_falsename() const
  1.1468 +		{
  1.1469 +			basic_string<testChar> str1;
  1.1470 +			Convert_string2_string_chart(str1,"!!");
  1.1471 +			return str1; }
  1.1472 +	};
  1.1473 +
  1.1474 +TInt Ctlocale::numpunct1L( CStifItemParser& aItem )
  1.1475 +    {
  1.1476 +
  1.1477 +    // Print to UI
  1.1478 +    _LIT( Ktlocale, "tlocale" );
  1.1479 +    _LIT( Ktest1, "In Test4" );
  1.1480 +    TestModuleIf().Printf( 0, Ktlocale, Ktest1 );
  1.1481 +    // Print to log file
  1.1482 +    iLog->Log( Ktest1 );
  1.1483 +
  1.1484 +    TInt i = 0;
  1.1485 +    TPtrC string;
  1.1486 +    _LIT( KParam, "Param[%i]: %S" );
  1.1487 +    
  1.1488 +    Mynumpunct fac;
  1.1489 +    
  1.1490 +    basic_string<testChar> str = fac.truename();
  1.1491 +	if (strcmp((char*)str.c_str(), "!") != 0)
  1.1492 +		return KErrGeneral;
  1.1493 +	
  1.1494 +	str = fac.falsename();
  1.1495 +	if (strcmp((char*)str.c_str(), "!!") != 0)
  1.1496 +		return KErrGeneral;
  1.1497 +		
  1.1498 +    return KErrNone;
  1.1499 +
  1.1500 +    }
  1.1501 +
  1.1502 +// -----------------------------------------------------------------------------
  1.1503 +// Ctlocale::numpunct_byname_test5L
  1.1504 +// -----------------------------------------------------------------------------
  1.1505 +//
  1.1506 +
  1.1507 +struct Mynumpunct_byname : public numpunct_byname<testChar> {
  1.1508 +	Mynumpunct_byname(const char *name, size_t refs)
  1.1509 +		: numpunct_byname<testChar>(name, refs) {}
  1.1510 +	string_type my_do_truename() const
  1.1511 +		{return (do_truename()); }
  1.1512 +	};
  1.1513 +	
  1.1514 +TInt Ctlocale::numpunct_byname1L( CStifItemParser& aItem )
  1.1515 +    {
  1.1516 +
  1.1517 +    // Print to UI
  1.1518 +    _LIT( Ktlocale, "tlocale" );
  1.1519 +    _LIT( Ktest1, "In Test5" );
  1.1520 +    TestModuleIf().Printf( 0, Ktlocale, Ktest1 );
  1.1521 +    // Print to log file
  1.1522 +    iLog->Log( Ktest1 );
  1.1523 +
  1.1524 +    TInt i = 0;
  1.1525 +    TPtrC string;
  1.1526 +    _LIT( KParam, "Param[%i]: %S" );
  1.1527 +    
  1.1528 +    const Mynumpunct_byname fac("C", 1);    
  1.1529 +    basic_string<testChar> str = fac.my_do_truename();
  1.1530 +    if(strcmp((char*)str.c_str(),"true") !=0)
  1.1531 +    	return KErrGeneral;
  1.1532 +    
  1.1533 +    return KErrNone;
  1.1534 +
  1.1535 +    }
  1.1536 +#endif
  1.1537 +
  1.1538 +#if 0    
  1.1539 +
  1.1540 +// -----------------------------------------------------------------------------
  1.1541 +// Ctlocale::num_get_test6L
  1.1542 +// -----------------------------------------------------------------------------
  1.1543 +//
  1.1544 +
  1.1545 +typedef char_traits<testChar> mycharite;
  1.1546 +typedef istreambuf_iterator<testChar, mycharite> myistrite;
  1.1547 +
  1.1548 +struct Mynum_get : public num_get<testChar, myistrite> {
  1.1549 +	iter_type my_do_get(iter_type first, iter_type last, ios_base& str,
  1.1550 +		ios_base::iostate& st, bool& val) const
  1.1551 +		{return (do_get(first, last, str, st, val)); }
  1.1552 +	iter_type my_do_get(iter_type first, iter_type last,  ios_base& str,
  1.1553 +		ios_base::iostate& st, long& val) const
  1.1554 +		{return (do_get(first, last, str, st, val)); }
  1.1555 +	iter_type my_do_get(iter_type first, iter_type last,  ios_base& str,
  1.1556 +		ios_base::iostate& st, unsigned long& val) const
  1.1557 +		{return (do_get(first, last, str, st, val)); }
  1.1558 +	iter_type my_do_get(iter_type first, iter_type last,  ios_base& str,
  1.1559 +		ios_base::iostate& st, double& val) const
  1.1560 +		{return (do_get(first, last, str, st, val)); }
  1.1561 +#ifndef __SYMBIAN32__
  1.1562 +	iter_type my_do_get(iter_type first, iter_type last,  ios_base& str,
  1.1563 +		ios_base::iostate& st, long double& val) const
  1.1564 +		{return (do_get(first, last, str, st, val)); }
  1.1565 +#endif
  1.1566 +	iter_type my_do_get(iter_type first, iter_type last,  ios_base& str,
  1.1567 +		ios_base::iostate& st, unsigned short& val) const	// [NOV95]
  1.1568 +		{return (do_get(first, last, str, st, val)); }
  1.1569 +	iter_type my_do_get(iter_type first, iter_type last,  ios_base& str,
  1.1570 +		ios_base::iostate& st, unsigned int& val) const
  1.1571 +		{return (do_get(first, last, str, st, val)); }
  1.1572 +	iter_type my_do_get(iter_type first, iter_type last,  ios_base& str,
  1.1573 +		ios_base::iostate& st, float& val) const
  1.1574 +		{return (do_get(first, last, str, st, val)); }
  1.1575 +	};
  1.1576 +		
  1.1577 +TInt Ctlocale::num_get1L( CStifItemParser& aItem )
  1.1578 +    {
  1.1579 +
  1.1580 +    // Print to UI
  1.1581 +    _LIT( Ktlocale, "tlocale" );
  1.1582 +    _LIT( Ktest1, "In Test6" );
  1.1583 +    TestModuleIf().Printf( 0, Ktlocale, Ktest1 );
  1.1584 +    // Print to log file
  1.1585 +    iLog->Log( Ktest1 );
  1.1586 +
  1.1587 +    TInt i = 0;
  1.1588 +    TPtrC string;
  1.1589 +    _LIT( KParam, "Param[%i]: %S" );
  1.1590 +    
  1.1591 +    Mynum_get fac;
  1.1592 +    basic_string<testChar> str1;
  1.1593 +    Convert_string2_string_chart(str1,"1V-2W3X4.00Y6A7B-8.C");
  1.1594 +  	locale loc;
  1.1595 +    basic_istringstream<testChar> istr(str1);
  1.1596 +    myistrite first(istr.rdbuf()), last;
  1.1597 +    bool bv = false;
  1.1598 +    ios_base::iostate st = ios_base::goodbit;
  1.1599 +    first = fac.my_do_get(first, last, istr, st, bv);
  1.1600 +	if (!bv);
  1.1601 +		return KErrGeneral;
  1.1602 +	if ((char)*first!= 'V');
  1.1603 +		return KErrGeneral;
  1.1604 +    	
  1.1605 +    
  1.1606 +    return KErrNone;
  1.1607 +
  1.1608 +    }
  1.1609 +    
  1.1610 +#endif    
  1.1611 +    
  1.1612 +//  End of File
  1.1613 +