sl@0: /* sl@0: * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "T_CP54936.h" sl@0: #include sl@0: #include sl@0: sl@0: #define test(cond) \ sl@0: { \ sl@0: TBool __bb = (cond); \ sl@0: TEST(__bb); \ sl@0: if (!__bb) \ sl@0: { \ sl@0: ERR_PRINTF1(_L("ERROR: Test Failed")); \ sl@0: User::Leave(1); \ sl@0: } \ sl@0: } sl@0: sl@0: sl@0: const TInt MaxCount = 10000; // iteration number for performance tests sl@0: sl@0: // cp54936 should be faster than cp936 sl@0: _LIT(KName936,"CP936"); sl@0: const TUid KPluginUid936={0x10206A91}; sl@0: sl@0: sl@0: _LIT(KName,"CP54936"); sl@0: const TUid KPluginUid={0x1028703b}; sl@0: sl@0: sl@0: void CT_CP54936::TestOut(const TDesC16 &des) sl@0: { sl@0: for (TInt i=0; i (function1); sl@0: sl@0: typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&); sl@0: TConvertToUnicodeL aConvertToUnicodeL = reinterpret_cast (function2); sl@0: sl@0: typedef TBool (*TIsLegalShortNameCharacter)(TUint); sl@0: TIsLegalShortNameCharacter aIsLegalShortNameCharacter = reinterpret_cast (function3); sl@0: sl@0: // from Test Analysis: sl@0: // p1: 0x40 -> 0x40 sl@0: // p2: 0x24 -> 0x24 sl@0: // p3: 0x706C -> 0xECE1 sl@0: // p4: 0x4E96 -> 0x8181 sl@0: // p5: 0x20AC -> 0xA2E3 sl@0: // p6: 0x3622 -> 0x8230A730, 0x060C -> 0x81318132 sl@0: // p7: 0x201AD (0xD840 0xDDAD) -> 0x9532AD35 sl@0: // p10-p15: N/A sl@0: // p20-p22: N/A sl@0: // p30: 0x32FF -> 0x8139D633 sl@0: // p31: 0x10500 (0xD801 0xDD00) -> 0x90318330 sl@0: // 0xFFFF -> 0x8431A439 sl@0: _LIT16(Uni_1, "\x0040\xD840\x0024\x060C\x706C\x4E96\x20AC\x3622\xD840\xDDAD\x32FF\xD801\xDD00\xDC00\xFFFF"); sl@0: _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"); sl@0: sl@0: TBuf8<200> foreign1; sl@0: TBuf16<200> unicode2; sl@0: sl@0: const TDesC16& unicode1(Uni_1); sl@0: INFO_PRINTF1(_L("source: ")); TestOut(unicode1); INFO_PRINTF1(_L("\n")); sl@0: INFO_PRINTF1(_L("expect: ")); TestOut(CP54936_1); INFO_PRINTF1(_L("\n")); sl@0: //TRAPD(err, (*aConvertFromUnicodeL)(foreign1, unicode1)); sl@0: (*aConvertFromUnicodeL)(foreign1, unicode1); //testing conversion from Unicode sl@0: INFO_PRINTF1(_L("result: ")); TestOut(foreign1); INFO_PRINTF1(_L("\n")); sl@0: TInt error = foreign1.Compare(CP54936_1); sl@0: test(error==0); sl@0: foreign1.Zero(); sl@0: sl@0: // from Test Analysis: sl@0: // p1: 0x40 sl@0: // p2: 0x24 sl@0: // p3: 0x706C <- 0xECE1 sl@0: // p4: 0x4E96 <- 0x8181 sl@0: // p5: 0x20AC <- 0xA2E3 sl@0: // p6: 0x3622 <- 0x8230A730, 0x060C <- 0x81318132 sl@0: // p7: 0x201AD (0xD840 0xDDAD) <- 0x9532AD35 sl@0: // p10: //0x0E -> 0xFFFD sl@0: // p11: //0xA0 -> 0xFFFD sl@0: // p12: 0xA1A0 -> 0xE525 sl@0: // p13: 0xA07F -> 0xFFFD sl@0: // p14: 0x95328230 -> 0x1FFFA (0xD83F 0xDFFA) //0xFFFD sl@0: // p15: 0x8130813A -> 0xFFFD sl@0: // p20-p22: N/A sl@0: // p30-p31: N/A sl@0: _LIT16(Uni_2, "\x0040\x0024\x706C\x4E96\x20AC\x3622\x060C\xD840\xDDAD\xE525\xFFFD\xD83F\xDFFA\xFFFD"); sl@0: _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"); sl@0: sl@0: const TDesC8& foreign2(CP54936_2); sl@0: INFO_PRINTF1(_L("source: ")); TestOut(foreign2); INFO_PRINTF1(_L("\n")); sl@0: INFO_PRINTF1(_L("expect: ")); TestOut(Uni_2); INFO_PRINTF1(_L("\n")); sl@0: //TRAP(err, (*aConvertToUnicodeL)(unicode2,foreign2)); sl@0: (*aConvertToUnicodeL)(unicode2,foreign2);//); //testing conversion to Unicode sl@0: INFO_PRINTF1(_L("result: ")); TestOut(unicode2); INFO_PRINTF1(_L("\n")); sl@0: error = unicode2.Compare(Uni_2); sl@0: test(error==0); sl@0: unicode2.Zero(); sl@0: sl@0: sl@0: //testing for legal short name character sl@0: TInt result = (*aIsLegalShortNameCharacter)(0x005F); //testing for existent character sl@0: test(result==1); sl@0: result = (*aIsLegalShortNameCharacter)(0x003F); //testing for illegal character sl@0: test(result==0); sl@0: result = (*aIsLegalShortNameCharacter)(0x2999); sl@0: test(result==1); sl@0: result = (*aIsLegalShortNameCharacter)(0x4E02); //testing for a double byte character sl@0: test(result==1); sl@0: sl@0: lib.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FATCHARSETCONV-CT-1847-0001 sl@0: @SYMTestCaseDesc Tests API behaviours of UnicodeConv class as part of INC090073 sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for correct character conversion on certain chinese characters for CP936 sl@0: @SYMTestExpectedResults Test must not fail sl@0: */ sl@0: void CT_CP54936::TestINC090073L() sl@0: { sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847-0001 ")); sl@0: sl@0: _LIT16(unicode, "\x7CCD\x74EF\x8026\x8F8F\x94F3\x7633\x6DFC\x9785\x7F81\x7A37\x61A9\x80B1\x86A3\x89E5\x80F2\x9B48\x9E47\x6C19\x7B71\x946B\x6B46\x6615"); sl@0: _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"); sl@0: sl@0: RLibrary lib; sl@0: sl@0: const TUidType serverUid(KNullUid,KNullUid,KPluginUid); sl@0: // load the dll sl@0: TInt returnValue = lib.Load(KName,serverUid); sl@0: test(returnValue==0); sl@0: sl@0: // get a pointer to the specified ordinal function and call it sl@0: TLibraryFunction function1 = lib.Lookup(1); sl@0: sl@0: sl@0: //cast the function pointer f to a function of type void with two arguments sl@0: typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&); sl@0: TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast (function1); sl@0: sl@0: TBuf8<50> foreign1; sl@0: sl@0: foreign1.Zero(); sl@0: const TDesC16& unicode1(unicode); sl@0: TRAPD(err,(*aConvertFromUnicodeL)(foreign1, unicode1)); //testing conversion from Unicode sl@0: test(err==0); sl@0: TInt error = foreign1.Compare(CP932Code); sl@0: test(error==0); sl@0: foreign1.Zero(); sl@0: sl@0: lib.Close(); sl@0: } sl@0: sl@0: void CT_CP54936::OOMTestL() sl@0: { sl@0: INFO_PRINTF1(_L("OOM testing")); sl@0: TInt err, tryCount = 0; sl@0: do sl@0: { sl@0: __UHEAP_MARK; sl@0: // find out the number of open handles sl@0: TInt startProcessHandleCount; sl@0: TInt startThreadHandleCount; sl@0: RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); sl@0: sl@0: // Setting Heap failure for OOM test sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount); sl@0: sl@0: TRAP(err,TestL()); sl@0: sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: sl@0: // check that no handles have leaked sl@0: TInt endProcessHandleCount; sl@0: TInt endThreadHandleCount; sl@0: RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); sl@0: sl@0: test(startProcessHandleCount == endProcessHandleCount); sl@0: test(startThreadHandleCount == endThreadHandleCount); sl@0: sl@0: __UHEAP_MARKEND; sl@0: }while (err == KErrNoMemory); sl@0: sl@0: test(err == KErrNone); sl@0: INFO_PRINTF2(_L("- server succeeded at heap failure rate of %i\n"), tryCount); sl@0: } sl@0: sl@0: sl@0: void CT_CP54936::PerformanceTest1L() sl@0: { sl@0: INFO_PRINTF1(_L("Performance test 1 (comparing with cp936)")); sl@0: RLibrary lib936; sl@0: RLibrary lib54936; sl@0: sl@0: const TUidType serverUid936(KNullUid,KNullUid,KPluginUid936); sl@0: const TUidType serverUid54936(KNullUid,KNullUid,KPluginUid); sl@0: sl@0: // load the dll sl@0: TInt returnValue = lib936.Load(KName936,serverUid936); sl@0: test(returnValue==0); sl@0: TInt returnValue2 = lib54936.Load(KName,serverUid54936); sl@0: test(returnValue2==0); sl@0: sl@0: // get a pointer to the specified ordinal function and call it sl@0: TLibraryFunction function9361 = lib936.Lookup(1); sl@0: TLibraryFunction function9362 = lib936.Lookup(2); sl@0: TLibraryFunction function9363 = lib936.Lookup(3); sl@0: TLibraryFunction function549361 = lib54936.Lookup(1); sl@0: TLibraryFunction function549362 = lib54936.Lookup(2); sl@0: TLibraryFunction function549363 = lib54936.Lookup(3); sl@0: sl@0: //cast the function pointer f to a function of type void with two arguments sl@0: typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&); sl@0: TConvertFromUnicodeL aConvertFromUnicode936L = reinterpret_cast (function9361); sl@0: TConvertFromUnicodeL aConvertFromUnicode54936L = reinterpret_cast (function549361); sl@0: sl@0: typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&); sl@0: TConvertToUnicodeL aConvertToUnicode936L = reinterpret_cast (function9362); sl@0: TConvertToUnicodeL aConvertToUnicode54936L = reinterpret_cast (function549362); sl@0: sl@0: // timer sl@0: TInt count; sl@0: TChar res2; sl@0: TBuf<256> msg; sl@0: TInt fastTimerFreq; sl@0: HAL::Get(HALData::EFastCounterFrequency, fastTimerFreq); sl@0: TReal ticksPerMicroSec = 1.0E-6 * fastTimerFreq; sl@0: TUint prevTime; sl@0: TUint timeDiff; sl@0: TReal64 fsSessionMicroSecs; sl@0: sl@0: _LIT16(Uni_1, "\x0053\x0059\x004D\x3125\x3122\x9673\xFA29"); sl@0: _LIT8(CP54936_1, "\x53\x59\x4D\xA8\xE5\xA8\xE2\xEA\x90\xFE\x4F"); sl@0: TBuf8<20> foreign1; sl@0: TBuf16<20> unicode2; sl@0: const TDesC16& unicode1(Uni_1); sl@0: TInt error; sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: // 1, unicode -> 936 sl@0: // test result: 1448 ms for 100000 iterations sl@0: INFO_PRINTF1(_L("unicode --> 936:\n")); sl@0: INFO_PRINTF1(_L(" source: ")); TestOut(unicode1); INFO_PRINTF1(_L("\n")); sl@0: INFO_PRINTF1(_L(" expect: ")); TestOut(CP54936_1); INFO_PRINTF1(_L("\n")); sl@0: prevTime = User::FastCounter(); sl@0: for (count=0; count 54936 sl@0: // test result: 44 ms for 100000 iterations sl@0: INFO_PRINTF1(_L("unicode --> 54936:\n")); sl@0: INFO_PRINTF1(_L(" source: ")); TestOut(unicode1); INFO_PRINTF1(_L("\n")); sl@0: INFO_PRINTF1(_L(" expect: ")); TestOut(CP54936_1); INFO_PRINTF1(_L("\n")); sl@0: prevTime = User::FastCounter(); sl@0: for (count=0; count unicode sl@0: // test result: 89 ms for 100000 iterations sl@0: INFO_PRINTF1(_L("936 ---> unicode:\n")); sl@0: INFO_PRINTF1(_L(" source: ")); TestOut(foreign2); INFO_PRINTF1(_L("\n")); sl@0: INFO_PRINTF1(_L(" expect: ")); TestOut(Uni_2); INFO_PRINTF1(_L("\n")); sl@0: prevTime = User::FastCounter(); sl@0: for (count=0; count unicode sl@0: // test result: 36 ms for 100000 iterations sl@0: INFO_PRINTF1(_L("54936 ---> unicode:\n")); sl@0: INFO_PRINTF1(_L(" source: ")); TestOut(foreign2); INFO_PRINTF1(_L("\n")); sl@0: INFO_PRINTF1(_L(" expect: ")); TestOut(Uni_2); INFO_PRINTF1(_L("\n")); sl@0: prevTime = User::FastCounter(); sl@0: for (count=0; count (function549361); sl@0: sl@0: typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&); sl@0: TConvertToUnicodeL aConvertToUnicode54936L = reinterpret_cast (function549362); sl@0: sl@0: // timer sl@0: TInt count; sl@0: TBuf<256> msg; sl@0: TInt fastTimerFreq; sl@0: HAL::Get(HALData::EFastCounterFrequency, fastTimerFreq); sl@0: TReal ticksPerMicroSec = 1.0E-6 * fastTimerFreq; sl@0: TUint prevTime; sl@0: TUint timeDiff; sl@0: TReal64 fsSessionMicroSecs; sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: _LIT16(Uni_1, "\x0053\x0059\x004D\x3125\x3122\x9673\xFA29\x060C\xD840\xDC00"); sl@0: _LIT8(CP54936_1, "\x53\x59\x4D\xA8\xE5\xA8\xE2\xEA\x90\xFE\x4F\x81\x31\x81\x32\x95\x32\x82\x36"); sl@0: TBuf8<200> foreign1; sl@0: TBuf16<200> unicode2; sl@0: const TDesC16& unicode1(Uni_1); sl@0: TInt error; sl@0: sl@0: // 2, unicode -> 54936 sl@0: // test result: 130 ms for 100000 iterations (44 ms if one huge table for BMP characters) sl@0: INFO_PRINTF1(_L("unicode --> 54936:\n")); sl@0: INFO_PRINTF1(_L(" source: ")); TestOut(unicode1); INFO_PRINTF1(_L("\n")); sl@0: INFO_PRINTF1(_L(" expect: ")); TestOut(CP54936_1); INFO_PRINTF1(_L("\n")); sl@0: prevTime = User::FastCounter(); sl@0: for (count=0; count unicode sl@0: // test result: 36 ms for 100000 iterations sl@0: INFO_PRINTF1(_L("54936 ---> unicode:\n")); sl@0: INFO_PRINTF1(_L(" source: ")); TestOut(foreign2); INFO_PRINTF1(_L("\n")); sl@0: INFO_PRINTF1(_L(" expect: ")); TestOut(Uni_2); INFO_PRINTF1(_L("\n")); sl@0: prevTime = User::FastCounter(); sl@0: for (count=0; count (function1); sl@0: sl@0: typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&); sl@0: TConvertToUnicodeL aConvertToUnicodeL = reinterpret_cast (function2); sl@0: sl@0: // testing conversion from Unicode sl@0: TBuf8<200> generated54936; sl@0: INFO_PRINTF1(_L("source: ")); sl@0: TestOut(aUnicode); sl@0: INFO_PRINTF1(_L("\n")); sl@0: INFO_PRINTF1(_L("expect: ")); sl@0: TestOut(a54936); sl@0: INFO_PRINTF1(_L("\n")); sl@0: (*aConvertFromUnicodeL)(generated54936, aUnicode); sl@0: INFO_PRINTF1(_L("result: ")); sl@0: TestOut(generated54936); sl@0: INFO_PRINTF1(_L("\n")); sl@0: TInt error = generated54936.Compare(a54936); sl@0: if ( aZero1 ) sl@0: { sl@0: test(error==0); sl@0: } sl@0: else sl@0: { sl@0: test(error!=0); sl@0: } sl@0: sl@0: // testing conversion to Unicode sl@0: TBuf16<200> generatedUnicode; sl@0: INFO_PRINTF1(_L("source: ")); sl@0: TestOut(a54936); sl@0: INFO_PRINTF1(_L("\n")); sl@0: INFO_PRINTF1(_L("expect: ")); sl@0: TestOut(aUnicode); sl@0: INFO_PRINTF1(_L("\n")); sl@0: (*aConvertToUnicodeL)(generatedUnicode,a54936); sl@0: INFO_PRINTF1(_L("result: ")); sl@0: TestOut(generatedUnicode); sl@0: INFO_PRINTF1(_L("\n")); sl@0: error = generatedUnicode.Compare(aUnicode); sl@0: if ( aZero2 ) sl@0: { sl@0: test(error==0); sl@0: } sl@0: else sl@0: { sl@0: test(error!=0); sl@0: } sl@0: sl@0: lib.Close(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID TI18N-CHARCONV-CT- sl@0: @SYMTestCaseDesc Check GB18030 support sl@0: @SYMTestPriority High sl@0: @SYMTestActions 1. Get one-byte Unicode codepoint sl@0: 2. Convert to/from GB18030 to/from Unicode sl@0: 3. Get two-byte Unicode codepoint sl@0: 4. Convert to/from GB18030 to/from Unicode sl@0: 5. Get four-byte Unicode codepoint sl@0: 6. Convert to/from GB18030 to/from Unicode sl@0: @SYMTestExpectedResults No side effect sl@0: @SYMREQ REQ12067 sl@0: */ sl@0: void CT_CP54936::TestGbConversionL() sl@0: { sl@0: // TestL() function covers GB 1,2,4 bytes sl@0: // one-byte sl@0: // border 0x80 sl@0: _LIT16(Uni_0, "\x0000"); sl@0: _LIT8(CP54936_0, "\x00"); sl@0: TestConversionL( Uni_0, CP54936_0 ); sl@0: sl@0: _LIT16(Uni_1, "\x0079"); sl@0: _LIT8(CP54936_1, "\x79"); sl@0: TestConversionL( Uni_1, CP54936_1 ); sl@0: sl@0: _LIT16(Uni_2, "\x0080"); sl@0: _LIT8(CP54936_2, "\x81\x30\x81\x30"); sl@0: TestConversionL( Uni_2, CP54936_2 ); sl@0: sl@0: _LIT16(Uni_3, "\x0081"); sl@0: _LIT8(CP54936_3, "\x81\x30\x81\x31"); sl@0: TestConversionL( Uni_3, CP54936_3 ); sl@0: sl@0: _LIT16(Uni_4, "\x00fe"); sl@0: _LIT8(CP54936_4, "\x81\x30\x8B\x36"); sl@0: TestConversionL( Uni_4, CP54936_4 ); sl@0: sl@0: _LIT16(Uni_5, "\x00ff"); sl@0: _LIT8(CP54936_5, "\x81\x30\x8B\x37"); sl@0: TestConversionL( Uni_5, CP54936_5 ); sl@0: sl@0: // two-byte sl@0: _LIT16(Uni_6, "\x0100"); sl@0: _LIT8(CP54936_6, "\x81\x30\x8B\x38"); sl@0: TestConversionL( Uni_6, CP54936_6 ); sl@0: sl@0: _LIT16(Uni_7, "\x0101"); sl@0: _LIT8(CP54936_7, "\xA8\xA1"); sl@0: TestConversionL( Uni_7, CP54936_7 ); sl@0: sl@0: _LIT16(Uni_8, "\x0ffe"); sl@0: _LIT8(CP54936_8, "\x81\x33\x83\x38"); sl@0: TestConversionL( Uni_8, CP54936_8 ); sl@0: sl@0: _LIT16(Uni_9, "\x0fff"); sl@0: _LIT8(CP54936_9, "\x81\x33\x83\x39"); sl@0: TestConversionL( Uni_9, CP54936_9 ); sl@0: sl@0: _LIT16(Uni_10, "\x1000"); sl@0: _LIT8(CP54936_10, "\x81\x33\x84\x30"); sl@0: TestConversionL( Uni_10, CP54936_10 ); sl@0: sl@0: _LIT16(Uni_11, "\x1001"); sl@0: _LIT8(CP54936_11, "\x81\x33\x84\x31"); sl@0: TestConversionL( Uni_11, CP54936_11 ); sl@0: sl@0: _LIT16(Uni_12, "\xfffe"); sl@0: _LIT8(CP54936_12, "\x84\x31\xA4\x38"); sl@0: TestConversionL( Uni_12, CP54936_12 ); sl@0: sl@0: _LIT16(Uni_13, "\xffff"); sl@0: _LIT8(CP54936_13, "\x84\x31\xA4\x39"); sl@0: TestConversionL( Uni_13, CP54936_13 ); sl@0: sl@0: // four-byte sl@0: _LIT16(Uni_14, "\xd840\xdc00"); sl@0: _LIT8(CP54936_14, "\x95\x32\x82\x36"); sl@0: TestConversionL( Uni_14, CP54936_14 ); sl@0: sl@0: _LIT16(Uni_15, "\xd840\xdc01"); sl@0: _LIT8(CP54936_15, "\x95\x32\x82\x37"); sl@0: TestConversionL( Uni_15, CP54936_15 ); sl@0: sl@0: _LIT16(Uni_16, "\xD87F\xdffe"); sl@0: _LIT8(CP54936_16, "\x9a\x34\x84\x30"); sl@0: TestConversionL( Uni_16, CP54936_16 ); sl@0: sl@0: _LIT16(Uni_17, "\xD87F\xdfff"); sl@0: _LIT8(CP54936_17, "\x9a\x34\x84\x31"); sl@0: TestConversionL( Uni_17, CP54936_17 ); sl@0: sl@0: // 4-byte gb sl@0: _LIT16(Uni_18, "\xd840\xddad"); sl@0: _LIT8(CP54936_18, "\x95\x32\xAD\x35"); sl@0: TestConversionL( Uni_18, CP54936_18 ); sl@0: sl@0: _LIT16(Uni_19, "\xd801\xdd00"); sl@0: _LIT8(CP54936_19, "\x90\x31\x83\x30"); sl@0: TestConversionL( Uni_19, CP54936_19 ); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID TI18N-CHARCONV-CT- sl@0: @SYMTestCaseDesc Test FAT short name legal character sl@0: @SYMTestPriority High sl@0: @SYMTestActions 1. Get one-byte Unicode codepoint sl@0: 2. Check if it's legal short name character sl@0: 3. Get two-byte Unicode codepoint sl@0: 4. Check if it's legal short name character sl@0: 5. Get four-byte Unicode codepoint sl@0: 6. Check if it's legal short name character sl@0: @SYMTestExpectedResults No side effect sl@0: @SYMREQ REQ12067 sl@0: */ sl@0: void CT_CP54936::TestShortNameCharacterL() sl@0: { sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1778 ")); sl@0: RLibrary lib; sl@0: sl@0: const TUidType serverUid(KNullUid,KNullUid,KPluginUid); sl@0: // load the dll sl@0: TInt returnValue = lib.Load(KName,serverUid); sl@0: test(returnValue==0); sl@0: sl@0: // get a pointer to the specified ordinal function and call it sl@0: TLibraryFunction function1 = lib.Lookup(1); sl@0: TLibraryFunction function2 = lib.Lookup(2); sl@0: TLibraryFunction function3 = lib.Lookup(3); sl@0: sl@0: typedef TBool (*TIsLegalShortNameCharacter)(TUint); sl@0: TIsLegalShortNameCharacter aIsLegalShortNameCharacter = reinterpret_cast (function3); sl@0: sl@0: // testing for legal short name character sl@0: // one-byte unicode sl@0: // 0x20 is space sl@0: TInt result = (*aIsLegalShortNameCharacter)(0x0019); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x0020); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x0021); sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x005F); sl@0: test(result==1); sl@0: sl@0: // 0x80 is ascii border sl@0: result = (*aIsLegalShortNameCharacter)(0x0079); sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x0080); sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x0081); sl@0: test(result==1); sl@0: sl@0: // testing for illegal character sl@0: result = (*aIsLegalShortNameCharacter)(0x003F); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x22); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x2A); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x2B); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x2C); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x2F); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x3A); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x3B); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x3C); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x3D); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x3E); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x5B); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x5C); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x5D); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x7C); sl@0: test(result==0); sl@0: sl@0: // two-byte unicode sl@0: result = (*aIsLegalShortNameCharacter)(0x1000); sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x1001); sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x2999); //testing for non-existent character sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x4E02); //testing for a double byte character sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0xfffe); sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0xffff); sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0xd7ff); sl@0: test(result==1); sl@0: sl@0: // surrogate part sl@0: result = (*aIsLegalShortNameCharacter)(0xd800); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0xdfff); sl@0: test(result==0); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0xe000); sl@0: test(result==1); sl@0: sl@0: // four-byte unicode sl@0: result = (*aIsLegalShortNameCharacter)(0x10000); sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x10001); sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x10fffe); sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x10ffff); sl@0: test(result==1); sl@0: sl@0: result = (*aIsLegalShortNameCharacter)(0x110000); sl@0: test(result==0); sl@0: sl@0: lib.Close(); sl@0: } sl@0: sl@0: sl@0: CT_CP54936::CT_CP54936() sl@0: { sl@0: SetTestStepName(KTestStep_T_CP54936); sl@0: } sl@0: sl@0: sl@0: TVerdict CT_CP54936::doTestStepL() sl@0: { sl@0: SetTestStepResult(EFail); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TRAPD(error1, TestGbConversionL()); sl@0: TRAPD(error2, TestShortNameCharacterL()); sl@0: TRAPD(error3, TestL()); sl@0: TRAPD(error4, TestINC090073L()); sl@0: TRAPD(error5, OOMTestL()); sl@0: TRAPD(error6, PerformanceTest1L()); sl@0: TRAPD(error7, PerformanceTest2L()); sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: if(error1 == KErrNone && error2 == KErrNone && error3 == KErrNone sl@0: && error4 == KErrNone && error5 == KErrNone sl@0: && error6 == KErrNone && error7 == KErrNone) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: }