os/ossrv/stdcpp/tsrc/BC/apps/widecharclassapiBCTest/src/widecharclassapiBCTestCases.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:       
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
// [INCLUDE FILES] - do not remove
sl@0
    20
#include <e32math.h>
sl@0
    21
#include "widecharclassapiBCTest.h"
sl@0
    22
sl@0
    23
#include <stl\_cwchar.h>
sl@0
    24
#include <stdio.h>
sl@0
    25
#include <time.h>
sl@0
    26
#include <stdarg.h>
sl@0
    27
sl@0
    28
sl@0
    29
// EXTERNAL DATA STRUCTURES
sl@0
    30
//extern  ?external_data;
sl@0
    31
sl@0
    32
// EXTERNAL FUNCTION PROTOTYPES  
sl@0
    33
//extern ?external_function( ?arg_type,?arg_type );
sl@0
    34
sl@0
    35
// CONSTANTS
sl@0
    36
//const ?type ?constant_var = ?constant;
sl@0
    37
sl@0
    38
// MACROS
sl@0
    39
//#define ?macro ?macro_def
sl@0
    40
sl@0
    41
// LOCAL CONSTANTS AND MACROS
sl@0
    42
//const ?type ?constant_var = ?constant;
sl@0
    43
//#define ?macro_name ?macro_def
sl@0
    44
sl@0
    45
// MODULE DATA STRUCTURES
sl@0
    46
//enum ?declaration
sl@0
    47
//typedef ?declaration
sl@0
    48
sl@0
    49
// LOCAL FUNCTION PROTOTYPES
sl@0
    50
//?type ?function_name( ?arg_type, ?arg_type );
sl@0
    51
sl@0
    52
// FORWARD DECLARATIONS
sl@0
    53
//class ?FORWARD_CLASSNAME;
sl@0
    54
sl@0
    55
// ============================= LOCAL FUNCTIONS ===============================
sl@0
    56
sl@0
    57
// -----------------------------------------------------------------------------
sl@0
    58
// ?function_name ?description.
sl@0
    59
// ?description
sl@0
    60
// Returns: ?value_1: ?description
sl@0
    61
//          ?value_n: ?description_line1
sl@0
    62
//                    ?description_line2
sl@0
    63
// -----------------------------------------------------------------------------
sl@0
    64
//
sl@0
    65
/*
sl@0
    66
?type ?function_name(
sl@0
    67
    ?arg_type arg,  // ?description
sl@0
    68
    ?arg_type arg)  // ?description
sl@0
    69
    {
sl@0
    70
sl@0
    71
    ?code  // ?comment
sl@0
    72
sl@0
    73
    // ?comment
sl@0
    74
    ?code
sl@0
    75
    }
sl@0
    76
*/
sl@0
    77
sl@0
    78
// ============================ MEMBER FUNCTIONS ===============================
sl@0
    79
sl@0
    80
// -----------------------------------------------------------------------------
sl@0
    81
// CwidecharclassapiBCTest::Case
sl@0
    82
// Returns a test case by number.
sl@0
    83
//
sl@0
    84
// This function contains an array of all available test cases 
sl@0
    85
// i.e pair of case name and test function. If case specified by parameter
sl@0
    86
// aCaseNumber is found from array, then that item is returned.
sl@0
    87
// 
sl@0
    88
// The reason for this rather complicated function is to specify all the
sl@0
    89
// test cases only in one place. It is not necessary to understand how
sl@0
    90
// function pointers to class member functions works when adding new test
sl@0
    91
// cases. See function body for instructions how to add new test case.
sl@0
    92
// -----------------------------------------------------------------------------
sl@0
    93
//
sl@0
    94
const TCaseInfo CwidecharclassapiBCTest::Case ( 
sl@0
    95
    const TInt aCaseNumber ) const 
