charconvfw/fatfilenameconversionplugins/test/T_CP54936.CPP
changeset 0 1fb32624e06b
child 51 a7c938434754
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32test.h>
       
    20 #include <e32des8.h>
       
    21 #include <hal.h>
       
    22 
       
    23 LOCAL_D RTest test(_L("T_CP54936.exe"));
       
    24 
       
    25 
       
    26 _LIT(KName,"CP54936");
       
    27 const TUid KPluginUid={0x1028703b};
       
    28 
       
    29 
       
    30 void TestOut(const TDesC16 &des)
       
    31 	{
       
    32 	for (TInt i=0; i<des.Length(); i++)
       
    33 		test.Printf(_L("%04X "), des[i]);
       
    34 	}
       
    35 
       
    36 void TestOut(const TDesC8 &des)
       
    37 	{
       
    38 	for (TInt i=0; i<des.Length(); i++)
       
    39 		test.Printf(_L("%02X "), des[i]);
       
    40 	}
       
    41 
       
    42 // Used for supressing warning in OOM tests
       
    43 #define __UNUSED_VAR(var) var = var
       
    44 
       
    45 /**
       
    46 @SYMTestCaseID          SYSLIB-FATCHARSETCONV-CT-1778
       
    47 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class
       
    48 @SYMTestPriority 	    High
       
    49 @SYMTestActions  	    Tests for conversions from/to Unicode, using a function pointer
       
    50 @SYMTestExpectedResults Test must not fail 
       
    51 */
       
    52 void Test()
       
    53 	{ 
       
    54 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1778 "));
       
    55 	RLibrary lib;
       
    56 
       
    57 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);	
       
    58 	// load the dll	
       
    59 	TInt returnValue = lib.Load(KName,serverUid);
       
    60 	test(returnValue==0);
       
    61 
       
    62 	// get a pointer to the specified ordinal function and call it	
       
    63 	TLibraryFunction function1 = lib.Lookup(1);
       
    64 	TLibraryFunction function2 = lib.Lookup(2);
       
    65 	TLibraryFunction function3 = lib.Lookup(3);
       
    66 
       
    67 	//cast the function pointer f to a function of type void with two arguments
       
    68 	typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);	
       
    69 	TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);
       
    70 	
       
    71 	typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&);	
       
    72 	TConvertToUnicodeL aConvertToUnicodeL = reinterpret_cast <TConvertToUnicodeL> (function2);
       
    73 	
       
    74 	typedef TBool (*TIsLegalShortNameCharacter)(TUint);	
       
    75 	TIsLegalShortNameCharacter aIsLegalShortNameCharacter = reinterpret_cast <TIsLegalShortNameCharacter> (function3);
       
    76 	
       
    77 	// from Test Analysis:
       
    78 	// p1:		0x40 -> 0x40
       
    79 	// p2:		0x24 -> 0x24
       
    80 	// p3:		0x706C -> 0xECE1
       
    81 	// p4:		0x4E96 -> 0x8181
       
    82 	// p5:		0x20AC -> 0xA2E3
       
    83 	// p6:		0x3622 -> 0x8230A730, 0x060C -> 0x81318132
       
    84 	// p7:		0x201AD (0xD840 0xDDAD) -> 0x9532AD35
       
    85 	// p10-p15:	N/A
       
    86 	// p20-p22: N/A
       
    87 	// p30:		0x32FF -> 0x8139D633
       
    88 	// p31:		0x10500 (0xD801 0xDD00) -> 0x90318330
       
    89 	//			0xFFFF -> 0x8431A439
       
    90 	_LIT16(Uni_1, "\x0040\xD840\x0024\x060C\x706C\x4E96\x20AC\x3622\xD840\xDDAD\x32FF\xD801\xDD00\xDC00\xFFFF");
       
    91 	_LIT8(CP54936_1, "\x40\x5F\x24\x81\x31\x81\x32\xEC\xE1\x81\x81\xA2\xE3\x82\x30\xA7\x30\x95\x32\xAD\x35\x81\x39\xD6\x33\x90\x31\x83\x30\x5F\x84\x31\xA4\x39");
       
    92 
       
    93 	TBuf8<200> foreign1;
       
    94 	TBuf16<200> unicode2;
       
    95 	
       
    96 	const TDesC16& unicode1(Uni_1);
       
    97 	test.Printf(_L("source: "));	TestOut(unicode1);	test.Printf(_L("\n"));
       
    98 	test.Printf(_L("expect: "));	TestOut(CP54936_1);	test.Printf(_L("\n"));
       
    99 	//TRAPD(err, (*aConvertFromUnicodeL)(foreign1, unicode1));
       
   100 	(*aConvertFromUnicodeL)(foreign1, unicode1); 	//testing conversion from Unicode
       
   101 	test.Printf(_L("result: "));	TestOut(foreign1);	test.Printf(_L("\n"));
       
   102 	TInt error = foreign1.Compare(CP54936_1);
       
   103 	test(error==0);
       
   104 	foreign1.Zero();
       
   105 
       
   106 	// from Test Analysis:
       
   107 	// p1:		0x40
       
   108 	// p2:		0x24
       
   109 	// p3:		0x706C <- 0xECE1
       
   110 	// p4:		0x4E96 <- 0x8181
       
   111 	// p5:		0x20AC <- 0xA2E3
       
   112 	// p6:		0x3622 <- 0x8230A730, 0x060C <- 0x81318132
       
   113 	// p7:		0x201AD (0xD840 0xDDAD) <- 0x9532AD35
       
   114 	// p10:		//0x0E -> 0xFFFD
       
   115 	// p11:		//0xA0 -> 0xFFFD
       
   116 	// p12:		0xA1A0 -> 0xE525
       
   117 	// p13:		0xA07F -> 0xFFFD
       
   118 	// p14:		0x95328230 -> 0x1FFFA (0xD83F 0xDFFA) //0xFFFD
       
   119 	// p15:		0x8130813A -> 0xFFFD
       
   120 	// p20-p22:	N/A
       
   121 	// p30-p31:	N/A
       
   122 	_LIT16(Uni_2, "\x0040\x0024\x706C\x4E96\x20AC\x3622\x060C\xD840\xDDAD\xE525\xFFFD\xD83F\xDFFA\xFFFD");
       
   123 	_LIT8(CP54936_2, "\x40\x24\xEC\xE1\x81\x81\xA2\xE3\x82\x30\xA7\x30\x81\x31\x81\x32\x95\x32\xAD\x35\xA1\xA0\xA0\x7F\x95\x32\x82\x30\x81\x30\x81\x3A");
       
   124 
       
   125 	const TDesC8& foreign2(CP54936_2);
       
   126 	test.Printf(_L("source: "));	TestOut(foreign2);	test.Printf(_L("\n"));
       
   127 	test.Printf(_L("expect: "));	TestOut(Uni_2);		test.Printf(_L("\n"));
       
   128 	//TRAP(err, (*aConvertToUnicodeL)(unicode2,foreign2));
       
   129 	(*aConvertToUnicodeL)(unicode2,foreign2);//); 	//testing conversion to Unicode
       
   130 	test.Printf(_L("result: "));	TestOut(unicode2);	test.Printf(_L("\n"));
       
   131 	error = unicode2.Compare(Uni_2);
       
   132 	test(error==0);
       
   133 	unicode2.Zero();
       
   134 	
       
   135 	
       
   136 	//testing for legal short name character
       
   137 	TInt result = (*aIsLegalShortNameCharacter)(0x005F); //testing for existent character
       
   138 	test(result==1);
       
   139 	result = (*aIsLegalShortNameCharacter)(0x003F); //testing for illegal character
       
   140 	test(result==0);
       
   141 	result = (*aIsLegalShortNameCharacter)(0x2999); 
       
   142 	test(result==1);
       
   143 	result = (*aIsLegalShortNameCharacter)(0x4E02); //testing for a double byte character
       
   144 	test(result==1);
       
   145 
       
   146 	lib.Close();
       
   147 	}
       
   148 
       
   149 /**
       
   150 @SYMTestCaseID          SYSLIB-FATCHARSETCONV-CT-1847-0001
       
   151 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class as part of INC090073
       
   152 @SYMTestPriority 	    High
       
   153 @SYMTestActions  	    Tests for correct character conversion on certain chinese characters for CP936 
       
   154 @SYMTestExpectedResults Test must not fail 
       
   155 */	
       
   156 void TestINC090073()
       
   157 	{
       
   158 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847-0001 ")); 
       
   159  	_LIT16(unicode, "\x7CCD\x74EF\x8026\x8F8F\x94F3\x7633\x6DFC\x9785\x7F81\x7A37\x61A9\x80B1\x86A3\x89E5\x80F2\x9B48\x9E47\x6C19\x7B71\x946B\x6B46\x6615");
       
   160 	_LIT8(CP932Code, "\xF4\xD9\xEA\xB1\xF1\xEE\xEA\xA3\xEF\xA5\xF1\xAC\xED\xB5\xF7\xB1\xEE\xBF\xF0\xA2\xED\xAC\xEB\xC5\xF2\xBC\xF6\xA1\xEB\xDC\xF7\xCC\xF0\xC2\xEB\xAF\xF3\xE3\xF6\xCE\xEC\xA7\xEA\xBF");
       
   161 
       
   162 	RLibrary lib;
       
   163 
       
   164 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);	
       
   165 	// load the dll	
       
   166 	TInt returnValue = lib.Load(KName,serverUid);
       
   167 	test(returnValue==0);
       
   168 
       
   169 	// get a pointer to the specified ordinal function and call it	
       
   170 	TLibraryFunction function1 = lib.Lookup(1);
       
   171 
       
   172 
       
   173 	//cast the function pointer f to a function of type void with two arguments
       
   174 	typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);	
       
   175 	TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);
       
   176 	
       
   177 	TBuf8<50> foreign1;
       
   178 	
       
   179 	foreign1.Zero();
       
   180 	const TDesC16& unicode1(unicode);
       
   181 	TRAPD(err,(*aConvertFromUnicodeL)(foreign1, unicode1)); 	//testing conversion from Unicode
       
   182 	test(err==0);
       
   183 	TInt error = foreign1.Compare(CP932Code);
       
   184 	test(error==0);
       
   185 	foreign1.Zero();
       
   186 
       
   187 	lib.Close();
       
   188 	}	
       
   189 
       
   190 void OOMTest()
       
   191 	{
       
   192 	test.Next(_L("OOM testing"));
       
   193 	TInt err, tryCount = 0;
       
   194 	do	
       
   195 		{
       
   196 			__UHEAP_MARK;
       
   197   		// find out the number of open handles
       
   198 		TInt startProcessHandleCount;
       
   199 		TInt startThreadHandleCount;
       
   200 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
   201 		
       
   202 			// Setting Heap failure for OOM test
       
   203 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
       
   204 
       
   205 		TRAP(err,Test());
       
   206 			
       
   207 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   208 		
       
   209 		// check that no handles have leaked
       
   210 		TInt endProcessHandleCount;
       
   211 		TInt endThreadHandleCount;
       
   212 		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
   213 
       
   214 		test(startProcessHandleCount == endProcessHandleCount);
       
   215 		test(startThreadHandleCount  == endThreadHandleCount);
       
   216 
       
   217 		__UHEAP_MARKEND;
       
   218 		}while (err == KErrNoMemory);
       
   219 		
       
   220 	test(err == KErrNone);
       
   221 	test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
       
   222 	}
       
   223 
       
   224 
       
   225 const TInt MaxCount = 10000;	// iteration number for performance tests
       
   226 
       
   227 // cp54936 should be faster than cp936
       
   228 _LIT(KName936,"CP936");
       
   229 const TUid KPluginUid936={0x10206A91};
       
   230 void PerformanceTest1()
       
   231 	{
       
   232 	test.Next(_L("Performance test 1 (comparing with cp936)"));
       
   233 	RLibrary lib936;
       
   234 	RLibrary lib54936;
       
   235 
       
   236 	const TUidType serverUid936(KNullUid,KNullUid,KPluginUid936);	
       
   237 	const TUidType serverUid54936(KNullUid,KNullUid,KPluginUid);
       
   238 	
       
   239 	// load the dll	
       
   240 	TInt returnValue = lib936.Load(KName936,serverUid936);
       
   241 	test(returnValue==0);
       
   242 	TInt returnValue2 = lib54936.Load(KName,serverUid54936);
       
   243 	test(returnValue2==0);
       
   244 
       
   245 	// get a pointer to the specified ordinal function and call it	
       
   246 	TLibraryFunction function9361 = lib936.Lookup(1);
       
   247 	TLibraryFunction function9362 = lib936.Lookup(2);
       
   248 	TLibraryFunction function9363 = lib936.Lookup(3);
       
   249 	TLibraryFunction function549361 = lib54936.Lookup(1);
       
   250 	TLibraryFunction function549362 = lib54936.Lookup(2);
       
   251 	TLibraryFunction function549363 = lib54936.Lookup(3);
       
   252 
       
   253 	//cast the function pointer f to a function of type void with two arguments
       
   254 	typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);
       
   255 	TConvertFromUnicodeL aConvertFromUnicode936L = reinterpret_cast <TConvertFromUnicodeL> (function9361);
       
   256 	TConvertFromUnicodeL aConvertFromUnicode54936L = reinterpret_cast <TConvertFromUnicodeL> (function549361);
       
   257 	
       
   258 	typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&);
       
   259 	TConvertToUnicodeL aConvertToUnicode936L = reinterpret_cast <TConvertToUnicodeL> (function9362);
       
   260 	TConvertToUnicodeL aConvertToUnicode54936L = reinterpret_cast <TConvertToUnicodeL> (function549362);
       
   261 
       
   262 	// timer
       
   263 	TInt count;
       
   264 	TChar res2;
       
   265 	TBuf<256> msg;
       
   266 	TInt fastTimerFreq;
       
   267 	HAL::Get(HALData::EFastCounterFrequency, fastTimerFreq);
       
   268 	TReal ticksPerMicroSec = 1.0E-6 * fastTimerFreq;
       
   269 	TUint prevTime;
       
   270 	TUint timeDiff;
       
   271 	TReal64 fsSessionMicroSecs;
       
   272 
       
   273 	_LIT16(Uni_1, "\x0053\x0059\x004D\x3125\x3122\x9673\xFA29");
       
   274 	_LIT8(CP54936_1, "\x53\x59\x4D\xA8\xE5\xA8\xE2\xEA\x90\xFE\x4F");
       
   275 	TBuf8<20> foreign1;
       
   276 	TBuf16<20> unicode2;
       
   277 	const TDesC16& unicode1(Uni_1);
       
   278 	TInt error;
       
   279 	
       
   280 //////////////////////////////////////////////////////////////////////////////
       
   281 //////////////////////////////////////////////////////////////////////////////
       
   282 	// 1, unicode -> 936
       
   283 	// test result: 1448 ms for 100000 iterations
       
   284 	test.Printf(_L("unicode --> 936:\n"));
       
   285 	test.Printf(_L("        source: "));	TestOut(unicode1);	test.Printf(_L("\n"));
       
   286 	test.Printf(_L("        expect: "));	TestOut(CP54936_1);	test.Printf(_L("\n"));
       
   287 	prevTime = User::FastCounter();
       
   288 	for (count=0; count<MaxCount; count++)
       
   289 		{
       
   290 		foreign1.Zero();
       
   291 		(*aConvertFromUnicode936L)(foreign1, unicode1);
       
   292 		}
       
   293 	timeDiff = User::FastCounter() - prevTime;
       
   294 	fsSessionMicroSecs = timeDiff / (ticksPerMicroSec);
       
   295 	msg.Format(_L("                    %10.2lf us, "), fsSessionMicroSecs);
       
   296 	test.Printf(_L("        result: "));	TestOut(foreign1);	test.Printf(_L("\n"));
       
   297 	test.Printf(msg);
       
   298 	error = foreign1.Compare(CP54936_1);
       
   299 	test(error==0);
       
   300 	foreign1.Zero();
       
   301 	test.Printf(_L("\n"));
       
   302 	
       
   303 	// 2, unicode -> 54936
       
   304 	// test result: 44 ms for 100000 iterations
       
   305 	test.Printf(_L("unicode --> 54936:\n"));
       
   306 	test.Printf(_L("        source: "));	TestOut(unicode1);	test.Printf(_L("\n"));
       
   307 	test.Printf(_L("        expect: "));	TestOut(CP54936_1);	test.Printf(_L("\n"));
       
   308 	prevTime = User::FastCounter();
       
   309 	for (count=0; count<MaxCount; count++)
       
   310 		{
       
   311 		foreign1.Zero();
       
   312 		(*aConvertFromUnicode54936L)(foreign1, unicode1);
       
   313 		}
       
   314 	timeDiff = User::FastCounter() - prevTime;
       
   315 	fsSessionMicroSecs = timeDiff / (ticksPerMicroSec);
       
   316 	msg.Format(_L("                    %10.2lf us, "), fsSessionMicroSecs);
       
   317 	test.Printf(_L("        result: "));	TestOut(foreign1);	test.Printf(_L("\n"));
       
   318 	test.Printf(msg);
       
   319 	error = foreign1.Compare(CP54936_1);
       
   320 	test(error==0);
       
   321 	foreign1.Zero();
       
   322 	test.Printf(_L("\n"));
       
   323 
       
   324 //////////////////////////////////////////////////////////////////////////////
       
   325 //////////////////////////////////////////////////////////////////////////////
       
   326 	_LIT16(Uni_2, "\x0032\xFFFD\x7FB1\x0032\xFFFD\x7FB1\x7FB1");
       
   327 	_LIT8(CP54936_2, "\x32\xC1\x7F\xC1\x7E\x32\xC1\x7F\xC1\x7E\xC1\x7E");
       
   328 	const TDesC8& foreign2(CP54936_2);
       
   329 
       
   330 	// 3, 936 -> unicode
       
   331 	// test result: 89 ms for 100000 iterations
       
   332 	test.Printf(_L("936 ---> unicode:\n"));
       
   333 	test.Printf(_L("        source: "));	TestOut(foreign2);	test.Printf(_L("\n"));
       
   334 	test.Printf(_L("        expect: "));	TestOut(Uni_2);		test.Printf(_L("\n"));
       
   335 	prevTime = User::FastCounter();
       
   336 	for (count=0; count<MaxCount; count++)
       
   337 		{
       
   338 		unicode2.Zero();
       
   339 		(*aConvertToUnicode936L)(unicode2,foreign2);
       
   340 		}
       
   341 	timeDiff = User::FastCounter() - prevTime;
       
   342 	fsSessionMicroSecs = timeDiff / (ticksPerMicroSec);
       
   343 	msg.Format(_L("                    %10.2lf us, "), fsSessionMicroSecs);
       
   344 	test.Printf(_L("        result: "));	TestOut(unicode2);	test.Printf(_L("\n"));
       
   345 	test.Printf(msg);
       
   346 	error = unicode2.Compare(Uni_2);
       
   347 	test(error==0);
       
   348 	unicode2.Zero();
       
   349 	test.Printf(_L("\n"));
       
   350 
       
   351 	// 4, 54936 -> unicode
       
   352 	// test result: 36 ms for 100000 iterations
       
   353 	test.Printf(_L("54936 ---> unicode:\n"));
       
   354 	test.Printf(_L("        source: "));	TestOut(foreign2);	test.Printf(_L("\n"));
       
   355 	test.Printf(_L("        expect: "));	TestOut(Uni_2);		test.Printf(_L("\n"));
       
   356 	prevTime = User::FastCounter();
       
   357 	for (count=0; count<MaxCount; count++)
       
   358 		{
       
   359 		unicode2.Zero();
       
   360 		(*aConvertToUnicode54936L)(unicode2,foreign2);
       
   361 		}
       
   362 	timeDiff = User::FastCounter() - prevTime;
       
   363 	fsSessionMicroSecs = timeDiff / (ticksPerMicroSec);
       
   364 	msg.Format(_L("                    %10.2lf us, "), fsSessionMicroSecs);
       
   365 	test.Printf(_L("        result: "));	TestOut(unicode2);	test.Printf(_L("\n"));
       
   366 	test.Printf(msg);
       
   367 	error = unicode2.Compare(Uni_2);
       
   368 	test(error==0);
       
   369 	unicode2.Zero();
       
   370 	test.Printf(_L("\n"));
       
   371 	
       
   372 	lib936.Close();
       
   373 	lib54936.Close();
       
   374 	
       
   375 //	test.Printf(_L("Press any key...\n"));
       
   376 //	test.Getch();
       
   377 	}
       
   378 
       
   379 
       
   380 // performance when converting mixed data.
       
   381 // just for reference.
       
   382 // ideally, the test result should be similar to that in PerformanceTest1()
       
   383 void PerformanceTest2()
       
   384 	{
       
   385 	test.Next(_L("Performance test 2 (reference)"));
       
   386 	RLibrary lib54936;
       
   387 	const TUidType serverUid54936(KNullUid,KNullUid,KPluginUid);
       
   388 	
       
   389 	// load the dll	
       
   390 	TInt returnValue2 = lib54936.Load(KName,serverUid54936);
       
   391 	test(returnValue2==0);
       
   392 
       
   393 	// get a pointer to the specified ordinal function and call it	
       
   394 	TLibraryFunction function549361 = lib54936.Lookup(1);
       
   395 	TLibraryFunction function549362 = lib54936.Lookup(2);
       
   396 	TLibraryFunction function549363 = lib54936.Lookup(3);
       
   397 
       
   398 	//cast the function pointer f to a function of type void with two arguments
       
   399 	typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);
       
   400 	TConvertFromUnicodeL aConvertFromUnicode54936L = reinterpret_cast <TConvertFromUnicodeL> (function549361);
       
   401 	
       
   402 	typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&);
       
   403 	TConvertToUnicodeL aConvertToUnicode54936L = reinterpret_cast <TConvertToUnicodeL> (function549362);
       
   404 
       
   405 	// timer
       
   406 	TInt count;
       
   407 	TBuf<256> msg;
       
   408 	TInt fastTimerFreq;
       
   409 	HAL::Get(HALData::EFastCounterFrequency, fastTimerFreq);
       
   410 	TReal ticksPerMicroSec = 1.0E-6 * fastTimerFreq;
       
   411 	TUint prevTime;
       
   412 	TUint timeDiff;
       
   413 	TReal64 fsSessionMicroSecs;
       
   414 
       
   415 //////////////////////////////////////////////////////////////////////////////
       
   416 //////////////////////////////////////////////////////////////////////////////
       
   417 	_LIT16(Uni_1, "\x0053\x0059\x004D\x3125\x3122\x9673\xFA29\x060C\xD840\xDC00");
       
   418 	_LIT8(CP54936_1, "\x53\x59\x4D\xA8\xE5\xA8\xE2\xEA\x90\xFE\x4F\x81\x31\x81\x32\x95\x32\x82\x36");
       
   419 	TBuf8<200> foreign1;
       
   420 	TBuf16<200> unicode2;
       
   421 	const TDesC16& unicode1(Uni_1);
       
   422 	TInt error;
       
   423 
       
   424 	// 2, unicode -> 54936
       
   425 	// test result: 130 ms for 100000 iterations (44 ms if one huge table for BMP characters)
       
   426 	test.Printf(_L("unicode --> 54936:\n"));
       
   427 	test.Printf(_L("        source: "));	TestOut(unicode1);	test.Printf(_L("\n"));
       
   428 	test.Printf(_L("        expect: "));	TestOut(CP54936_1);	test.Printf(_L("\n"));
       
   429 	prevTime = User::FastCounter();
       
   430 	for (count=0; count<MaxCount; count++)
       
   431 		{
       
   432 		foreign1.Zero();
       
   433 		(*aConvertFromUnicode54936L)(foreign1, unicode1);
       
   434 		}
       
   435 	timeDiff = User::FastCounter() - prevTime;
       
   436 	fsSessionMicroSecs = timeDiff / (ticksPerMicroSec);
       
   437 	msg.Format(_L("                    %10.2lf us, "), fsSessionMicroSecs);
       
   438 	test.Printf(_L("        result: "));	TestOut(foreign1);	test.Printf(_L("\n"));
       
   439 	test.Printf(msg);
       
   440 	error = foreign1.Compare(CP54936_1);
       
   441 	test(error==0);
       
   442 	foreign1.Zero();
       
   443 	test.Printf(_L("\n"));
       
   444 
       
   445 //////////////////////////////////////////////////////////////////////////////
       
   446 //////////////////////////////////////////////////////////////////////////////
       
   447 	_LIT16(Uni_2, "\x0032\x20AC\xFFFD\x7FB1\x47BB\xD840\xDC00");
       
   448 	_LIT8(CP54936_2, "\x32\xA2\xE3\xC1\x7F\xC1\x7E\x82\x33\xED\x33\x95\x32\x82\x36");
       
   449 	const TDesC8& foreign2(CP54936_2);
       
   450 
       
   451 	// 4, 54936 -> unicode
       
   452 	// test result: 36 ms for 100000 iterations
       
   453 	test.Printf(_L("54936 ---> unicode:\n"));
       
   454 	test.Printf(_L("        source: "));	TestOut(foreign2);	test.Printf(_L("\n"));
       
   455 	test.Printf(_L("        expect: "));	TestOut(Uni_2);		test.Printf(_L("\n"));
       
   456 	prevTime = User::FastCounter();
       
   457 	for (count=0; count<MaxCount; count++)
       
   458 		{
       
   459 		unicode2.Zero();
       
   460 		(*aConvertToUnicode54936L)(unicode2,foreign2);
       
   461 		}
       
   462 	timeDiff = User::FastCounter() - prevTime;
       
   463 	fsSessionMicroSecs = timeDiff / (ticksPerMicroSec);
       
   464 	msg.Format(_L("                    %10.2lf us, "), fsSessionMicroSecs);
       
   465 	test.Printf(_L("        result: "));	TestOut(unicode2);	test.Printf(_L("\n"));
       
   466 	test.Printf(msg);
       
   467 	error = unicode2.Compare(Uni_2);
       
   468 	test(error==0);
       
   469 	unicode2.Zero();
       
   470 	test.Printf(_L("\n"));
       
   471 	
       
   472 	lib54936.Close();
       
   473 	
       
   474 //	test.Printf(_L("Press any key...\n"));
       
   475 //	test.Getch();
       
   476 	}
       
   477 
       
   478 /**
       
   479 @SYMTestCaseID          TI18N-FATCHARCONV-CIT-4001
       
   480 @SYMTestCaseDesc        Check GB18030 support 
       
   481 @SYMTestPriority        High
       
   482 @SYMTestActions         1. Get one-byte Unicode codepoint
       
   483                         2. Convert to/from GB18030 to/from Unicode
       
   484                         3. Get two-byte Unicode codepoint
       
   485                         4. Convert to/from GB18030 to/from Unicode
       
   486                         5. Get four-byte Unicode codepoint
       
   487                         6. Convert to/from GB18030 to/from Unicode
       
   488 @SYMTestExpectedResults No side effect
       
   489 @SYMREQ                 REQ12067
       
   490 */
       
   491 LOCAL_C void TestConversion( const TDesC16& aUnicode, const TDesC8& a54936, TBool aZero1=ETrue, TBool aZero2=ETrue )
       
   492 {
       
   493 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1778 "));
       
   494 	RLibrary lib;
       
   495 
       
   496 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);	
       
   497 	// load the dll	
       
   498 	TInt returnValue = lib.Load(KName,serverUid);
       
   499 	test(returnValue==0);
       
   500 
       
   501 	// get a pointer to the specified ordinal function and call it	
       
   502 	TLibraryFunction function1 = lib.Lookup(1);
       
   503 	TLibraryFunction function2 = lib.Lookup(2);
       
   504 	TLibraryFunction function3 = lib.Lookup(3);
       
   505 
       
   506 	//cast the function pointer f to a function of type void with two arguments
       
   507 	typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);	
       
   508 	TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);
       
   509 	
       
   510 	typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&);	
       
   511 	TConvertToUnicodeL aConvertToUnicodeL = reinterpret_cast <TConvertToUnicodeL> (function2);
       
   512 	
       
   513 	//	testing conversion from Unicode
       
   514 	TBuf8<200> generated54936;
       
   515 	test.Printf(_L("source: "));	
       
   516 	TestOut(aUnicode);	
       
   517 	test.Printf(_L("\n"));
       
   518 	test.Printf(_L("expect: "));	
       
   519 	TestOut(a54936);	
       
   520 	test.Printf(_L("\n"));
       
   521 	(*aConvertFromUnicodeL)(generated54936, aUnicode); 	
       
   522 	test.Printf(_L("result: "));	
       
   523 	TestOut(generated54936);	
       
   524 	test.Printf(_L("\n"));
       
   525 	TInt error = generated54936.Compare(a54936);
       
   526 	if ( aZero1 )
       
   527 	{
       
   528 		test(error==0);
       
   529 	}
       
   530 	else
       
   531 	{
       
   532 		test(error!=0);
       
   533 	}
       
   534 
       
   535 	//	testing conversion to Unicode
       
   536 	TBuf16<200> generatedUnicode;
       
   537 	test.Printf(_L("source: "));	
       
   538 	TestOut(a54936);	
       
   539 	test.Printf(_L("\n"));
       
   540 	test.Printf(_L("expect: "));	
       
   541 	TestOut(aUnicode);		
       
   542 	test.Printf(_L("\n"));
       
   543 	(*aConvertToUnicodeL)(generatedUnicode,a54936);
       
   544 	test.Printf(_L("result: "));	
       
   545 	TestOut(generatedUnicode);	
       
   546 	test.Printf(_L("\n"));
       
   547 	error = generatedUnicode.Compare(aUnicode);
       
   548 	if ( aZero2 )
       
   549 	{
       
   550 		test(error==0);
       
   551 	}
       
   552 	else
       
   553 	{
       
   554 		test(error!=0);
       
   555 	}
       
   556 	
       
   557 	lib.Close();
       
   558 }
       
   559 
       
   560 
       
   561 /**
       
   562 @SYMTestCaseID          TI18N-CHARCONV-CT-
       
   563 @SYMTestCaseDesc        Check GB18030 support 
       
   564 @SYMTestPriority        High
       
   565 @SYMTestActions         1. Get one-byte Unicode codepoint
       
   566 						2. Convert to/from GB18030 to/from Unicode
       
   567 						3. Get two-byte Unicode codepoint
       
   568 						4. Convert to/from GB18030 to/from Unicode
       
   569 						5. Get four-byte Unicode codepoint
       
   570 						6. Convert to/from GB18030 to/from Unicode
       
   571 @SYMTestExpectedResults No side effect
       
   572 @SYMREQ                 REQ12067
       
   573 */
       
   574 LOCAL_C void TestGbConversion()
       
   575 {
       
   576 	//	Test() function covers GB 1,2,4 bytes
       
   577 	//	one-byte
       
   578 	//	border 0x80
       
   579 	_LIT16(Uni_0, "\x0000");
       
   580 	_LIT8(CP54936_0, "\x00");
       
   581 	TestConversion( Uni_0, CP54936_0 );		
       
   582 
       
   583 	_LIT16(Uni_1, "\x0079");
       
   584 	_LIT8(CP54936_1, "\x79");
       
   585 	TestConversion( Uni_1, CP54936_1 );		
       
   586 
       
   587 	_LIT16(Uni_2, "\x0080");
       
   588 	_LIT8(CP54936_2, "\x81\x30\x81\x30");
       
   589 	TestConversion( Uni_2, CP54936_2 );		
       
   590 
       
   591 	_LIT16(Uni_3, "\x0081");
       
   592 	_LIT8(CP54936_3, "\x81\x30\x81\x31");
       
   593 	TestConversion( Uni_3, CP54936_3 );		
       
   594 	
       
   595 	_LIT16(Uni_4, "\x00fe");
       
   596 	_LIT8(CP54936_4, "\x81\x30\x8B\x36");
       
   597 	TestConversion( Uni_4, CP54936_4 );		
       
   598 
       
   599 	_LIT16(Uni_5, "\x00ff");
       
   600 	_LIT8(CP54936_5, "\x81\x30\x8B\x37");
       
   601 	TestConversion( Uni_5, CP54936_5 );		
       
   602 
       
   603 	//	two-byte
       
   604 	_LIT16(Uni_6, "\x0100");
       
   605 	_LIT8(CP54936_6, "\x81\x30\x8B\x38");
       
   606 	TestConversion( Uni_6, CP54936_6 );	
       
   607 
       
   608 	_LIT16(Uni_7, "\x0101");
       
   609 	_LIT8(CP54936_7, "\xA8\xA1");
       
   610 	TestConversion( Uni_7, CP54936_7 );	
       
   611 
       
   612 	_LIT16(Uni_8, "\x0ffe");
       
   613 	_LIT8(CP54936_8, "\x81\x33\x83\x38");
       
   614 	TestConversion( Uni_8, CP54936_8 );	
       
   615 
       
   616 	_LIT16(Uni_9, "\x0fff");
       
   617 	_LIT8(CP54936_9, "\x81\x33\x83\x39");
       
   618 	TestConversion( Uni_9, CP54936_9 );	
       
   619 
       
   620 	_LIT16(Uni_10, "\x1000");
       
   621 	_LIT8(CP54936_10, "\x81\x33\x84\x30");
       
   622 	TestConversion( Uni_10, CP54936_10 );	
       
   623 
       
   624 	_LIT16(Uni_11, "\x1001");
       
   625 	_LIT8(CP54936_11, "\x81\x33\x84\x31");
       
   626 	TestConversion( Uni_11, CP54936_11 );	
       
   627 
       
   628 	_LIT16(Uni_12, "\xfffe");
       
   629 	_LIT8(CP54936_12, "\x84\x31\xA4\x38");
       
   630 	TestConversion( Uni_12, CP54936_12 );	
       
   631 
       
   632 	_LIT16(Uni_13, "\xffff");
       
   633 	_LIT8(CP54936_13, "\x84\x31\xA4\x39");
       
   634 	TestConversion( Uni_13, CP54936_13 );	
       
   635 
       
   636 	//	four-byte
       
   637 	_LIT16(Uni_14, "\xd840\xdc00");
       
   638 	_LIT8(CP54936_14, "\x95\x32\x82\x36");
       
   639 	TestConversion( Uni_14, CP54936_14 );	
       
   640 
       
   641 	_LIT16(Uni_15, "\xd840\xdc01");
       
   642 	_LIT8(CP54936_15, "\x95\x32\x82\x37");
       
   643 	TestConversion( Uni_15, CP54936_15 );	
       
   644 	
       
   645 	_LIT16(Uni_16, "\xD87F\xdffe");
       
   646 	_LIT8(CP54936_16, "\x9a\x34\x84\x30");
       
   647 	TestConversion( Uni_16, CP54936_16 );	
       
   648 
       
   649 	_LIT16(Uni_17, "\xD87F\xdfff");
       
   650 	_LIT8(CP54936_17, "\x9a\x34\x84\x31");
       
   651 	TestConversion( Uni_17, CP54936_17 );	
       
   652 
       
   653 	//	4-byte gb
       
   654 	_LIT16(Uni_18, "\xd840\xddad");
       
   655 	_LIT8(CP54936_18, "\x95\x32\xAD\x35");
       
   656 	TestConversion( Uni_18, CP54936_18 );	
       
   657 	
       
   658 	_LIT16(Uni_19, "\xd801\xdd00");
       
   659 	_LIT8(CP54936_19, "\x90\x31\x83\x30");
       
   660 	TestConversion( Uni_19, CP54936_19 );	
       
   661 }
       
   662 
       
   663 
       
   664 /**
       
   665 @SYMTestCaseID          TI18N-CHARCONV-CT-
       
   666 @SYMTestCaseDesc        Test FAT short name legal character
       
   667 @SYMTestPriority        High
       
   668 @SYMTestActions         1. Get one-byte Unicode codepoint
       
   669 						2. Check if it's legal short name character
       
   670 						3. Get two-byte Unicode codepoint
       
   671 						4. Check if it's legal short name character
       
   672 						5. Get four-byte Unicode codepoint
       
   673 						6. Check if it's legal short name character
       
   674 @SYMTestExpectedResults No side effect
       
   675 @SYMREQ                 REQ12067
       
   676 */
       
   677 LOCAL_C void TestShortNameCharacter()
       
   678 {
       
   679 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1778 "));
       
   680 	RLibrary lib;
       
   681 
       
   682 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);	
       
   683 	// 	load the dll	
       
   684 	TInt returnValue = lib.Load(KName,serverUid);
       
   685 	test(returnValue==0);
       
   686 
       
   687 	// 	get a pointer to the specified ordinal function and call it	
       
   688 	TLibraryFunction function1 = lib.Lookup(1);
       
   689 	TLibraryFunction function2 = lib.Lookup(2);
       
   690 	TLibraryFunction function3 = lib.Lookup(3);
       
   691 
       
   692 	typedef TBool (*TIsLegalShortNameCharacter)(TUint);	
       
   693 	TIsLegalShortNameCharacter aIsLegalShortNameCharacter = reinterpret_cast <TIsLegalShortNameCharacter> (function3);
       
   694 		
       
   695 	//	testing for legal short name character
       
   696 	//	one-byte unicode
       
   697 	//	0x20 is space
       
   698 	TInt result = (*aIsLegalShortNameCharacter)(0x0019); 
       
   699 	test(result==0);
       
   700 
       
   701 	result = (*aIsLegalShortNameCharacter)(0x0020); 
       
   702 	test(result==0);
       
   703 
       
   704 	result = (*aIsLegalShortNameCharacter)(0x0021); 
       
   705 	test(result==1);
       
   706 
       
   707 	result = (*aIsLegalShortNameCharacter)(0x005F); 
       
   708 	test(result==1);
       
   709 
       
   710 	//	0x80 is ascii border
       
   711 	result = (*aIsLegalShortNameCharacter)(0x0079); 
       
   712 	test(result==1);
       
   713 
       
   714 	result = (*aIsLegalShortNameCharacter)(0x0080); 
       
   715 	test(result==1);
       
   716 
       
   717 	result = (*aIsLegalShortNameCharacter)(0x0081); 
       
   718 	test(result==1);
       
   719 
       
   720 	//	testing for illegal character
       
   721 	result = (*aIsLegalShortNameCharacter)(0x003F); 
       
   722 	test(result==0);
       
   723 
       
   724 	result = (*aIsLegalShortNameCharacter)(0x22); 
       
   725 	test(result==0);
       
   726 
       
   727 	result = (*aIsLegalShortNameCharacter)(0x2A); 
       
   728 	test(result==0);
       
   729 
       
   730 	result = (*aIsLegalShortNameCharacter)(0x2B); 
       
   731 	test(result==0);
       
   732 
       
   733 	result = (*aIsLegalShortNameCharacter)(0x2C); 
       
   734 	test(result==0);
       
   735 
       
   736 	result = (*aIsLegalShortNameCharacter)(0x2F); 
       
   737 	test(result==0);
       
   738 
       
   739 	result = (*aIsLegalShortNameCharacter)(0x3A); 
       
   740 	test(result==0);
       
   741 
       
   742 	result = (*aIsLegalShortNameCharacter)(0x3B); 
       
   743 	test(result==0);
       
   744 
       
   745 	result = (*aIsLegalShortNameCharacter)(0x3C); 
       
   746 	test(result==0);
       
   747 
       
   748 	result = (*aIsLegalShortNameCharacter)(0x3D); 
       
   749 	test(result==0);
       
   750 
       
   751 	result = (*aIsLegalShortNameCharacter)(0x3E); 
       
   752 	test(result==0);
       
   753 
       
   754 	result = (*aIsLegalShortNameCharacter)(0x5B); 
       
   755 	test(result==0);
       
   756 
       
   757 	result = (*aIsLegalShortNameCharacter)(0x5C); 
       
   758 	test(result==0);
       
   759 
       
   760 	result = (*aIsLegalShortNameCharacter)(0x5D); 
       
   761 	test(result==0);
       
   762 
       
   763 	result = (*aIsLegalShortNameCharacter)(0x7C); 
       
   764 	test(result==0);
       
   765 
       
   766 	//	two-byte unicode
       
   767 	result = (*aIsLegalShortNameCharacter)(0x1000); 
       
   768 	test(result==1);
       
   769 
       
   770 	result = (*aIsLegalShortNameCharacter)(0x1001); 
       
   771 	test(result==1);
       
   772 
       
   773 	result = (*aIsLegalShortNameCharacter)(0x2999); //testing for non-existent character
       
   774 	test(result==1);
       
   775 
       
   776 	result = (*aIsLegalShortNameCharacter)(0x4E02); //testing for a double byte character
       
   777 	test(result==1);
       
   778 
       
   779 	result = (*aIsLegalShortNameCharacter)(0xfffe); 
       
   780 	test(result==1);
       
   781 
       
   782 	result = (*aIsLegalShortNameCharacter)(0xffff); 
       
   783 	test(result==1);
       
   784 
       
   785 	result = (*aIsLegalShortNameCharacter)(0xd7ff); 
       
   786 	test(result==1);
       
   787 
       
   788 	//	surrogate part
       
   789 	result = (*aIsLegalShortNameCharacter)(0xd800); 
       
   790 	test(result==0);
       
   791 	
       
   792 	result = (*aIsLegalShortNameCharacter)(0xdfff); 
       
   793 	test(result==0);
       
   794 
       
   795 	result = (*aIsLegalShortNameCharacter)(0xe000); 
       
   796 	test(result==1);
       
   797 
       
   798 	//	four-byte unicode
       
   799 	result = (*aIsLegalShortNameCharacter)(0x10000); 
       
   800 	test(result==1);
       
   801 
       
   802 	result = (*aIsLegalShortNameCharacter)(0x10001); 
       
   803 	test(result==1);
       
   804 
       
   805 	result = (*aIsLegalShortNameCharacter)(0x10fffe); 
       
   806 	test(result==1);
       
   807 
       
   808 	result = (*aIsLegalShortNameCharacter)(0x10ffff); 
       
   809 	test(result==1);
       
   810 
       
   811 	result = (*aIsLegalShortNameCharacter)(0x110000); 
       
   812 	test(result==0);
       
   813 
       
   814 	lib.Close();
       
   815 }
       
   816 
       
   817 
       
   818 LOCAL_C void DoE32MainL()
       
   819 	{
       
   820 	__UHEAP_MARK;
       
   821 	
       
   822 	TestGbConversion();
       
   823 	TestShortNameCharacter();
       
   824 	Test();
       
   825 	TestINC090073();
       
   826 	OOMTest();
       
   827 	PerformanceTest1();
       
   828 	PerformanceTest2();
       
   829 	
       
   830 	__UHEAP_MARKEND;
       
   831 	}
       
   832 
       
   833 GLDEF_C TInt E32Main()
       
   834 	{
       
   835 	__UHEAP_MARK;
       
   836 
       
   837 	test.Title();
       
   838 	test.Start(_L("CP54936 test..."));
       
   839 
       
   840 	CTrapCleanup* trapCleanup=CTrapCleanup::New();
       
   841 	TRAPD(error, DoE32MainL());
       
   842 	test(error==KErrNone);
       
   843 	
       
   844 	delete trapCleanup;
       
   845 	
       
   846 	test.End();
       
   847 	test.Close();
       
   848 
       
   849 	__UHEAP_MARKEND;
       
   850 	return error;
       
   851 	}