os/ossrv/stdcpp/tsrc/BC/apps/widecharclassapiBCTest/src/widecharclassapiBCTestCases.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/widecharclassapiBCTest/src/widecharclassapiBCTestCases.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,694 @@
     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 +// [INCLUDE FILES] - do not remove
    1.23 +#include <e32math.h>
    1.24 +#include "widecharclassapiBCTest.h"
    1.25 +
    1.26 +#include <stl\_cwchar.h>
    1.27 +#include <stdio.h>
    1.28 +#include <time.h>
    1.29 +#include <stdarg.h>
    1.30 +
    1.31 +
    1.32 +// EXTERNAL DATA STRUCTURES
    1.33 +//extern  ?external_data;
    1.34 +
    1.35 +// EXTERNAL FUNCTION PROTOTYPES  
    1.36 +//extern ?external_function( ?arg_type,?arg_type );
    1.37 +
    1.38 +// CONSTANTS
    1.39 +//const ?type ?constant_var = ?constant;
    1.40 +
    1.41 +// MACROS
    1.42 +//#define ?macro ?macro_def
    1.43 +
    1.44 +// LOCAL CONSTANTS AND MACROS
    1.45 +//const ?type ?constant_var = ?constant;
    1.46 +//#define ?macro_name ?macro_def
    1.47 +
    1.48 +// MODULE DATA STRUCTURES
    1.49 +//enum ?declaration
    1.50 +//typedef ?declaration
    1.51 +
    1.52 +// LOCAL FUNCTION PROTOTYPES
    1.53 +//?type ?function_name( ?arg_type, ?arg_type );
    1.54 +
    1.55 +// FORWARD DECLARATIONS
    1.56 +//class ?FORWARD_CLASSNAME;
    1.57 +
    1.58 +// ============================= LOCAL FUNCTIONS ===============================
    1.59 +
    1.60 +// -----------------------------------------------------------------------------
    1.61 +// ?function_name ?description.
    1.62 +// ?description
    1.63 +// Returns: ?value_1: ?description
    1.64 +//          ?value_n: ?description_line1
    1.65 +//                    ?description_line2
    1.66 +// -----------------------------------------------------------------------------
    1.67 +//
    1.68 +/*
    1.69 +?type ?function_name(
    1.70 +    ?arg_type arg,  // ?description
    1.71 +    ?arg_type arg)  // ?description
    1.72 +    {
    1.73 +
    1.74 +    ?code  // ?comment
    1.75 +
    1.76 +    // ?comment
    1.77 +    ?code
    1.78 +    }
    1.79 +*/
    1.80 +
    1.81 +// ============================ MEMBER FUNCTIONS ===============================
    1.82 +
    1.83 +// -----------------------------------------------------------------------------
    1.84 +// CwidecharclassapiBCTest::Case
    1.85 +// Returns a test case by number.
    1.86 +//
    1.87 +// This function contains an array of all available test cases 
    1.88 +// i.e pair of case name and test function. If case specified by parameter
    1.89 +// aCaseNumber is found from array, then that item is returned.
    1.90 +// 
    1.91 +// The reason for this rather complicated function is to specify all the
    1.92 +// test cases only in one place. It is not necessary to understand how
    1.93 +// function pointers to class member functions works when adding new test
    1.94 +// cases. See function body for instructions how to add new test case.
    1.95 +// -----------------------------------------------------------------------------
    1.96 +//
    1.97 +const TCaseInfo CwidecharclassapiBCTest::Case ( 
    1.98 +    const TInt aCaseNumber ) const 
    1.99 +     {
   1.100 +
   1.101 +    /**
   1.102 +    * To add new test cases, implement new test case function and add new 
   1.103 +    * line to KCases array specify the name of the case and the function 
   1.104 +    * doing the test case
   1.105 +    * In practice, do following
   1.106 +    * 1) Make copy of existing test case function and change its name
   1.107 +    *    and functionality. Note that the function must be added to 
   1.108 +    *    widecharclassapiBCTest.cpp file and to widecharclassapiBCTest.h 
   1.109 +    *    header file.
   1.110 +    *
   1.111 +    * 2) Add entry to following KCases array either by using:
   1.112 +    *
   1.113 +    * 2.1: FUNCENTRY or ENTRY macro
   1.114 +    * ENTRY macro takes two parameters: test case name and test case 
   1.115 +    * function name.
   1.116 +    *
   1.117 +    * FUNCENTRY macro takes only test case function name as a parameter and
   1.118 +    * uses that as a test case name and test case function name.
   1.119 +    *
   1.120 +    * Or
   1.121 +    *
   1.122 +    * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
   1.123 +    * only with OOM (Out-Of-Memory) testing!
   1.124 +    *
   1.125 +    * OOM_ENTRY macro takes five parameters: test case name, test case 
   1.126 +    * function name, TBool which specifies is method supposed to be run using
   1.127 +    * OOM conditions, TInt value for first heap memory allocation failure and 
   1.128 +    * TInt value for last heap memory allocation failure.
   1.129 +    * 
   1.130 +    * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
   1.131 +    * that as a test case name, TBool which specifies is method supposed to be
   1.132 +    * run using OOM conditions, TInt value for first heap memory allocation 
   1.133 +    * failure and TInt value for last heap memory allocation failure. 
   1.134 +    */ 
   1.135 +
   1.136 +    static TCaseInfoInternal const KCases[] =
   1.137 +        {
   1.138 +        // [test cases entries] - do not remove
   1.139 +        
   1.140 +        // NOTE: When compiled to GCCE, there must be Classname::
   1.141 +        // declaration in front of the method name, e.g. 
   1.142 +        // CwidecharclassapiBCTest::PrintTest. Otherwise the compiler
   1.143 +        // gives errors.
   1.144 +        
   1.145 +        ENTRY( "Arithmetic Functions test", CwidecharclassapiBCTest::ArithmeticTest ),
   1.146 +        ENTRY( "File Manipulation test", CwidecharclassapiBCTest::FileManipulationTest ),
   1.147 +        ENTRY( "Console Operations test", CwidecharclassapiBCTest::ConsoleOperationsTest ),
   1.148 +        ENTRY( "String Operations test", CwidecharclassapiBCTest::StringOperationsTest ),
   1.149 +        ENTRY( "Conversion Operations test", CwidecharclassapiBCTest::ConversionOperationsTest ),
   1.150 +        // Example how to use OOM functionality
   1.151 +        //OOM_ENTRY( "Loop test with OOM", CwidecharclassapiBCTest::LoopTest, ETrue, 2, 3),
   1.152 +        //OOM_FUNCENTRY( CwidecharclassapiBCTest::PrintTest, ETrue, 1, 3 ),
   1.153 +        };
   1.154 +
   1.155 +    // Verify that case number is valid
   1.156 +    if( (TUint) aCaseNumber >= sizeof( KCases ) / 
   1.157 +                               sizeof( TCaseInfoInternal ) )
   1.158 +        {
   1.159 +        // Invalid case, construct empty object
   1.160 +        TCaseInfo null( (const TText*) L"" );
   1.161 +        null.iMethod = NULL;
   1.162 +        null.iIsOOMTest = EFalse;
   1.163 +        null.iFirstMemoryAllocation = 0;
   1.164 +        null.iLastMemoryAllocation = 0;
   1.165 +        return null;
   1.166 +        } 
   1.167 +
   1.168 +    // Construct TCaseInfo object and return it
   1.169 +    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
   1.170 +    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
   1.171 +    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
   1.172 +    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
   1.173 +    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
   1.174 +    return tmp;
   1.175 +
   1.176 +    }
   1.177 +
   1.178 +
   1.179 +int WriteVarPrintfConsole (char *format, ...)
   1.180 +{
   1.181 +  int result;
   1.182 +  va_list args;
   1.183 +  va_start (args, format);
   1.184 +  result = std::vwprintf (L"%d", args);
   1.185 +  va_end (args);
   1.186 +  return result;
   1.187 +}
   1.188 +
   1.189 +int WriteVarPrintfFile (FILE * stream, char * format, ...)
   1.190 +{
   1.191 +  int result;
   1.192 +  va_list args;
   1.193 +  va_start (args, format);
   1.194 +  result = std::vfwprintf (stream, L"%d", args);
   1.195 +  va_end (args);
   1.196 +  return result;
   1.197 +}
   1.198 +
   1.199 +int WriteVarPrintfString (wchar_t * outputBuf, int sizeBuf, char * format, ...)
   1.200 +{
   1.201 +  int result;
   1.202 +  va_list args;
   1.203 +  va_start (args, format);
   1.204 +  result = std::vswprintf (outputBuf, sizeBuf, L"%d", args);
   1.205 +  va_end (args);
   1.206 +  return result;
   1.207 +}
   1.208 +
   1.209 +
   1.210 +
   1.211 +
   1.212 +TInt CwidecharclassapiBCTest::FileManipulationTest( TTestResult& aResult )
   1.213 +    {
   1.214 +  		int testError = 0;
   1.215 +__UHEAP_MARK;
   1.216 +
   1.217 +  		
   1.218 +		const  wchar_t *wsList = L"This is Wide Character Class API test.";
   1.219 +		const  wchar_t *wPrintfTestFormat = L"%d";
   1.220 +		
   1.221 +		wchar_t wsListRead[64];
   1.222 +		wchar_t wPrintfTestReadList[64];
   1.223 +		std::wint_t wc = 88;
   1.224 +		int c = 65;
   1.225 +
   1.226 +
   1.227 +		char fileName[]="c:\\data\\others\\widechartest.txt";
   1.228 +		remove(fileName);
   1.229 +		
   1.230 +		FILE *fp = NULL;
   1.231 +		
   1.232 +		/* opening the output file */
   1.233 +		fp = fopen(fileName,"w");
   1.234 +		if(fp == NULL)
   1.235 +		{
   1.236 +		   testError++;
   1.237 +		}
   1.238 +
   1.239 +//Test std::fwide
   1.240 +		int fileOrientation ;
   1.241 +		
   1.242 +		fileOrientation = std::fwide(fp, 0);
   1.243 +
   1.244 +
   1.245 +//Test std::fwprintf
   1.246 +		int fWritePrResult = std::fwprintf(fp, wPrintfTestFormat, c);
   1.247 +		if(fWritePrResult < 0)
   1.248 +			testError++;
   1.249 +		
   1.250 +//Test std::vfwprintf
   1.251 +		int fWriteVPrResult = WriteVarPrintfFile(fp, "%d", c);
   1.252 +		if(fWriteVPrResult < 0)
   1.253 +			testError++;
   1.254 +		
   1.255 +		
   1.256 +//Test std::fputwc		 
   1.257 +		std::wint_t fWriteWCResult = std::fputwc(wc,fp);
   1.258 +		if(fWriteWCResult == WEOF)
   1.259 +			testError++;
   1.260 +		
   1.261 +//Test std::fputws		 
   1.262 +		int fWriteWSResult = std::fputws(wsList, fp);
   1.263 +		if(fWriteWSResult < 0)
   1.264 +			testError++;
   1.265 +		
   1.266 +	
   1.267 +		fclose(fp);
   1.268 +		
   1.269 +		
   1.270 +		
   1.271 +		int wsListLength = std::wcslen(wsList);
   1.272 +		int wPrintTestListLength = std::wcslen(wPrintfTestFormat);
   1.273 +		
   1.274 +
   1.275 +		/* opening the input file */
   1.276 +		fp = fopen(fileName,"r");
   1.277 +		if(fp == NULL)
   1.278 +		{
   1.279 +		   testError++;
   1.280 +		}
   1.281 +
   1.282 +//Test std::fwscanf
   1.283 +		int inpC;
   1.284 +		int fReadPrResult = std::fwscanf(fp, wPrintfTestFormat, &inpC);
   1.285 +		if(fReadPrResult < 0)
   1.286 +			testError++;
   1.287 +		fReadPrResult = std::fwscanf(fp, wPrintfTestFormat, &inpC);
   1.288 +		if(fReadPrResult < 0)
   1.289 +			testError++;
   1.290 +
   1.291 +		
   1.292 +//Test std::fputwc		 
   1.293 +		std::wint_t fReadWCResult = std::fgetwc(fp);
   1.294 +		if(fReadWCResult == WEOF)
   1.295 +			testError++;
   1.296 +		
   1.297 +//Test std::fgetws		 
   1.298 +		wchar_t * ptrReadWSResult = std::fgetws(wsListRead, wsListLength, fp);
   1.299 +		if(ptrReadWSResult == 0)
   1.300 +			testError++;
   1.301 +		
   1.302 +		
   1.303 +		fclose(fp);
   1.304 +		remove(fileName);
   1.305 +  		
   1.306 +  		
   1.307 +    // Test case passed
   1.308 +__UHEAP_MARKEND;
   1.309 +    // Sets test case result and description(Maximum size is KStifMaxResultDes)
   1.310 +	if(testError)
   1.311 +	{
   1.312 + 	   _LIT( KDescriptionErr, "FileManipulationTest failed" );
   1.313 + 	   aResult.SetResult( KErrGeneral, KDescriptionErr );
   1.314 +
   1.315 + 	   // Case was executed
   1.316 +	    return testError;
   1.317 +		
   1.318 +	}
   1.319 +	
   1.320 +
   1.321 +    // Case was executed
   1.322 +    return KErrNone;
   1.323 +
   1.324 +    }
   1.325 +    
   1.326 +    
   1.327 +TInt CwidecharclassapiBCTest::ConsoleOperationsTest( TTestResult& aResult )
   1.328 +    {
   1.329 +  		int testError = 0;
   1.330 +__UHEAP_MARK;
   1.331 +  		
   1.332 +  		freopen("c:\\data\\others\\myconsole.txt", "w", stdout);
   1.333 +//Test std::putwc 		
   1.334 +  		wchar_t * consoleMessage = L"Enter Character 'v' ";
   1.335 +		fputws(consoleMessage, stdout);
   1.336 +		wint_t putWCResult = std::putwc(L':', stdout);
   1.337 +
   1.338 +//Test std::vwprintf
   1.339 +		int c=89;
   1.340 +		int fWriteVPrResult = WriteVarPrintfConsole("%d", c);
   1.341 +		if(fWriteVPrResult < 0)
   1.342 +			testError++;
   1.343 +
   1.344 +		ungetwc(L'v', stdin);
   1.345 +
   1.346 +//Test std::getwc		
   1.347 +		wint_t getWCResult;
   1.348 +		getWCResult = std::getwc(stdin);
   1.349 +
   1.350 +
   1.351 +		ungetwc(L'v', stdin);
   1.352 +		getWCResult = std::getwchar();
   1.353 +
   1.354 +		fclose(stdout);
   1.355 +		fclose(stderr);
   1.356 +		fclose(stdin);
   1.357 +
   1.358 + 		
   1.359 +    // Test case passed
   1.360 +__UHEAP_MARKEND;
   1.361 +    // Sets test case result and description(Maximum size is KStifMaxResultDes)
   1.362 +	if(testError)
   1.363 +	{
   1.364 + 	   // Case was executed
   1.365 +	    return testError;
   1.366 +		
   1.367 +	}
   1.368 +	
   1.369 +
   1.370 +    // Case was executed
   1.371 +    return KErrNone;
   1.372 +
   1.373 +
   1.374 +    }
   1.375 +    
   1.376 +    
   1.377 +TInt CwidecharclassapiBCTest::StringOperationsTest( TTestResult& aResult )
   1.378 +    {
   1.379 +  		int testError = 0;
   1.380 +__UHEAP_MARK;
   1.381 +  		
   1.382 +//Test std::wcscat  		
   1.383 +		wchar_t wcSRC[64] = L"Wide character";
   1.384 +		wchar_t wcDST[64] = L"Class API";
   1.385 +		wchar_t *wcWCSCATResult= std::wcscat(wcDST, (const wchar_t*)wcSRC);
   1.386 +
   1.387 +//Test std::wcsncat		
   1.388 +		wchar_t *wcWCSNCATResult= std::wcsncat(wcDST, (const wchar_t*)wcSRC, 4);
   1.389 +
   1.390 +		
   1.391 +		wchar_t *wcSTR = L"Wide Character Class API";
   1.392 +		wchar_t wcSearch = L'A';
   1.393 +//Test std::wcschr
   1.394 +		wchar_t* wcWCSCHRResult = std::wcschr(wcSTR, wcSearch);
   1.395 +
   1.396 +//Test std::wcsrchr
   1.397 +		wchar_t* wcWCSRCHRResult = std::wcsrchr(wcSTR, wcSearch);
   1.398 +
   1.399 +//Test std::wmemchr
   1.400 +		wchar_t* wcWMEMCHRResult = std::wmemchr(wcSTR, wcSearch, 4);
   1.401 +
   1.402 +
   1.403 +//Test std::wcscmp
   1.404 +		wchar_t *wcS1 = L"ABCDE";
   1.405 +		wchar_t *wcS2 = L"ACCD";
   1.406 +		int intWCSCMPResult = std::wcscmp(wcS1, wcS2);
   1.407 +
   1.408 +//Test std::wcsncmp
   1.409 +		int intWCSNCMPResult = std::wcsncmp(wcS1, wcS2, 4);
   1.410 +
   1.411 +//Test std::wcscoll
   1.412 +		int intWCSCOLLResult = std::wcscoll(wcS1, wcS2);
   1.413 +
   1.414 +//Test std::wmemcmp
   1.415 +		int intWMEMCMPResult = std::wmemcmp(wcS1, wcS2, 4);
   1.416 +
   1.417 +
   1.418 +//Test std::wcscpy
   1.419 +		wchar_t wcSRC1[64] = L"Wide character";
   1.420 +		wchar_t wcDST1[64] = L"Class API";
   1.421 +		wchar_t *wcWCSCPYResult = std::wcscpy(wcDST1, wcSRC1);
   1.422 +
   1.423 +//Test std::wcsncpy
   1.424 +		wchar_t *wcWCSNCPYResult = std::wcsncpy(wcDST1, wcSRC1, 4);
   1.425 +
   1.426 +//Test std::wmemcpy
   1.427 +		wchar_t *wcWMEMCPYResult = std::wmemcpy(wcDST1, wcSRC1, 4);
   1.428 +
   1.429 +//Test std::wmemmove
   1.430 +		wchar_t *wcWMEMMOVEResult = std::wmemmove(wcDST1, wcSRC1, 4);
   1.431 +
   1.432 +//Test std::wmemset
   1.433 +		wchar_t *wcWMEMSETResult = std::wmemset(wcDST1, L'V', 4);
   1.434 +
   1.435 +//Test std::wcsxfrm
   1.436 +		size_t lenWCSXFRMResult = std::wcsxfrm(wcDST1, wcSRC1, 15);
   1.437 +
   1.438 +//Test std::wcscspn
   1.439 + 		const wchar_t wcSTR1[30] = L"1234567890ABCDE!@#$$";
   1.440 +  		const wchar_t wcSpanset[20] = L"ABCDE!@#$$";
   1.441 +		size_t intWCSCSPNResult = std::wcscspn(wcSTR1, wcSpanset);
   1.442 +	
   1.443 +//Test std::wcsspn	
   1.444 +		size_t intWCSSPNResult = std::wcsspn(wcSTR1, wcSpanset);
   1.445 +
   1.446 +//Test std::wcspbrk	
   1.447 +		wchar_t * wcptrWCSSPNResult = std::wcspbrk(wcSTR1, wcSpanset);
   1.448 +	
   1.449 +	
   1.450 +//Test std::wcsftime	
   1.451 +		time_t rawtime;
   1.452 +  		struct tm * timeinfo;
   1.453 +  		wchar_t wcTimeOutput [80];
   1.454 +  		time ( &rawtime );
   1.455 +  		timeinfo = localtime ( &rawtime );
   1.456 +  		size_t lenString = std::wcsftime (wcTimeOutput,80,L"Now is %I:%M%p.",timeinfo);
   1.457 +	
   1.458 +//Test std::wcslen	
   1.459 +		size_t lenSTR = std::wcslen(wcSTR);
   1.460 +		
   1.461 +//Test std::wcsstr	
   1.462 +		wchar_t wcSTR2[64] = L"Wide character Class API";
   1.463 +		wchar_t wcSUBSTR[64] = L"Class API";
   1.464 +		wchar_t* wcptrWCSSTR = std::wcsstr(wcSTR2, wcSUBSTR);
   1.465 +
   1.466 +
   1.467 +		wchar_t wcSTRDest[64];
   1.468 +//Test std::swprintf	
   1.469 +		wchar_t *formatSTR = L"%d";
   1.470 +		int intSampleOutput = 78;
   1.471 +		int returnPrintf = std::swprintf(wcSTRDest, 63, formatSTR, intSampleOutput);
   1.472 +		
   1.473 +//Test std::swscanf	
   1.474 +		int intSampleInput;
   1.475 +		int returnScanf = std::swscanf(wcSTRDest, formatSTR, &intSampleInput);
   1.476 +  		
   1.477 +  		
   1.478 +//Test std::vswprintf
   1.479 +		wchar_t outputSTR[32];
   1.480 +		int c = 76;
   1.481 +		int fWriteVPrResult = WriteVarPrintfString(outputSTR, 32, "%d", c);
   1.482 +		if(fWriteVPrResult < 0)
   1.483 +			testError++;
   1.484 + 		
   1.485 +  		
   1.486 +    // Test case passed
   1.487 +__UHEAP_MARKEND;
   1.488 +    // Sets test case result and description(Maximum size is KStifMaxResultDes)
   1.489 +	if(testError)
   1.490 +	{
   1.491 + 	   // Case was executed
   1.492 +	    return testError;
   1.493 +		
   1.494 +	}
   1.495 +	
   1.496 +    // Case was executed
   1.497 +    return KErrNone;
   1.498 +
   1.499 +
   1.500 +    }
   1.501 +    
   1.502 +    
   1.503 +TInt CwidecharclassapiBCTest::ConversionOperationsTest( TTestResult& aResult )
   1.504 +    {
   1.505 +  		int testError = 0;
   1.506 +//__UHEAP_MARK;
   1.507 +
   1.508 + 		size_t len;
   1.509 +		char *szMBTest = "this is test";
   1.510 +		mbstate_t mbs;
   1.511 +		mbstate_t ps;
   1.512 + 		
   1.513 +//Test std::btowc
   1.514 +		int c = 65;
   1.515 +		std::wint_t wc;
   1.516 + 		/* converting single byte to wide-character */
   1.517 + 		wc = std::btowc(c);
   1.518 +  		
   1.519 +
   1.520 +//Test std::wcstod
   1.521 +		 wchar_t wcs1[21] = L"  1.23abcd";
   1.522 +		 wchar_t wcs2[5]=L"abcd";
   1.523 +		 wchar_t *eptr;
   1.524 +		 float d;
   1.525 +		 /* convert wide-char string to double */  
   1.526 +		 d = std::wcstod(wcs1, &eptr);
   1.527 +		 /* compare the result */
   1.528 +		 if(!((d == 1.23F) && !(std::wcscmp (eptr, wcs2))))
   1.529 +		   testError++;
   1.530 +  
   1.531 +
   1.532 +//Test std::wcstol
   1.533 +		 wchar_t wcs3[8]=L".23abcd";
   1.534 +		 long longintOutput;
   1.535 +		 /* convert wide-char string to long int */  
   1.536 +		 longintOutput = std::wcstol(wcs1, &eptr, 10);
   1.537 +		 /* compare the result */
   1.538 +		 if(!((longintOutput == 1) && !(std::wcscmp (eptr, wcs3))))
   1.539 +		   testError++;
   1.540 +  
   1.541 +//Test std::wcstoul
   1.542 +		 unsigned long unslongintOutput;
   1.543 +		 /* convert wide-char string to long int */  
   1.544 +		 unslongintOutput = std::wcstoul(wcs1, &eptr, 10);
   1.545 +		 /* compare the result */
   1.546 +		 if(!((unslongintOutput == 1) && !(std::wcscmp (eptr, wcs3))))
   1.547 +		   testError++;
   1.548 +  
   1.549 +
   1.550 +
   1.551 +//Test std::wcstok
   1.552 +		 const wchar_t *seps = L":";
   1.553 +		 wchar_t *last, *tok, text[] = L"one:twothree";
   1.554 +		              
   1.555 +		 tok = std::wcstok(text, seps, &last);
   1.556 +		 if(!tok)
   1.557 +		   testError++;
   1.558 +		 
   1.559 +		 
   1.560 +//Test std::mbsrtowcs
   1.561 +		wchar_t wideCharStringOutput[64];
   1.562 +		len = std::mbsrtowcs(wideCharStringOutput, (const char**)&szMBTest, 10, &ps);
   1.563 +		/* checking for error */
   1.564 +		if(len < 0)
   1.565 +		{
   1.566 +			testError++;
   1.567 +		}
   1.568 +	
   1.569 +//Test std::wcsrtombs
   1.570 +		char mbOutputString[64];
   1.571 +		wchar_t *wcptrString = wideCharStringOutput;
   1.572 +		size_t lenWCS = std::wcsrtombs(mbOutputString, (const wchar_t**) &wcptrString, len, &ps);
   1.573 +
   1.574 +
   1.575 +//Test std::wcrtomb
   1.576 +		wchar_t wcWCRTOMB = L'v';
   1.577 +		char mbWCRTOMB[10];
   1.578 +		len = std::wcrtomb(mbWCRTOMB, wcWCRTOMB, &ps);
   1.579 +
   1.580 +    // Test case passed
   1.581 +__UHEAP_MARKEND ;
   1.582 +
   1.583 +
   1.584 +    // Sets test case result and description(Maximum size is KStifMaxResultDes)
   1.585 +	if(testError)
   1.586 +	{
   1.587 +	    return testError;
   1.588 +		
   1.589 +	}
   1.590 +	
   1.591 +
   1.592 +
   1.593 +    // Case was executed
   1.594 +    return KErrNone;
   1.595 +
   1.596 +
   1.597 +    }
   1.598 +
   1.599 +
   1.600 +
   1.601 +TInt CwidecharclassapiBCTest::ArithmeticTest( TTestResult& aResult )
   1.602 +    {
   1.603 +
   1.604 +  		int testError = 0;
   1.605 +__UHEAP_MARK;
   1.606 +		
   1.607 +
   1.608 +//Test std::mbrlen
   1.609 +		char *szMBTest = "this is test";
   1.610 +		int aa = 2;
   1.611 +		mbstate_t mbs;
   1.612 +		memset(&mbs, 0, sizeof(mbs));
   1.613 +//		size_t charlen = std::mbrlen(szMBTest, 6, &mbs); 
   1.614 +		size_t charlen = std::mbrlen((const char*)&aa, 6, &mbs); 
   1.615 +
   1.616 +//Test std::mbrtowc
   1.617 +		size_t len;
   1.618 +		wchar_t wcMBCOutput[100];
   1.619 +		char *s = "a";
   1.620 +		size_t n = 1;
   1.621 +		mbstate_t ps;
   1.622 +		/* converting multibyte sequence to a wide-char sequence */
   1.623 +		len = std::mbrtowc(wcMBCOutput,(const char *) s, n, &ps);
   1.624 +		/* checking for error value */
   1.625 +		if(len < 0)
   1.626 +		{
   1.627 +			testError++;
   1.628 +		}
   1.629 +
   1.630 +
   1.631 +//Test std::mbsinit
   1.632 +		int mbINITOutput = std::mbsinit((const mbstate_t*) &ps);
   1.633 +
   1.634 +
   1.635 +    // Test case passed
   1.636 +
   1.637 +    // Sets test case result and description(Maximum size is KStifMaxResultDes)
   1.638 +	if(testError)
   1.639 +	{
   1.640 + 	   _LIT( KDescriptionErr, "ArithmeticTest failed" );
   1.641 + 	   aResult.SetResult( KErrGeneral, KDescriptionErr );
   1.642 +
   1.643 + 	   // Case was executed
   1.644 +	    return testError;
   1.645 +		
   1.646 +	}
   1.647 +	
   1.648 +    _LIT( KDescription, "LoopTest passed" );
   1.649 +    aResult.SetResult( KErrNone, KDescription );
   1.650 +
   1.651 +__UHEAP_MARK;
   1.652 +
   1.653 +// Case was executed
   1.654 +    return KErrNone;
   1.655 +
   1.656 +    }
   1.657 +
   1.658 +
   1.659 +
   1.660 +// -----------------------------------------------------------------------------
   1.661 +// ?classname::?member_function
   1.662 +// ?implementation_description
   1.663 +// (other items were commented in a header).
   1.664 +// -----------------------------------------------------------------------------
   1.665 +//
   1.666 +/*
   1.667 +?type ?classname::?member_function(
   1.668 +   ?arg_type arg,
   1.669 +   ?arg_type arg )
   1.670 +   {
   1.671 +
   1.672 +   ?code
   1.673 +
   1.674 +   }
   1.675 +*/
   1.676 +
   1.677 +// ========================== OTHER EXPORTED FUNCTIONS =========================
   1.678 +
   1.679 +// -----------------------------------------------------------------------------
   1.680 +// ?function_name implements...
   1.681 +// ?implementation_description.
   1.682 +// Returns: ?value_1: ?description
   1.683 +//          ?value_n: ?description
   1.684 +//                    ?description
   1.685 +// -----------------------------------------------------------------------------
   1.686 +//
   1.687 +/*
   1.688 +?type  ?function_name(
   1.689 +    ?arg_type arg,  // ?description
   1.690 +    ?arg_type arg )  // ?description
   1.691 +    {
   1.692 +
   1.693 +    ?code
   1.694 +
   1.695 +    }
   1.696 +*/
   1.697 +//  [End of File] - do not remove