sl@0
    96
     {
sl@0
    97
sl@0
    98
    /**
sl@0
    99
    * To add new test cases, implement new test case function and add new 
sl@0
   100
    * line to KCases array specify the name of the case and the function 
sl@0
   101
    * doing the test case
sl@0
   102
    * In practice, do following
sl@0
   103
    * 1) Make copy of existing test case function and change its name
sl@0
   104
    *    and functionality. Note that the function must be added to 
sl@0
   105
    *    widecharclassapiBCTest.cpp file and to widecharclassapiBCTest.h 
sl@0
   106
    *    header file.
sl@0
   107
    *
sl@0
   108
    * 2) Add entry to following KCases array either by using:
sl@0
   109
    *
sl@0
   110
    * 2.1: FUNCENTRY or ENTRY macro
sl@0
   111
    * ENTRY macro takes two parameters: test case name and test case 
sl@0
   112
    * function name.
sl@0
   113
    *
sl@0
   114
    * FUNCENTRY macro takes only test case function name as a parameter and
sl@0
   115
    * uses that as a test case name and test case function name.
sl@0
   116
    *
sl@0
   117
    * Or
sl@0
   118
    *
sl@0
   119
    * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
sl@0
   120
    * only with OOM (Out-Of-Memory) testing!
sl@0
   121
    *
sl@0
   122
    * OOM_ENTRY macro takes five parameters: test case name, test case 
sl@0
   123
    * function name, TBool which specifies is method supposed to be run using
sl@0
   124
    * OOM conditions, TInt value for first heap memory allocation failure and 
sl@0
   125
    * TInt value for last heap memory allocation failure.
sl@0
   126
    * 
sl@0
   127
    * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
sl@0
   128
    * that as a test case name, TBool which specifies is method supposed to be
sl@0
   129
    * run using OOM conditions, TInt value for first heap memory allocation 
sl@0
   130
    * failure and TInt value for last heap memory allocation failure. 
sl@0
   131
    */ 
sl@0
   132
sl@0
   133
    static TCaseInfoInternal const KCases[] =
sl@0
   134
        {
sl@0
   135
        // [test cases entries] - do not remove
sl@0
   136
        
sl@0
   137
        // NOTE: When compiled to GCCE, there must be Classname::
sl@0
   138
        // declaration in front of the method name, e.g. 
sl@0
   139
        // CwidecharclassapiBCTest::PrintTest. Otherwise the compiler
sl@0
   140
        // gives errors.
sl@0
   141
        
sl@0
   142
        ENTRY( "Arithmetic Functions test", CwidecharclassapiBCTest::ArithmeticTest ),
sl@0
   143
        ENTRY( "File Manipulation test", CwidecharclassapiBCTest::FileManipulationTest ),
sl@0
   144
        ENTRY( "Console Operations test", CwidecharclassapiBCTest::ConsoleOperationsTest ),
sl@0
   145
        ENTRY( "String Operations test", CwidecharclassapiBCTest::StringOperationsTest ),
sl@0
   146
        ENTRY( "Conversion Operations test", CwidecharclassapiBCTest::ConversionOperationsTest ),
sl@0
   147
        // Example how to use OOM functionality
sl@0
   148
        //OOM_ENTRY( "Loop test with OOM", CwidecharclassapiBCTest::LoopTest, ETrue, 2, 3),
sl@0
   149
        //OOM_FUNCENTRY( CwidecharclassapiBCTest::PrintTest, ETrue, 1, 3 ),
sl@0
   150
        };
sl@0
   151
sl@0
   152
    // Verify that case number is valid
sl@0
   153
    if( (TUint) aCaseNumber >= sizeof( KCases ) / 
sl@0
   154
                               sizeof( TCaseInfoInternal ) )
sl@0
   155
        {
sl@0
   156
        // Invalid case, construct empty object
sl@0
   157
        TCaseInfo null( (const TText*) L"" );
sl@0
   158
        null.iMethod = NULL;
sl@0
   159
        null.iIsOOMTest = EFalse;
sl@0
   160
        null.iFirstMemoryAllocation = 0;
sl@0
   161
        null.iLastMemoryAllocation = 0;
sl@0
   162
        return null;
sl@0
   163
        } 
sl@0
   164
sl@0
   165
    // Construct TCaseInfo object and return it
sl@0
   166
    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
sl@0
   167
    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
sl@0
   168
    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
sl@0
   169
    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
sl@0
   170
    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
sl@0
   171
    return tmp;
sl@0
   172
sl@0
   173
    }
sl@0
   174
sl@0
   175
sl@0
   176
