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