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