int WriteVarPrintfConsole (char *format, ...)
sl@0
   177
{
sl@0
   178
  int result;
sl@0
   179
  va_list args;
sl@0
   180
  va_start (args, format);
sl@0
   181
  result = std::vwprintf (L"%d", args);
sl@0
   182
  va_end (args);
sl@0
   183
  return result;
sl@0
   184
}
sl@0
   185
sl@0
   186
int WriteVarPrintfFile (FILE * stream, char * format, ...)
sl@0
   187
{
sl@0
   188
  int result;
sl@0
   189
  va_list args;
sl@0
   190
  va_start (args, format);
sl@0
   191
  result = std::vfwprintf (stream, L"%d", args);
sl@0
   192
  va_end (args);
sl@0
   193
  return result;
sl@0
   194
}
sl@0
   195
sl@0
   196
int WriteVarPrintfString (wchar_t * outputBuf, int sizeBuf, char * format, ...)
sl@0
   197
{
sl@0
   198
  int result;
sl@0
   199
  va_list args;
sl@0
   200
  va_start (args, format);
sl@0
   201
  result = std::vswprintf (outputBuf, sizeBuf, L"%d", args);
sl@0
   202
  va_end (args);
sl@0
   203
  return result;
sl@0
   204
}
sl@0
   205
sl@0
   206
sl@0
   207
sl@0
   208
sl@0
   209
TInt CwidecharclassapiBCTest::FileManipulationTest( TTestResult& aResult )
sl@0
   210
    {
sl@0
   211
  		int testError = 0;
sl@0
   212
__UHEAP_MARK;
sl@0
   213
sl@0
   214
  		
sl@0
   215
		const  wchar_t *wsList = L"This is Wide Character Class API test.";
sl@0
   216
		const  wchar_t *wPrintfTestFormat = L"%d";
sl@0
   217
		
sl@0
   218
		wchar_t wsListRead[64];
sl@0
   219
		wchar_t wPrintfTestReadList[64];
sl@0
   220
		std::wint_t wc = 88;
sl@0
   221
		int c = 65;
sl@0
   222
sl@0
   223
sl@0
   224
		char fileName[]="c:\\data\\others\\widechartest.txt";
sl@0
   225
		remove(fileName);
sl@0
   226
		
sl@0
   227
		FILE *fp = NULL;
sl@0
   228
		
sl@0
   229
		/* opening the output file */
sl@0
   230
		fp = fopen(fileName,"w");
sl@0
   231
		if(fp == NULL)
sl@0
   232
		{
sl@0
   233
		   testError++;
sl@0
   234
		}
sl@0
   235
sl@0
   236
//Test std::fwide
sl@0
   237
		int fileOrientation ;
sl@0
   238
		
sl@0
   239
		fileOrientation = std::fwide(fp, 0);
sl@0
   240
sl@0
   241
sl@0
   242
//Test std::fwprintf
sl@0
   243
		int fWritePrResult = std::fwprintf(fp, wPrintfTestFormat, c);
sl@0
   244
		if(fWritePrResult < 0)
sl@0
   245
			testError++;
sl@0
   246
		
sl@0
   247
//Test std::vfwprintf
sl@0
   248
		int fWriteVPrResult = WriteVarPrintfFile(fp, "%d", c);
sl@0
   249
		if(fWriteVPrResult < 0)
sl@0
   250
			testError++;
sl@0
   251
		
sl@0
   252
		
sl@0
   253
//Test std::fputwc		 
sl@0
   254
		std::wint_t fWriteWCResult = std::fputwc(wc,fp);
sl@0
   255
		if(fWriteWCResult == WEOF)
sl@0
   256
			testError++;
sl@0
   257
		
sl@0
   258
//Test std::fputws		 
sl@0
   259
		int fWriteWSResult = std::fputws(wsList, fp);
sl@0
   260
		if(fWriteWSResult < 0)
sl@0
   261
			testError++;
sl@0
   262
		
sl@0
   263
	
sl@0
   264
		fclose(fp);
sl@0
   265
		
sl@0
   266
		
sl@0
   267
		
sl@0
   268
		int wsListLength = std::wcslen(wsList);
sl@0
   269
		int wPrintTestListLength = std::wcslen(wPrintfTestFormat);
sl@0
   270
		
sl@0
   271
sl@0
   272
		/* opening the input file */
sl@0
   273
		fp = fopen(fileName,"r");
sl@0
   274
		if(fp == NULL)
sl@0
   275
		{
sl@0
   276
		   testError++;
sl@0
   277
		}
sl@0
   278
sl@0
   279
//Test std::fwscanf
sl@0
   280
		int inpC;
sl@0
   281
		int fReadPrResult = std::fwscanf(fp, wPrintfTestFormat, &inpC);
sl@0
   282
		if(fReadPrResult < 0)
sl@0
   283
			testError++;
sl@0
   284
		fReadPrResult = std::fwscanf(fp, wPrintfTestFormat, &inpC);
sl@0
   285
		if(fReadPrResult < 0)
sl@0
   286
			testError++;
sl@0
   287
sl@0
   288
		
sl@0
   289
//Test std::fputwc		 
sl@0
   290
		std::wint_t fReadWCResult = std::fgetwc(fp);
sl@0
   291
		if(fReadWCResult == WEOF)
sl@0
   292
			testError++;
sl@0
   293
		
sl@0
   294
//Test std::fgetws		 
sl@0
   295
		wchar_t * ptrReadWSResult = std::fgetws(wsListRead, wsListLength, fp);
sl@0
   296
		if(ptrReadWSResult == 0)
sl@0
   297
			testError++;
sl@0
   298
		
sl@0
   299
		
sl@0
   300
		fclose(fp);
sl@0
   301
		remove(fileName);
sl@0
   302
  		
sl@0
   303
  		
sl@0
   304
    // Test case passed
sl@0
   305
__UHEAP_MARKEND;
sl@0
   306
    // Sets test case result and description(Maximum size is KStifMaxResultDes)
sl@0
   307
	if(testError)
sl@0
   308
	{
sl@0
   309
 	   _LIT( KDescriptionErr, "FileManipulationTest failed" );
sl@0
   310
 	   aResult.SetResult( KErrGeneral, KDescriptionErr );
sl@0
   311
sl@0
   312
 	   // Case was executed
sl@0
   313
	    return testError;
sl@0
   314
		
sl@0
   315
	}
sl@0
   316
	
sl@0
   317
sl@0
   318
    // Case was executed
sl@0
   319
    return KErrNone;
sl@0
   320
sl@0
   321
    }
sl@0
   322
    
sl@0
   323
    
sl@0
   324
TInt CwidecharclassapiBCTest::ConsoleOperationsTest( TTestResult& aResult )
sl@0
   325
    {
sl@0
   326
  		int testError = 0;
sl@0
   327
__UHEAP_MARK;
sl@0
   328
  		
sl@0
   329
  		freopen("c:\\data\\others\\myconsole.txt", "w", stdout);
sl@0
   330
//Test std::putwc 		
sl@0
   331
  		wchar_t * consoleMessage = L"Enter Character 'v' ";
sl@0
   332
		fputws(consoleMessage, stdout);
sl@0
   333
		wint_t putWCResult = std::putwc(L':', stdout);
sl@0
   334
sl@0
   335
//Test std::vwprintf
sl@0
   336
		int c=89;
sl@0
   337
		int fWriteVPrResult = WriteVarPrintfConsole("%d", c);
sl@0
   338
		if(fWriteVPrResult < 0)
sl@0
   339
			testError++;
sl@0
   340
sl@0
   341
		ungetwc(L'v', stdin);
sl@0
   342
sl@0
   343
//Test std::getwc		
sl@0
   344
		wint_t getWCResult;
sl@0
   345
		getWCResult = std::getwc(stdin);
sl@0
   346
sl@0
   347
sl@0
   348
		ungetwc(L'v', stdin);
sl@0
   349
		getWCResult = std::getwchar();
sl@0
   350
sl@0
   351
		fclose(stdout);
sl@0
   352
		fclose(stderr);
sl@0
   353
		fclose(stdin);
sl@0
   354
sl@0
   355
 		
sl@0
   356
    // Test case passed
sl@0
   357
__UHEAP_MARKEND;
sl@0
   358
    // Sets test case result and description(Maximum size is KStifMaxResultDes)
sl@0
   359
	if(testError)
sl@0
   360
	{
sl@0
   361
 	   // Case was executed
sl@0
   362
	    return testError;
sl@0
   363
		
sl@0
   364
	}
sl@0
   365
	
sl@0
   366
sl@0
   367
    // Case was executed
sl@0
   368
    return KErrNone;
sl@0
   369
sl@0
   370
sl@0
   371
    }
sl@0
   372
    
sl@0
   373
    
sl@0
   374
TInt CwidecharclassapiBCTest::StringOperationsTest( TTestResult& aResult )
sl@0
   375
    {
sl@0
   376
  		int testError = 0;
sl@0
   377
__UHEAP_MARK;
sl@0
   378
  		
sl@0
   379
//Test std::wcscat  		
sl@0
   380
		wchar_t wcSRC[64] = L"Wide character";
sl@0
   381
		wchar_t wcDST[64] = L"Class API";
sl@0
   382
		wchar_t *wcWCSCATResult= std::wcscat(wcDST, (const wchar_t*)wcSRC);
sl@0
   383
sl@0
   384
//Test std::wcsncat		
sl@0
   385
		wchar_t *wcWCSNCATResult= std::wcsncat(wcDST, (const wchar_t*)wcSRC, 4);
sl@0
   386
sl@0
   387
		
sl@0
   388
		wchar_t *wcSTR = L"Wide Character Class API";
sl@0
   389
		wchar_t wcSearch = L'A';
sl@0
   390
//Test std::wcschr
sl@0
   391
		wchar_t* wcWCSCHRResult = std::wcschr(wcSTR, wcSearch);
sl@0
   392
sl@0
   393
//Test std::wcsrchr
sl@0
   394
		wchar_t* wcWCSRCHRResult = std::wcsrchr(wcSTR, wcSearch);
sl@0
   395
sl@0
   396
//Test std::wmemchr
sl@0
   397
		wchar_t* wcWMEMCHRResult = std::wmemchr(wcSTR, wcSearch, 4);
sl@0
   398
sl@0
   399
sl@0
   400
//Test std::wcscmp
sl@0
   401
		wchar_t *wcS1 = L"ABCDE";
sl@0
   402
		wchar_t *wcS2 = L"ACCD";
sl@0
   403
		int intWCSCMPResult = std::wcscmp(wcS1, wcS2);
sl@0
   404
sl@0
   405
//Test std::wcsncmp
sl@0
   406
		int intWCSNCMPResult = std::wcsncmp(wcS1, wcS2, 4);
sl@0
   407
sl@0
   408
//Test std::wcscoll
sl@0
   409
		int intWCSCOLLResult = std::wcscoll(wcS1, wcS2);
sl@0
   410
sl@0
   411
//Test std::wmemcmp
sl@0
   412
		int intWMEMCMPResult = std::wmemcmp(wcS1, wcS2, 4);
sl@0
   413
sl@0
   414
sl@0
   415
//Test std::wcscpy
sl@0
   416
		wchar_t wcSRC1[64] = L"Wide character";
sl@0
   417
		wchar_t wcDST1[64] = L"Class API";
sl@0
   418
		wchar_t *wcWCSCPYResult = std::wcscpy(wcDST1, wcSRC1);
sl@0
   419
sl@0
   420
//Test std::wcsncpy
sl@0
   421
		wchar_t *wcWCSNCPYResult = std::wcsncpy(wcDST1, wcSRC1, 4);
sl@0
   422
sl@0
   423
//Test std::wmemcpy
sl@0
   424
		wchar_t *wcWMEMCPYResult = std::wmemcpy(wcDST1, wcSRC1, 4);
sl@0
   425
sl@0
   426
//Test std::wmemmove
sl@0
   427
		wchar_t *wcWMEMMOVEResult = std::wmemmove(wcDST1, wcSRC1, 4);
sl@0
   428
sl@0
   429
//Test std::wmemset
sl@0
   430
		wchar_t *wcWMEMSETResult = std::wmemset(wcDST1, L'V', 4);
sl@0
   431
sl@0
   432
//Test std::wcsxfrm
sl@0
   433
		size_t lenWCSXFRMResult = std::wcsxfrm(wcDST1, wcSRC1, 15);
sl@0
   434
sl@0
   435
//Test std::wcscspn
sl@0
   436
 		const wchar_t wcSTR1[30] = L"1234567890ABCDE!@#$$";
sl@0
   437
  		const wchar_t wcSpanset[20] = L"ABCDE!@#$$";
sl@0
   438
		size_t intWCSCSPNResult = std::wcscspn(wcSTR1, wcSpanset);
sl@0
   439
	
sl@0
   440
//Test std::wcsspn	
sl@0
   441
		size_t intWCSSPNResult = std::wcsspn(wcSTR1, wcSpanset);
sl@0
   442
sl@0
   443
//Test std::wcspbrk	
sl@0
   444
		wchar_t * wcptrWCSSPNResult = std::wcspbrk(wcSTR1, wcSpanset);
sl@0
   445
	
sl@0
   446
	
sl@0
   447
//Test std::wcsftime	
sl@0
   448
		time_t rawtime;
sl@0
   449
  		struct tm * timeinfo;
sl@0
   450
  		wchar_t wcTimeOutput [80];
sl@0
   451
  		time ( &rawtime );
sl@0
   452
  		timeinfo = localtime ( &rawtime );
sl@0
   453
  		size_t lenString = std::wcsftime (wcTimeOutput,80,L"Now is %I:%M%p.",timeinfo);
sl@0
   454
	
sl@0
   455
//Test std::wcslen	
sl@0
   456
		size_t lenSTR = std::wcslen(wcSTR);
sl@0
   457
		
sl@0
   458
//Test std::wcsstr	
sl@0
   459
		wchar_t wcSTR2[64] = L"Wide character Class API";
sl@0
   460
		wchar_t wcSUBSTR[64] = L"Class API";
sl@0
   461
		wchar_t* wcptrWCSSTR = std::wcsstr(wcSTR2, wcSUBSTR);
sl@0
   462
sl@0
   463
sl@0
   464
		wchar_t wcSTRDest[64];
sl@0
   465
//Test std::swprintf	
sl@0
   466
		wchar_t *formatSTR = L"%d";
sl@0
   467
		int intSampleOutput = 78;
sl@0
   468
		int returnPrintf = std::swprintf(wcSTRDest, 63, formatSTR, intSampleOutput);
sl@0
   469
		
sl@0
   470
//Test std::swscanf	
sl@0
   471
		int intSampleInput;
sl@0
   472
		int returnScanf = std::swscanf(wcSTRDest, formatSTR, &intSampleInput);
sl@0
   473
  		
sl@0
   474
  		
sl@0
   475
//Test std::vswprintf
sl@0
   476
		wchar_t outputSTR[32];
sl@0
   477
		int c = 76;
sl@0
   478
		int fWriteVPrResult = WriteVarPrintfString(outputSTR, 32, "%d", c);
sl@0
   479
		if(fWriteVPrResult < 0)
sl@0
   480
			testError++;
sl@0
   481
 		
sl@0
   482
  		
sl@0
   483
    // Test case passed
sl@0
   484
__UHEAP_MARKEND;
sl@0
   485
    // Sets test case result and description(Maximum size is KStifMaxResultDes)
sl@0
   486
	if(testError)
sl@0
   487
	{
sl@0
   488
 	   // Case was executed
sl@0
   489
	    return testError;
sl@0
   490
		
sl@0
   491
	}
sl@0
   492
	
sl@0
   493
    // Case was executed
sl@0
   494
    return KErrNone;
sl@0
   495
sl@0
   496
sl@0
   497
    }
sl@0
   498
    
sl@0
   499
    
sl@0
   500
TInt CwidecharclassapiBCTest::ConversionOperationsTest( TTestResult& aResult )
sl@0
   501
    {
sl@0
   502
  		int testError = 0;
sl@0
   503
//__UHEAP_MARK;
sl@0
   504
sl@0
   505
 		size_t len;
sl@0
   506
		char *szMBTest = "this is test";
sl@0
   507
		mbstate_t mbs;
sl@0
   508
		mbstate_t ps;
sl@0
   509
 		
sl@0
   510
//Test std::btowc
sl@0
   511
		int c = 65;
sl@0
   512
		std::wint_t wc;
sl@0
   513
 		/* converting single byte to wide-character */
sl@0
   514
 		wc = std::btowc(c);
sl@0
   515
  		
sl@0
   516
sl@0
   517
//Test std::wcstod
sl@0
   518
		 wchar_t wcs1[21] = L"  1.23abcd";
sl@0
   519
		 wchar_t wcs2[5]=L"abcd";
sl@0
   520
		 wchar_t *eptr;
sl@0
   521
		 float d;
sl@0
   522
		 /* convert wide-char string to double */  
sl@0
   523
		 d = std::wcstod(wcs1, &eptr);
sl@0
   524
		 /* compare the result */
sl@0
   525
		 if(!((d == 1.23F) && !(std::wcscmp (eptr, wcs2))))
sl@0
   526
		   testError++;
sl@0
   527
  
sl@0
   528
sl@0
   529
//Test std::wcstol
sl@0
   530
		 wchar_t wcs3[8]=L".23abcd";
sl@0
   531
		 long longintOutput;
sl@0
   532
		 /* convert wide-char string to long int */  
sl@0
   533
		 longintOutput = std::wcstol(wcs1, &eptr, 10);
sl@0
   534
		 /* compare the result */
sl@0
   535
		 if(!((longintOutput == 1) && !(std::wcscmp (eptr, wcs3))))
sl@0
   536
		   testError++;
sl@0
   537
  
sl@0
   538
//Test std::wcstoul
sl@0
   539
		 unsigned long unslongintOutput;
sl@0
   540
		 /* convert wide-char string to long int */  
sl@0
   541
		 unslongintOutput = std::wcstoul(wcs1, &eptr, 10);
sl@0
   542
		 /* compare the result */
sl@0
   543
		 if(!((unslongintOutput == 1) && !(std::wcscmp (eptr, wcs3))))
sl@0
   544
		   testError++;
sl@0
   545
  
sl@0
   546
sl@0
   547
sl@0
   548
//Test std::wcstok
sl@0
   549
		 const wchar_t *seps = L":";
sl@0
   550
		 wchar_t *last, *tok, text[] = L"one:twothree";
sl@0
   551
		              
sl@0
   552
		 tok = std::wcstok(text, seps, &last);
sl@0
   553
		 if(!tok)
sl@0
   554
		   testError++;
sl@0
   555
		 
sl@0
   556
		 
sl@0
   557
//Test std::mbsrtowcs
sl@0
   558
		wchar_t wideCharStringOutput[64];
sl@0
   559
		len = std::mbsrtowcs(wideCharStringOutput, (const char**)&szMBTest, 10, &ps);
sl@0
   560
		/* checking for error */
sl@0
   561
		if(len < 0)
sl@0
   562
		{
sl@0
   563
			testError++;
sl@0
   564
		}
sl@0
   565
	
sl@0
   566
//Test std::wcsrtombs
sl@0
   567
		char mbOutputString[64];
sl@0
   568
		wchar_t *wcptrString = wideCharStringOutput;
sl@0
   569
		size_t lenWCS = std::wcsrtombs(mbOutputString, (const wchar_t**) &wcptrString, len, &ps);
sl@0
   570
sl@0
   571
sl@0
   572
//Test std::wcrtomb
sl@0
   573
		wchar_t wcWCRTOMB = L'v';
sl@0
   574
		char mbWCRTOMB[10];
sl@0
   575
		len = std::wcrtomb(mbWCRTOMB, wcWCRTOMB, &ps);
sl@0
   576
sl@0
   577
    // Test case passed
sl@0
   578
__UHEAP_MARKEND ;
sl@0
   579
sl@0
   580
sl@0
   581
    // Sets test case result and description(Maximum size is KStifMaxResultDes)
sl@0
   582
	if(testError)
sl@0
   583
	{
sl@0
   584
	    return testError;
sl@0
   585
		
sl@0
   586
	}
sl@0
   587
	
sl@0
   588
sl@0
   589
sl@0
   590
    // Case was executed
sl@0
   591
    return KErrNone;
sl@0
   592
sl@0
   593
sl@0
   594
    }
sl@0
   595
sl@0
   596
sl@0
   597
sl@0
   598
TInt CwidecharclassapiBCTest::ArithmeticTest( TTestResult& aResult )
sl@0
   599
    {
sl@0
   600
sl@0
   601
  		int testError = 0;
sl@0
   602
__UHEAP_MARK;
sl@0
   603
		
sl@0
   604
sl@0
   605
//Test std::mbrlen
sl@0
   606
		char *szMBTest = "this is test";
sl@0
   607
		int aa = 2;
sl@0
   608
		mbstate_t mbs;
sl@0
   609
		memset(&mbs, 0, sizeof(mbs));
sl@0
   610
//		size_t charlen = std::mbrlen(szMBTest, 6, &mbs); 
sl@0
   611
		size_t charlen = std::mbrlen((const char*)&aa, 6, &mbs); 
sl@0
   612
sl@0
   613
//Test std::mbrtowc
sl@0
   614
		size_t len;
sl@0
   615
		wchar_t wcMBCOutput[100];
sl@0
   616
		char *s = "a";
sl@0
   617
		size_t n = 1;
sl@0
   618
		mbstate_t ps;
sl@0
   619
		/* converting multibyte sequence to a wide-char sequence */
sl@0
   620
		len = std::mbrtowc(wcMBCOutput,(const char *) s, n, &ps);
sl@0
   621
		/* checking for error value */
sl@0
   622
		if(len < 0)
sl@0
   623
		{
sl@0
   624
			testError++;
sl@0
   625
		}
sl@0
   626
sl@0
   627
sl@0
   628
//Test std::mbsinit
sl@0
   629
		int mbINITOutput = std::mbsinit((const mbstate_t*) &ps);
sl@0
   630
sl@0
   631
sl@0
   632
    // Test case passed
sl@0
   633
sl@0
   634
    // Sets test case result and description(Maximum size is KStifMaxResultDes)
sl@0
   635
	if(testError)
sl@0
   636
	{
sl@0
   637
 	   _LIT( KDescriptionErr, "ArithmeticTest failed" );
sl@0
   638
 	   aResult.SetResult( KErrGeneral, KDescriptionErr );
sl@0
   639
sl@0
   640
 	   // Case was executed
sl@0
   641
	    return testError;
sl@0
   642
		
sl@0
   643
	}
sl@0
   644
	
sl@0
   645
    _LIT( KDescription, "LoopTest passed" );
sl@0
   646
    aResult.SetResult( KErrNone, KDescription );
sl@0
   647
sl@0
   648
__UHEAP_MARK;
sl@0
   649
sl@0
   650
// Case was executed
sl@0
   651
    return KErrNone;
sl@0
   652
sl@0
   653
    }
sl@0
   654
sl@0
   655
sl@0
   656
sl@0
   657
// -----------------------------------------------------------------------------
sl@0
   658
// ?classname::?member_function
sl@0
   659
// ?implementation_description
sl@0
   660
// (other items were commented in a header).
sl@0
   661
// -----------------------------------------------------------------------------
sl@0
   662
//
sl@0
   663
/*
sl@0
   664
?type ?classname::?member_function(
sl@0
   665
   ?arg_type arg,
sl@0
   666
   ?arg_type arg )
sl@0
   667
   {
sl@0
   668
sl@0
   669
   ?code
sl@0
   670
sl@0
   671
   }
sl@0
   672
*/
sl@0
   673
sl@0
   674
// ========================== OTHER EXPORTED FUNCTIONS =========================
sl@0
   675
sl@0
   676
// -----------------------------------------------------------------------------
sl@0
   677
// ?function_name implements...
sl@0
   678
// ?implementation_description.
sl@0
   679
// Returns: ?value_1: ?description
sl@0
   680
//          ?value_n: ?description
sl@0
   681
//                    ?description
sl@0
   682
// -----------------------------------------------------------------------------
sl@0
   683
//
sl@0
   684
/*
sl@0
   685
?type  ?function_name(
sl@0
   686
    ?arg_type arg,  // ?description
sl@0
   687
    ?arg_type arg )  // ?description
sl@0
   688
    {
sl@0
   689
sl@0
   690
    ?code
sl@0
   691
sl@0
   692
    }
sl@0
   693
*/
sl@0
   694
//  [End of File] - do not remove