sl@0: // Copyright (c) 1996-2009 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 the License "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: // e32test\buffer\t_match.cpp sl@0: // Overview: sl@0: // Test the match methods of TPtrC8 and TPtrC16 objects and the sl@0: // TCharIterator TCombiningCharIterator, TCollationValueIterator sl@0: // and TCollationRawValueIterator classes. sl@0: // API Information: sl@0: // TPtrC8, TPtrC16, TCharIterator, TCombiningCharIterator, sl@0: // TCollationValueIterator, TCollationRawValueIterator sl@0: // Details: sl@0: // - Test and verify the results of TPtrC8 Match and MatchF methods sl@0: // on a variety of constant strings. Verify both match and mismatch sl@0: // conditions. sl@0: // - Test and verify the results of TPtrC16 Match and MatchF methods sl@0: // on a variety of constant strings. Verify both match and mismatch sl@0: // conditions. sl@0: // - For a TCharIterator object, test and verify: sl@0: // - basic character handling sl@0: // - ability to reset the iterator correctly sl@0: // - combining characters works as expected sl@0: // - ability to jump into the middle of combined characters sl@0: // - full-width variants are not modified sl@0: // - narrow strings work as expected sl@0: // - surrogate pairs work as expected sl@0: // - Using a TCombiningCharIterator object with a variety of character sl@0: // strings as input, verify that the output is as expected. sl@0: // - Using TCollationValueIterator and TCollationRawValueIterator objects: sl@0: // - test the raw iterator sl@0: // - test starting at different points in the iteration and verify capitals sl@0: // are ignored at level 0 sl@0: // - verify capitals are ignored at level 1 sl@0: // - verify capitals do not match at level 2 sl@0: // - check the TCollationValueIterator Restart method sl@0: // - test collation keys, when they success and when they fail halfway sl@0: // - exhaust the internal cache, verify object still works sl@0: // - test different decompositions at level 3 sl@0: // - verify results are as expected sl@0: // - Test and verify the results of the TUnicodeFold::FindWildcardMatchFolded() sl@0: // method on a variety of constant strings: find a string within another sl@0: // string, verify the offset into the candidate string if it is present, or sl@0: // KErrNotFound if it is not. sl@0: // - Test and verify the results of the TUnicodeFold::FindFolded() method on sl@0: // a variety of constant strings: compare two strings, verify return value. sl@0: // - Test and verify results of UnicodeFoldCase() on a variety of characters. sl@0: // - Test and verify results of MatchLeadingWildcards() on a variety of strings. sl@0: // - Test and verify results of MatchesHereFoldedWithPrefixTest() on a variety sl@0: // of strings. sl@0: // - Test and verify results of LocateFolded() on a variety of strings. sl@0: // - Test and verify results of FindFoldedWithWildcard() and FindMatchFolded() sl@0: // on a variety of strings. sl@0: // - Test and verify results of TDesc.CompareF() on a variety of strings. sl@0: // Platforms/Drives/Compatibility: sl@0: // All sl@0: // Assumptions/Requirement/Pre-requisites: sl@0: // Failures and causes: sl@0: // Base Port information: sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "collateimp.h" sl@0: #include "CompareImp.h" sl@0: #include "u32std.h" sl@0: sl@0: static inline TBool IsSupplementary(TUint aChar) sl@0: /** sl@0: @param aChar The 32-bit code point value of a Unicode character. sl@0: sl@0: @return True, if aChar is supplementary character; false, otherwise. sl@0: */ sl@0: { sl@0: return (aChar > 0xFFFF); sl@0: } sl@0: sl@0: static inline TText16 GetHighSurrogate(TUint aChar) sl@0: /** sl@0: Retrieve the high surrogate of a supplementary character. sl@0: sl@0: @param aChar The 32-bit code point value of a Unicode character. sl@0: sl@0: @return High surrogate of aChar, if aChar is a supplementary character; sl@0: aChar itself, if aChar is not a supplementary character. sl@0: sl@0: @see TChar::GetLowSurrogate sl@0: */ sl@0: { sl@0: return STATIC_CAST(TText16, 0xD7C0 + (aChar >> 10)); sl@0: } sl@0: sl@0: static inline TText16 GetLowSurrogate(TUint aChar) sl@0: /** sl@0: Retrieve the low surrogate of a supplementary character. sl@0: sl@0: @param aChar The 32-bit code point value of a Unicode character. sl@0: sl@0: @return Low surrogate of aChar, if aChar is a supplementary character; sl@0: zero, if aChar is not a supplementary character. sl@0: sl@0: @see TChar::GetHighSurrogate sl@0: */ sl@0: { sl@0: return STATIC_CAST(TText16, 0xDC00 | (aChar & 0x3FF)); sl@0: } sl@0: sl@0: sl@0: ///***************** copied from locale euser source code *********************** sl@0: static const TCollationMethod TheCollationMethod[] = sl@0: { sl@0: { sl@0: KUidBasicCollationMethod, // this is the standard unlocalised method sl@0: NULL, // null means use the standard table sl@0: NULL, // there's no override table sl@0: 0 // the flags are standard sl@0: } sl@0: }; sl@0: static const TCollationDataSet TheCollationDataSet = sl@0: { sl@0: TheCollationMethod, sl@0: 1 sl@0: }; sl@0: const LCharSet TheCharSet = sl@0: { sl@0: NULL, sl@0: &TheCollationDataSet sl@0: }; sl@0: const LCharSet* GetLocaleCharSet() sl@0: { sl@0: return &TheCharSet; sl@0: } sl@0: ///******************************************************************************* sl@0: sl@0: sl@0: #ifdef __VC32__ sl@0: // Solve compilation problem caused by non-English locale sl@0: #pragma setlocale("english") sl@0: #endif sl@0: sl@0: #define ARRAY_SIZE(ar) (sizeof(ar) / (sizeof(ar[0]))) sl@0: sl@0: LOCAL_D RTest test(_L("T_MATCH")); sl@0: sl@0: _LIT(KUnicodeTestDataFile, "z:\\Test\\UnicodeData.txt"); sl@0: sl@0: static const TUint32 TheDevanagariKey[] = sl@0: { sl@0: 0x22a010b,0x22b010b,0x285010b,0xb109,0xb209,0xb309,0xb409,0xb509, sl@0: 0x6c5e609,0x6c6e609,0x6c7e609,0x6c8e609,0x6c9e609,0x6cae609,0x6cbe609,0x6cce609, sl@0: 0x6cde609,0x6cee609,0xba40109,0xba50109,0xba60109,0xba70109,0xba80109,0xba90109, sl@0: 0xbaa0109,0xbab0109,0xbac0109,0xbad0109,0xbae0109,0xbaf0109,0xbb00109,0xbb10109, sl@0: 0xbb20109,0xbb30109,0xbb40109,0xbb50109,0xbb60109,0xbb70109,0xbb80109,0xbb90109, sl@0: 0xbb9b109,0xbba0109,0xbbab109,0xbbb0109,0xbbbb109,0xbbc0109,0xbbd0109,0xbbe0109, sl@0: 0xbbf0109,0xbc00109,0xbc0b109,0xbc10109,0xbc20109,0xbc30109,0xbc40109,0xbc50109, sl@0: 0xbc5b109,0xbc60109,0xbc6b109,0xbc70109,0xbc80109,0xbc90109,0xbca0109,0xbcb0109, sl@0: 0xbcc0109,0xbccb109,0xbcd0109,0xbce0109,0xbceb109,0xbcf0109,0xbd00109,0xbd10109, sl@0: 0xbd20109,0xbd2b109,0xbd30109,0xbd3b109,0xbd40109,0xbd50109,0xbd5b109,0xbd60109, sl@0: 0xbd70109,0xbd80109,0xbd90109,0xbda0109,0xbdb0109,0xbdc0109,0xbdd0109,0xbde0109, sl@0: 0xbdf0109,0xbe00109,0xbe10109,0xbe20109,0xbe30109,0xbe40109,0xbe50109,0xbe60109, sl@0: 0xbe70109,0xbe80109,0xbe90109,0xbea0109,0xbeb0109,0xbec0109,0xbed0109, sl@0: }; sl@0: sl@0: static const TUint32 TheDevanagariIndex[] = sl@0: { sl@0: 0x9010012,0x9020013,0x9030014,0x9050015,0x9060016,0x9070017,0x9080018,0x9090019, sl@0: 0x90a001a,0x90b001b,0x90c001d,0x90d001f,0x90e0020,0x90f0021,0x9100022,0x9110023, sl@0: 0x9120024,0x9130025,0x9140026,0x9150027,0x9160029,0x917002b,0x918002d,0x919002e, sl@0: 0x91a002f,0x91b0030,0x91c0031,0x91d0033,0x91e0034,0x91f0035,0x9200036,0x9210037, sl@0: 0x9220039,0x923003b,0x924003c,0x925003d,0x926003e,0x927003f,0x9280040,0x9290041, sl@0: 0x92a0042,0x92b0043,0x92c0045,0x92d0046,0x92e0047,0x92f0048,0x930004a,0x931004b, sl@0: 0x932004c,0x933004d,0x934004e,0x935004f,0x9360050,0x9370051,0x9380052,0x9390053, sl@0: 0x93c0003,0x93d0054,0x93e0055,0x93f0056,0x9400057,0x9410058,0x9420059,0x943005a, sl@0: 0x944005b,0x945005e,0x946005f,0x9470060,0x9480061,0x9490062,0x94a0063,0x94b0064, sl@0: 0x94c0065,0x94d0066,0x9510004,0x9520005,0x9530006,0x9540007,0x9580028,0x959002a, sl@0: 0x95a002c,0x95b0032,0x95c0038,0x95d003a,0x95e0044,0x95f0049,0x960001c,0x961001e, sl@0: 0x962005c,0x963005d,0x9640000,0x9650001,0x9660008,0x9670009,0x968000a,0x969000b, sl@0: 0x96a000c,0x96b000d,0x96c000e,0x96d000f,0x96e0010,0x96f0011,0x9700002, sl@0: }; sl@0: sl@0: static const TCollationKeyTable TheDevanagariTable = sl@0: { TheDevanagariKey, TheDevanagariIndex, 103, 0, 0, 0 }; sl@0: sl@0: static const TCollationMethod TheDevanagariMethod = sl@0: { 0, 0, &TheDevanagariTable, 0 }; sl@0: sl@0: static const TCollationMethod TheDevanagariIgnoreCombiningMethod = sl@0: { 0, 0, &TheDevanagariTable, TCollationMethod::EIgnoreCombining }; sl@0: sl@0: static const TUint32 TheSwedishKey[] = sl@0: { sl@0: 0x8f60109,0x8f70109,0x8f80109,0x8f60121,0x8f70121,0x8f80121,0x8dd0109,0x8dd0121, sl@0: 0x8c50121,0x8c50109, sl@0: }; sl@0: sl@0: static const TUint32 TheSwedishIndex[] = sl@0: { sl@0: 0x570008,0x770009, sl@0: }; sl@0: sl@0: static const TUint16 TheSwedishStringElement[] = sl@0: { sl@0: 0x2,0x61,0x30a,0x2,0x61,0x308,0x2,0x6f, sl@0: 0x308,0x2,0x41,0x30a,0x2,0x41,0x308,0x2, sl@0: 0x4f,0x308,0x2,0x75,0x308,0x2,0x55,0x308, sl@0: }; sl@0: sl@0: static const TUint32 TheSwedishStringIndex[] = sl@0: { sl@0: 0xc0004,0x90003,0xf0005,0x150007,0x30001,0x0,0x60002,0x120006, sl@0: }; sl@0: sl@0: static const TCollationKeyTable TheSwedishTable = sl@0: { TheSwedishKey, TheSwedishIndex, 2, TheSwedishStringElement, TheSwedishStringIndex, 8 }; sl@0: sl@0: static const TCollationMethod TheSwedishMethod = sl@0: { 0, 0, &TheSwedishTable, TCollationMethod::EIgnoreNone }; sl@0: sl@0: static const TCollationMethod TheIgnoreNoneMethod = sl@0: { 0, 0, 0, TCollationMethod::EIgnoreNone }; sl@0: sl@0: void TestPrintCaption(const TDesC& aTestName, const TText16 aStr[], TInt aLen) sl@0: { sl@0: test.Next(aTestName); sl@0: RDebug::Print(_L("Char seq: ")); sl@0: for(TInt i=0;i search, target; sl@0: //All Devanagari dependant vowels are in the following range sl@0: for(TInt dependantVowel=0x93e; dependantVowel<=0x94c; dependantVowel++) sl@0: { sl@0: //Most of the Devanagari consonants are in the following range sl@0: for(TInt consonant=0x915; consonant<=0x939; consonant++) sl@0: { sl@0: target.Format(_L("%c%c"),consonant,dependantVowel); sl@0: search.Format(_L("%c*"),consonant); sl@0: TestDisableCombiningCharacterCheckFlag(target, search); sl@0: } sl@0: } sl@0: //Test same situation but where consonants decompose to consonant + dependant vowel sl@0: TestDisableCombiningCharacterCheckFlag(_L("\x929"), _L("\x928*")); sl@0: TestDisableCombiningCharacterCheckFlag(_L("\x931"), _L("\x930*")); sl@0: TestDisableCombiningCharacterCheckFlag(_L("\x934"), _L("\x933*")); sl@0: TestDisableCombiningCharacterCheckFlag(_L("\x958"), _L("\x915*")); sl@0: TestDisableCombiningCharacterCheckFlag(_L("\x959"), _L("\x916*")); sl@0: TestDisableCombiningCharacterCheckFlag(_L("\x95a"), _L("\x917*")); sl@0: TestDisableCombiningCharacterCheckFlag(_L("\x95b"), _L("\x91c*")); sl@0: TestDisableCombiningCharacterCheckFlag(_L("\x95c"), _L("\x921*")); sl@0: TestDisableCombiningCharacterCheckFlag(_L("\x95d"), _L("\x922*")); sl@0: TestDisableCombiningCharacterCheckFlag(_L("\x95e"), _L("\x92b*")); sl@0: TestDisableCombiningCharacterCheckFlag(_L("\x95f"), _L("\x92f*")); sl@0: } sl@0: sl@0: _LIT(KHelloT, "Hello"); sl@0: _LIT(KLatin1AccentsC, "\xE0\xD2p\xE2\xEB\xED\xF1\xC7"); sl@0: _LIT(KLatin1AccentsD, "a\x300O\x300pa\x302\x65\x308i\x301n\x303\x43\x327"); sl@0: // four alpha + psili + varia + ypogegrameni sl@0: _LIT(KGreekAccentsC, "\x1f82\x1f82\x1f82\x1f82"); sl@0: // decomposed in four different ways sl@0: _LIT(KGreekAccentsS, "\x1f82\x1f02\x345\x1f00\x300\x345\x3b1\x313\x300\x345"); sl@0: // completely decomposed sl@0: _LIT(KGreekAccentsD, "\x3b1\x313\x300\x345\x3b1\x313\x300\x345\x3b1\x313\x300\x345\x3b1\x313\x300\x345"); sl@0: // full-width variants sl@0: _LIT(KFullWidth, "\xFF21\xFF42\xFF43"); sl@0: // surrogate pair, unpaired low surrogate, unpaired high surrogate, unpaired sl@0: // high surrogate at end of string sl@0: _LIT(KSurrogates, "\xD965\xDEF0\xDF12\xDB10\xDA4E"); sl@0: _LIT(KSurrogatesTest, "\xD965\xDEF0"); sl@0: sl@0: void TestIteratorOutput(TDecompositionIterator& aIt, const TDesC& aCheck) sl@0: { sl@0: TBool unpairedHighSurrogate = EFalse; sl@0: for(TInt i = 0; i != aCheck.Length(); aIt.Next()) sl@0: { sl@0: if (aIt.AtEnd()) sl@0: { sl@0: test(0); sl@0: return; sl@0: } sl@0: TInt c = aIt.Current(); sl@0: // test that we are not looking at an unpaired low surrogate that sl@0: // follows an unpaired high surrogate: this is not possible. sl@0: test((c & 0xFC00) != 0xDC00 || !unpairedHighSurrogate); sl@0: unpairedHighSurrogate = (c & 0xFC00) == 0xD800? (TBool)ETrue : (TBool)EFalse; sl@0: if (c < 0x10000) sl@0: { sl@0: test(c == aCheck[i]); sl@0: ++i; sl@0: } sl@0: else sl@0: { sl@0: TInt sp = ((aCheck[i] - 0xD7F7) << 10) + aCheck[i + 1]; sl@0: test(c == sp); sl@0: i += 2; sl@0: } sl@0: } sl@0: test(aIt.AtEnd()); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-0097 sl@0: @SYMTestCaseDesc TUTF32Iterator functionality tested on 2 character sequences: sl@0: (1) single character sl@0: (2) surrogate pair sl@0: @SYMTestPriority High sl@0: @SYMTestActions TUTF32Iterator test. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ814 Optimise folded string comparisons. sl@0: */ sl@0: void TestUTF32Iterator() sl@0: { sl@0: //Single character sl@0: const TText16 KStr[] = {0x01D5}; sl@0: ::TestPrintCaption(_L("TUTF32Iterator"), KStr, ARRAY_SIZE(KStr)); sl@0: TUTF32Iterator it(KStr, KStr + ARRAY_SIZE(KStr)); sl@0: TInt itCount = 0; sl@0: for(;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: TChar ch = it.Current(); sl@0: test(ch == static_cast (KStr[0])); sl@0: RDebug::Print(_L("%04X "), (TUint)ch); sl@0: } sl@0: test(itCount == 1); sl@0: RDebug::Print(_L("\n")); sl@0: sl@0: //Surrogate pair sl@0: ::TestPrintCaption(_L("TUTF32Iterator-surrogates"), KSurrogatesTest().Ptr(), KSurrogatesTest().Length()); sl@0: it = TUTF32Iterator(KSurrogatesTest().Ptr(), KSurrogatesTest().Ptr() + KSurrogatesTest().Length()); sl@0: for(itCount=0;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: TChar ch = it.Current(); sl@0: test(ch == 0x696F0); sl@0: RDebug::Print(_L("%06X "), (TUint)ch); sl@0: } sl@0: test(itCount == 1); sl@0: RDebug::Print(_L("\n")); sl@0: sl@0: // surrogate 0x10000 sl@0: _LIT( KSurrogatesTest2, "\xd800\xdc00" ); sl@0: ::TestPrintCaption(_L("TUTF32Iterator-surrogates2"), KSurrogatesTest2().Ptr(), KSurrogatesTest2().Length()); sl@0: it = TUTF32Iterator(KSurrogatesTest2().Ptr(), KSurrogatesTest2().Ptr() + KSurrogatesTest2().Length()); sl@0: for(itCount=0;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: TChar ch = it.Current(); sl@0: test(ch == 0x10000); sl@0: RDebug::Print(_L("%06X "), (TUint)ch); sl@0: } sl@0: test(itCount == 1); sl@0: RDebug::Print(_L("\n")); sl@0: sl@0: // surrogate 0x20000 sl@0: _LIT( KSurrogatesTest3, "\xd840\xdc00" ); sl@0: ::TestPrintCaption(_L("TUTF32Iterator-surrogates3"), KSurrogatesTest3().Ptr(), KSurrogatesTest3().Length()); sl@0: it = TUTF32Iterator(KSurrogatesTest3().Ptr(), KSurrogatesTest3().Ptr() + KSurrogatesTest3().Length()); sl@0: for(itCount=0;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: TChar ch = it.Current(); sl@0: test(ch == 0x20000); sl@0: RDebug::Print(_L("%06X "), (TUint)ch); sl@0: } sl@0: test(itCount == 1); sl@0: RDebug::Print(_L("\n")); sl@0: sl@0: // surrogate 0x2ffff sl@0: _LIT( KSurrogatesTest4, "\xD87F\xDFFF" ); sl@0: ::TestPrintCaption(_L("TUTF32Iterator-surrogates4"), KSurrogatesTest4().Ptr(), KSurrogatesTest4().Length()); sl@0: it = TUTF32Iterator(KSurrogatesTest4().Ptr(), KSurrogatesTest4().Ptr() + KSurrogatesTest4().Length()); sl@0: for(itCount=0;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: TChar ch = it.Current(); sl@0: test(ch == 0x2ffff); sl@0: RDebug::Print(_L("%06X "), (TUint)ch); sl@0: } sl@0: //test(itCount == 1); sl@0: RDebug::Print(_L("\n")); sl@0: sl@0: // surrogate 0xd800 sl@0: _LIT( KSurrogatesTest5, "\xD800" ); sl@0: ::TestPrintCaption(_L("TUTF32Iterator-surrogates5"), KSurrogatesTest5().Ptr(), KSurrogatesTest5().Length()); sl@0: it = TUTF32Iterator(KSurrogatesTest5().Ptr(), KSurrogatesTest5().Ptr() + KSurrogatesTest5().Length()); sl@0: for(itCount=0;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: TChar ch = it.Current(); sl@0: RDebug::Print(_L("%06X "), (TUint)ch); sl@0: } sl@0: test(itCount == 0); sl@0: RDebug::Print(_L("\n")); sl@0: sl@0: // surrogate 0xdc00 sl@0: _LIT( KSurrogatesTest6, "\xDc00" ); sl@0: ::TestPrintCaption(_L("TUTF32Iterator-surrogates6"), KSurrogatesTest6().Ptr(), KSurrogatesTest6().Length()); sl@0: it = TUTF32Iterator(KSurrogatesTest6().Ptr(), KSurrogatesTest6().Ptr() + KSurrogatesTest6().Length()); sl@0: for(itCount=0;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: TChar ch = it.Current(); sl@0: RDebug::Print(_L("%06X "), (TUint)ch); sl@0: } sl@0: test(itCount == 0); sl@0: RDebug::Print(_L("\n")); sl@0: sl@0: // surrogate 0xdfff sl@0: _LIT( KSurrogatesTest7, "\xDfff" ); sl@0: ::TestPrintCaption(_L("TUTF32Iterator-surrogates7"), KSurrogatesTest7().Ptr(), KSurrogatesTest7().Length()); sl@0: it = TUTF32Iterator(KSurrogatesTest7().Ptr(), KSurrogatesTest7().Ptr() + KSurrogatesTest7().Length()); sl@0: for(itCount=0;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: TChar ch = it.Current(); sl@0: RDebug::Print(_L("%06X "), (TUint)ch); sl@0: } sl@0: test(itCount == 0); sl@0: RDebug::Print(_L("\n")); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-0098 sl@0: @SYMTestCaseDesc TFoldedDecompIterator functionality tested on 2 character sequences. sl@0: @SYMTestPriority High sl@0: @SYMTestActions TFoldedDecompIterator test. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ814 Optimise folded string comparisons. sl@0: */ sl@0: void TestFoldedDecompIterator() sl@0: { sl@0: //Character sequence 1: sl@0: //(1) DEVANAGARI LETTER FA - 0x095E sl@0: //(2) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5 sl@0: //Decompositions: sl@0: //(1) 0x095E decomposed to: 0x092B 0x093C sl@0: //(2) 0x01D5 decomposed to: 0x00DC 0x0304 sl@0: // 0x00DC decomposed to: 0x0055 0x0308 sl@0: // 0x0055 decomposed to: 0x0075 sl@0: const TText16 KStr[] = {0x095E, 0x01D5}; sl@0: const TText16 KStrOut[] = {0x092B, 0x093C, 0x0075, 0x0308, 0x0304}; sl@0: ::TestPrintCaption(_L("TFoldedDecompIterator-1"), KStr, ARRAY_SIZE(KStr)); sl@0: TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); sl@0: TFoldedDecompIterator it(itSrc); sl@0: TInt itCount = 0; sl@0: for(;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: if(!it.IsInFoldedSequence()) sl@0: { sl@0: it.EnterFoldedSequence(); sl@0: } sl@0: TChar ch = it.Current(); sl@0: test(ch == static_cast (KStrOut[itCount])); sl@0: RDebug::Print(_L("%04X "), (TUint)ch); sl@0: } sl@0: test(itCount == ARRAY_SIZE(KStrOut)); sl@0: RDebug::Print(_L("\n")); sl@0: sl@0: //Character sequence 2: sl@0: //(1) GREEK CAPITAL LETTER BETA - 0x0392 sl@0: //(2) COMBINING GRAVE ACCENT - 0x0300 sl@0: //(3) COMBINING GRAVE ACCENT BELOW - 0x0316 sl@0: //(4) GREEK CAPITAL LETTER GAMMA - 0x0393 sl@0: //(5) HEBREW POINT TSERE - 0x05B5 sl@0: //(6) TIBETAN MARK HALANTA - 0x0F84 sl@0: //Decompositions: sl@0: //(1) 0x0392 decomposed to: 0x03B2 sl@0: //(2) 0x0300 decomposed to: 0x0300 sl@0: //(3) 0x0316 decomposed to: 0x0316 sl@0: //(4) 0x0393 decomposed to: 0x03B3 sl@0: //(5) 0x05B5 decomposed to: 0x05B5 sl@0: //(6) 0x0F84 decomposed to: 0x0F84 sl@0: const TText16 KStr2[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0x0F84}; sl@0: const TText16 KStrOut2[] = {0x03B2, 0x0300, 0x0316, 0x03B3, 0x05B5, 0x0F84}; sl@0: ::TestPrintCaption(_L("TFoldedDecompIterator-2"), KStr2, ARRAY_SIZE(KStr2)); sl@0: itSrc = TUTF32Iterator(KStr2, KStr2 + ARRAY_SIZE(KStr2)); sl@0: it = TFoldedDecompIterator(itSrc); sl@0: for(itCount=0;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: if(!it.IsInFoldedSequence()) sl@0: { sl@0: it.EnterFoldedSequence(); sl@0: } sl@0: TChar ch = it.Current(); sl@0: test(ch == static_cast (KStrOut2[itCount])); sl@0: RDebug::Print(_L("%04X "), (TUint)ch); sl@0: } sl@0: test(itCount == ARRAY_SIZE(KStrOut2)); sl@0: RDebug::Print(_L("\n")); sl@0: sl@0: //Character sequence 3: sl@0: //(1) MUSICAL SYMBOL EIGHTH NOTE - 0x1D161 (D834, DD61) sl@0: //Decompositions: sl@0: //(1) 0x1D161 decomposed to: 0x1D15F 0x1D16F sl@0: // 0x1D15F decomposed to: 0x1D158 0x1D165 sl@0: const TText16 KStr3[] = {0xD834, 0xDD61}; sl@0: const TUint32 KStrOut3[] = {0x1D158, 0x1D165, 0x1D16F}; sl@0: ::TestPrintCaption(_L("TFoldedDecompIterator-3"), KStr3, ARRAY_SIZE(KStr3)); sl@0: itSrc = TUTF32Iterator(KStr3, KStr3 + ARRAY_SIZE(KStr3)); sl@0: it = TFoldedDecompIterator(itSrc); sl@0: for(itCount=0;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: if(!it.IsInFoldedSequence()) sl@0: { sl@0: it.EnterFoldedSequence(); sl@0: } sl@0: TChar ch = it.Current(); sl@0: test(ch == static_cast (KStrOut3[itCount])); sl@0: RDebug::Print(_L("%04X "), (TUint)ch); sl@0: } sl@0: test(itCount == ARRAY_SIZE(KStrOut3)); sl@0: RDebug::Print(_L("\n")); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-0099 sl@0: @SYMTestCaseDesc TFoldedSortedDecompIterator functionality tested on 1 character sequence. sl@0: @SYMTestPriority High sl@0: @SYMTestActions TFoldedSortedDecompIterator test. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ814 Optimise folded string comparisons. sl@0: */ sl@0: void TestFoldedSortedDecompIterator() sl@0: { sl@0: //Character sequence 1: sl@0: //(1) GREEK CAPITAL LETTER BETA - 0x0392 (fold: 0x3B2, ccc=0) sl@0: //(2) COMBINING GRAVE ACCENT - 0x0300 (no fold, ccc=230) sl@0: //(3) COMBINING GRAVE ACCENT BELOW - 0x0316 (no fold, ccc=220) sl@0: //(4) GREEK CAPITAL LETTER GAMMA - 0x0393 (fold: 0x3B3, ccc=0) sl@0: //(5) HEBREW POINT TSERE - 0x05B5 (no fold, ccc=15) sl@0: //(6) 0x10A39 (no fold, ccc=1) sl@0: //(7) TIBETAN MARK HALANTA - 0x0F84 (no fold, ccc=9) sl@0: //(8) 0x10400 (fold: 0x10428, ccc=0) sl@0: //(9) 0x10A38 (no fold, ccc=230) sl@0: //(10) 0xFB1E (no fold, ccc=26) sl@0: //Decompositions: sl@0: //0x03B2 Class 0 sl@0: //0x0316 Class 220 sl@0: //0x0300 Class 230 sl@0: //0x03B3 Class 0 sl@0: //0x10A39 Class 1 sl@0: //0x0F84 Class 9 sl@0: //0x05B5 Class 15 sl@0: //0x10428 Class 0 sl@0: //0xFB1E Class 26 sl@0: //0x10A38 Class 230 sl@0: //const TText16 KStr[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0x0F84}; sl@0: //const TText16 KStrOut[] = {0x03B2, 0x0316, 0x0300, 0x03B3, 0x0F84, 0x05B5}; sl@0: //const TInt KClass[] = {0, 220, 230, 0, 9, 15}; sl@0: const TText16 KStr[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0xD802, 0xDE39, 0x0F84, 0xD801, 0xDC00, 0xD802, 0xDE38, 0xFB1E}; sl@0: const TUint32 KStrOut[] = {0x03B2, 0x0316, 0x0300, 0x03B3, 0x10A39, 0x0F84, 0x05B5, 0x10428, 0xFB1E, 0x10A38}; sl@0: const TInt KClass[] = {0, 220, 230, 0, 1, 9, 15, 0, 26, 230}; sl@0: ::TestPrintCaption(_L("TFoldedSortedDecompIterator"), KStr, ARRAY_SIZE(KStr)); sl@0: RDebug::Print(_L("\n")); sl@0: TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); sl@0: TFoldedDecompIterator itDecomp(itSrc); sl@0: TInt itCount = 0; sl@0: while(!itDecomp.AtEnd()) sl@0: { sl@0: if(!itDecomp.IsInFoldedSequence()) sl@0: { sl@0: itDecomp.EnterFoldedSequence(); sl@0: } sl@0: if(itDecomp.Current().GetCombiningClass() == 0) sl@0: { sl@0: TChar ch = itDecomp.Current(); sl@0: TInt clss = itDecomp.Current().GetCombiningClass(); sl@0: RDebug::Print(_L("BaseCh %04X Class %d\n"), (TUint)ch, clss); sl@0: test(ch == static_cast (KStrOut[itCount])); sl@0: test(clss == KClass[itCount]); sl@0: itDecomp.Next(); sl@0: ++itCount; sl@0: } sl@0: else sl@0: { sl@0: TFoldedSortedDecompIterator it; sl@0: it.Set(itDecomp); sl@0: while(!it.AtEnd()) sl@0: { sl@0: TChar ch = it.Current(); sl@0: TInt clss = it.Current().GetCombiningClass(); sl@0: RDebug::Print(_L("CombCh %08X Class %d\n"), (TUint)ch, clss); sl@0: test(ch == static_cast (KStrOut[itCount])); sl@0: test(clss == KClass[itCount]); sl@0: it.Next(); sl@0: ++itCount; sl@0: } sl@0: } sl@0: } sl@0: test(itCount == ARRAY_SIZE(KStrOut)); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-0100 sl@0: @SYMTestCaseDesc TFoldedCanonicalIterator functionality tested on 1 character sequence. sl@0: @SYMTestPriority High sl@0: @SYMTestActions TFoldedCanonicalIterator test. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ814 Optimise folded string comparisons. sl@0: */ sl@0: void TestFoldedCanonicalIterator() sl@0: { sl@0: //Character sequence 1: sl@0: //(1) GREEK CAPITAL LETTER BETA - 0x0392 sl@0: //(2) COMBINING GRAVE ACCENT - 0x0300 sl@0: //(3) COMBINING GRAVE ACCENT BELOW - 0x0316 sl@0: //(4) GREEK CAPITAL LETTER GAMMA - 0x0393 sl@0: //(5) HEBREW POINT TSERE - 0x05B5 sl@0: //(6) TIBETAN MARK HALANTA - 0x0F84 sl@0: //(7) MUSICAL SYMBOL EIGHTH NOTE - 0x1D161 (D834, DD61) sl@0: //(8) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5 sl@0: //Decompositions: sl@0: //0x0392 to 0x03B2 sl@0: //0x0316 to 0x0316 sl@0: //0x0300 to 0x0300 sl@0: //0x0393 to 0x03B3 sl@0: //0x0F84 to 0x0F84 sl@0: //0x05B5 to 0x05B5 sl@0: //0x1D161 to 0x1D158 0x1D165 0x1D16F sl@0: //0x01D5 to 0x0075 0x0308 0x0304 sl@0: const TText16 KStr[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0x0F84, 0xD834, 0xDD61, 0x01D5}; sl@0: const TUint32 KStrOut[] = {0x03B2, 0x0316, 0x0300, 0x03B3, 0x0F84, 0x05B5, 0x1D158, 0x1D165, 0x1D16F, 0x0075, 0x0308, 0x0304}; sl@0: TestPrintCaption(_L("TFoldedCanonicalIterator"), KStr, ARRAY_SIZE(KStr)); sl@0: TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); sl@0: TFoldedCanonicalIterator it(itSrc); sl@0: TInt itCount = 0; sl@0: sl@0: const TUnicodeDataSet* charDataSet = GetLocaleCharSet()->iCharDataSet; sl@0: sl@0: for(;!it.AtEnd();++itCount, it.Next(charDataSet)) sl@0: { sl@0: TChar ch = it.Current(); sl@0: test(ch == static_cast (KStrOut[itCount])); sl@0: RDebug::Print(_L("%04X "), (TUint)ch); sl@0: } sl@0: test(itCount == ARRAY_SIZE(KStrOut)); sl@0: RDebug::Print(_L("\n")); sl@0: sl@0: //10400 sl@0: //103ff sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-0101 sl@0: @SYMTestCaseDesc TDecompositionIterator functionality tested on 1 character sequence sl@0: @SYMTestPriority High sl@0: @SYMTestActions TDecompositionIterator test. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ814 Optimise folded string comparisons. sl@0: */ sl@0: void TestDecompositionIterator2() sl@0: { sl@0: //Character sequence 1 sl@0: //LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5 sl@0: //Decomposition: sl@0: //0x01D5 to: 0x0055 0x0308 0x0304 sl@0: const TText16 KStr[] = {0x01D5}; sl@0: const TText16 KStrOut[] = {0x0055, 0x0308, 0x0304}; sl@0: TestPrintCaption(_L("TDecompositionIterator"), KStr, ARRAY_SIZE(KStr)); sl@0: TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); sl@0: TDecompositionIterator it; sl@0: it.Set(itSrc); sl@0: TInt itCount = 0; sl@0: for(;!it.AtEnd(); ++itCount, it.Next()) sl@0: { sl@0: TChar ch = it.Current(); sl@0: test(ch == static_cast (KStrOut[itCount])); sl@0: RDebug::Print(_L("%04X "), (TUint)ch); sl@0: } sl@0: test(itCount == ARRAY_SIZE(KStrOut)); sl@0: RDebug::Print(_L("\n")); sl@0: sl@0: // Character sequence 2 sl@0: // MUSICAL SYMBOL THIRTY-SECOND NOTE - 0x1D162 (D834, DD62) sl@0: // Decomposition: sl@0: // 0x1D162 to: 0x1D15F 0x1D170, then to: 0x1D158 0x1D165 0x1D170 sl@0: const TText16 KStr2[] = {0xD834, 0xDD62}; sl@0: const TUint32 KStrOut2[] = {0x1D158, 0x1D165, 0x1D170}; sl@0: TestPrintCaption(_L("TDecompositionIterator"), KStr2, ARRAY_SIZE(KStr2)); sl@0: TUTF32Iterator itSrc2(KStr2, KStr2 + ARRAY_SIZE(KStr2)); sl@0: TDecompositionIterator it2; sl@0: it2.Set(itSrc2); sl@0: TInt itCount2 = 0; sl@0: for(;!it2.AtEnd(); ++itCount2, it2.Next()) sl@0: { sl@0: TChar ch = it2.Current(); sl@0: //test.Printf(_L(" expect = %08X, result = %08X\n"), KStrOut2[itCount2], ch); sl@0: test(ch == KStrOut2[itCount2]); sl@0: RDebug::Print(_L("%04X "), (TUint)ch); sl@0: } sl@0: test(itCount2 == ARRAY_SIZE(KStrOut2)); sl@0: RDebug::Print(_L("\n")); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-0102 sl@0: @SYMTestCaseDesc TCanonicalDecompositionIterator functionality tested on 1 character sequence sl@0: @SYMTestPriority High sl@0: @SYMTestActions TCanonicalDecompositionIterator test. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ814 Optimise folded string comparisons. sl@0: */ sl@0: void TestCanonicalDecompositionIterator2() sl@0: { sl@0: //Character sequence 1 sl@0: //(1) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5 sl@0: //(2) MUSICAL SYMBOL THIRTY-SECOND NOTE - 0x1D162 (D834, DD62) sl@0: //Decomposition: sl@0: //0x01D5 to: 0x0055 0x0308 0x0304 sl@0: //0x1D162 to: 0x1D15F 0x1D170, then to: 0x1D158 0x1D165 0x1D170 sl@0: const TText16 KStr[] = {0x01D5, 0xD834, 0xDD62}; sl@0: const TUint32 KStrOut[] = {0x0055, 0x0308, 0x0304, 0x1D158, 0x1D165, 0x1D170}; sl@0: TestPrintCaption(_L("TCanonicalDecompositionIterator"), KStr, ARRAY_SIZE(KStr)); sl@0: TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); sl@0: TCanonicalDecompositionIterator it; sl@0: it.Set(itSrc); sl@0: TInt itCount = 0; sl@0: for(;!it.AtEnd();++itCount, it.Next()) sl@0: { sl@0: TChar ch = it.Current(); sl@0: test(ch == static_cast (KStrOut[itCount])); sl@0: RDebug::Print(_L("%04X "), (TUint)ch); sl@0: } sl@0: test(itCount == ARRAY_SIZE(KStrOut)); sl@0: RDebug::Print(_L("\n")); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-0103 sl@0: @SYMTestCaseDesc TCanonicalDecompositionIteratorCached functionality tested on 1 character sequence sl@0: @SYMTestPriority High sl@0: @SYMTestActions TCanonicalDecompositionIteratorCached test. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ814 Optimise folded string comparisons. sl@0: */ sl@0: void TestCanonicalDecompositionIteratorCached() sl@0: { sl@0: //Character sequence 1 sl@0: //(1) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5 sl@0: //(2) MUSICAL SYMBOL THIRTY-SECOND NOTE - 0x1D162 (D834, DD62) sl@0: //Decomposition: sl@0: //0x01D5 to: 0x0055 0x0308 0x0304 sl@0: //0x1D162 to: 0x1D15F 0x1D170, then to: 0x1D158 0x1D165 0x1D170 sl@0: const TText16 KStr[] = {0x01D5, 0xD834, 0xDD62}; sl@0: const TUint32 KStrOut[] = {0x0055, 0x0308, 0x0304, 0x1D158, 0x1D165, 0x1D170}; sl@0: TestPrintCaption(_L("TCanonicalDecompositionIteratorCached"), KStr, ARRAY_SIZE(KStr)); sl@0: TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); sl@0: TCanonicalDecompositionIteratorCached it; sl@0: it.Set(itSrc); sl@0: TInt itCount = 0; sl@0: for(;!it.AtEnd();++itCount, it.Next(1)) sl@0: { sl@0: TChar ch = it.Get(0); sl@0: test(ch == static_cast (KStrOut[itCount])); sl@0: RDebug::Print(_L("%04X "), (TUint)ch); sl@0: } sl@0: test(itCount == ARRAY_SIZE(KStrOut)); sl@0: RDebug::Print(_L("\n")); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-0104 sl@0: @SYMTestCaseDesc TDecompositionIterator test sl@0: @SYMTestPriority High sl@0: @SYMTestActions TDecompositionIterator test. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ814 Optimise folded string comparisons. sl@0: */ sl@0: void TestDecompositionIterator() sl@0: { sl@0: TDecompositionIterator i; sl@0: sl@0: // test basic character handling sl@0: TUTF32Iterator i1(KHelloT().Ptr(), KHelloT().Ptr() + KHelloT().Length()); sl@0: i.Set(i1); sl@0: TestIteratorOutput(i, KHelloT); sl@0: sl@0: TUTF32Iterator i2(KHelloT().Ptr() + 3, KHelloT().Ptr() + KHelloT().Length()); sl@0: i.Set(i2); sl@0: TestIteratorOutput(i, KHelloT().Mid(3)); sl@0: sl@0: // test combining characters sl@0: TUTF32Iterator i3(KLatin1AccentsC().Ptr(), KLatin1AccentsC().Ptr() + KLatin1AccentsC().Length()); sl@0: i.Set(i3); sl@0: TestIteratorOutput(i, KLatin1AccentsD); sl@0: sl@0: TUTF32Iterator i4(KGreekAccentsC().Ptr(), KGreekAccentsC().Ptr() + KGreekAccentsC().Length()); sl@0: i.Set(i4); sl@0: TestIteratorOutput(i, KGreekAccentsD); sl@0: sl@0: TUTF32Iterator i5(KGreekAccentsS().Ptr(), KGreekAccentsS().Ptr() + KGreekAccentsS().Length()); sl@0: i.Set(i5); sl@0: TestIteratorOutput(i, KGreekAccentsD); sl@0: sl@0: // test that full-width variants are not fiddled with sl@0: TUTF32Iterator i6(KFullWidth().Ptr(), KFullWidth().Ptr() + KFullWidth().Length()); sl@0: i.Set(i6); sl@0: TestIteratorOutput(i, KFullWidth); sl@0: sl@0: TUTF32Iterator i7(KSurrogates().Ptr(), KSurrogates().Ptr() + KSurrogates().Length()); sl@0: i.Set(i7); sl@0: TestIteratorOutput(i, KSurrogatesTest); sl@0: } sl@0: sl@0: //The function collects collation keys at the specified level aLevel from aIt iterator sl@0: //and stores them in aBuf output parameter. sl@0: //aExpectedNumKeys value specifies the count of expected collation keys. sl@0: void GetKeys(TCollationValueIterator& aIt, TUint32* aBuf, TInt aLevel, TInt aExpectedNumKeys) sl@0: { sl@0: //Zero the output parameter sl@0: Mem::FillZ(aBuf, sizeof(TUint32) * aExpectedNumKeys); sl@0: //Get the keys sl@0: TInt i = 0; sl@0: for(;i!=aExpectedNumKeys;++i) sl@0: { sl@0: for (;;) sl@0: { sl@0: (void)aIt.GetCurrentKey(aLevel, aBuf[i]); sl@0: test(aIt.Increment()); sl@0: if(aBuf[i] != 0) sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: //The rest of the keys at that level should have 0 value. sl@0: for(;aIt.Increment();) sl@0: { sl@0: TUint32 key = 0; sl@0: (void)aIt.GetCurrentKey(aLevel, key); sl@0: test(key == 0); sl@0: } sl@0: } sl@0: sl@0: //The function collects the raw keys from aIt iterator and stores them in aBuf output parameter. sl@0: //aExpectedNumKeys value specifies the count of expected raw collation keys. sl@0: void GetRawKeys(TCollationValueIterator& aIt, TCollationKey* aBuf, TInt aExpectedNumKeys) sl@0: { sl@0: //Zero the output parameter sl@0: Mem::FillZ(aBuf, sizeof(TCollationKey) * aExpectedNumKeys); sl@0: //Get the keys sl@0: for(TInt i=0;i!=aExpectedNumKeys;++i) sl@0: { sl@0: test(aIt.GetCurrentKey(aBuf[i])); sl@0: aIt.Increment(); sl@0: } sl@0: //One additional GetCurrentKey() call. Because there shouldn't be more raw keys than sl@0: //aExpectedNumKeys, the call should fail returning EFalse. sl@0: TCollationKey dummy; sl@0: test(!aIt.GetCurrentKey(dummy)); sl@0: } sl@0: sl@0: //The function gets a sequence of raw collation keys in aBuf parameter and a character number sl@0: //aCharNo in the original string. sl@0: //It returns the position in aBuf where raw collation key sequence for aCharNo starts. sl@0: TInt CharNo2CollKeyPos(const TCollationKey* aBuf, TInt aBufLen, TInt aCharNo) sl@0: { sl@0: TInt starterCnt = 0; sl@0: TInt pos = 0; sl@0: do sl@0: { sl@0: if(aBuf[pos].IsStarter()) sl@0: { sl@0: ++starterCnt; sl@0: } sl@0: } while(starterCnt!=(aCharNo+1) && ++pos!=aBufLen); sl@0: test(pos != aBufLen); sl@0: return pos; sl@0: } sl@0: sl@0: //The function compares aBuf1 and aBuf2 and returns how many elements in aBuf1 differ sl@0: //from the elements in aBuf2 at the same position. sl@0: TInt CountDiscrepancies(TUint32* aBuf1, TUint32* aBuf2, TInt aCount) sl@0: { sl@0: TInt discrepancies = 0; sl@0: for (; aCount; --aCount) sl@0: { sl@0: if (*aBuf1++ != *aBuf2++) sl@0: ++discrepancies; sl@0: } sl@0: return discrepancies; sl@0: } sl@0: sl@0: TInt CountDiscrepancies(TCollationKey* aBuf1, TCollationKey* aBuf2, TInt aCount) sl@0: { sl@0: TInt discrepancies = 0; sl@0: for (; aCount; --aCount) sl@0: { sl@0: if (aBuf1->iHigh != aBuf2->iHigh || aBuf1->iLow != aBuf2->iLow) sl@0: ++discrepancies; sl@0: ++aBuf1; sl@0: ++aBuf2; sl@0: } sl@0: return discrepancies; sl@0: } sl@0: sl@0: _LIT(KAYZAccentsAbove, "\xE0\x301y\x302z\x303\x304"); sl@0: _LIT(KCapitalAYZAccentsAbove, "A\x300\x301Y\x302Z\x303\x304"); sl@0: _LIT(KCapitalYAYZAccentsAbove, "a\x300\x301Y\x302z\x303\x304"); sl@0: _LIT(KABCRuleTest, "abcwabkakb"); sl@0: _LIT(KABCRuleExpected, "eeabkakb"); sl@0: //_LIT(KExhaustCaches, "0123456789ABCDEFexhausted"); sl@0: _LIT(KGreekOPVY1, "\x1f82"); sl@0: _LIT(KGreekOPVY2, "\x1f02\x345"); sl@0: _LIT(KGreekOPVY3, "\x1f00\x300\x345"); sl@0: _LIT(KGreekOPVY4, "\x3b1\x313\x300\x345"); sl@0: _LIT(KGreekOPVY5, "\x3b1\x313\x345\x300"); sl@0: _LIT(KGreekOPVY6, "\x3b1\x345\x313\x300"); sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-0105 sl@0: @SYMTestCaseDesc TCollationValueIterator test sl@0: @SYMTestPriority High sl@0: @SYMTestActions TCollationValueIterator tests sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ814 Optimise folded string comparisons. sl@0: */ sl@0: void TestCollationValueIterator() sl@0: { sl@0: // a funny pair of extra collation rules: w and abc both collate as e. sl@0: TUint32 abcWTLKey[] = {0/* key for 'e' will go here */, sl@0: 0x8ff00101, 0x8ff10101, 0x8ff20101, 0x8ff30101, sl@0: 0x8ff40101, 0x8ff50101, 0x8ff60101}; sl@0: const TUint32 overrideIndex[] = {0x00770000, 0x0E010001, 0x0E400002, 0x0E440003, sl@0: 0x0E810004, 0x0EC10005, 0x0EC20006, 0xEC30007}; sl@0: const TUint16 abcString[4] = {0x0003, 0x0061, 0x0062, 0x0063}; sl@0: const TUint32 abcStringIndex = 0; sl@0: TCollationMethod method; sl@0: method.iId = 0; sl@0: method.iMainTable = StandardCollationMethod(); sl@0: method.iFlags = TCollationMethod::EIgnoreNone; sl@0: TInt charindex; sl@0: for (charindex = 0; method.iMainTable->iIndex[charindex] >> 16 != 'e'; ++charindex) sl@0: { sl@0: } sl@0: abcWTLKey[0] = method.iMainTable->iKey[method.iMainTable->iIndex[charindex] & 0xFFFF]; sl@0: TCollationKeyTable overrideTable = {abcWTLKey, overrideIndex, sizeof(abcWTLKey)/4, abcString, &abcStringIndex, 1}; sl@0: method.iOverrideTable = &overrideTable; sl@0: sl@0: TCollationValueIterator v(method); sl@0: TCollationValueIterator rv(method); sl@0: sl@0: TUint32 buf1[32]; sl@0: TUint32 buf2[32]; sl@0: sl@0: TCollationKey raw1[32]; sl@0: TCollationKey raw2[32]; sl@0: const TInt KRawKeyCnt = 8;//Raw collation key count produced from KAYZAccentsAbove string. sl@0: sl@0: //Get the raw key sequence for the whole KAYZAccentsAbove string. sl@0: TUTF32Iterator it(KAYZAccentsAbove().Ptr(), KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); sl@0: rv.SetSourceIt(it); sl@0: ::GetRawKeys(rv, raw1, KRawKeyCnt); sl@0: sl@0: //KAYZAccentsAbove related constants sl@0: const TInt KBaseCharCnt = 3;//The number of base characters (A, y, z) in KAYZAccentsAbove string. sl@0: const TInt KOrgPosA = 0;//A position in KAYZAccentsAbove sl@0: const TInt KOrgPosY = 2;//y position in KAYZAccentsAbove sl@0: const TInt KOrgPosZ = 4;//z position in KAYZAccentsAbove sl@0: //Find where the collation key sequences start for A, y, z characters in KAYZAccentsAbove string. sl@0: const TInt KCollKeyPosA = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 0); sl@0: const TInt KCollKeyPosY = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 1); sl@0: const TInt KCollKeyPosZ = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 2); sl@0: sl@0: //Get the raw key sequence for character A in KAYZAccentsAbove string. sl@0: it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosA, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); sl@0: rv.SetSourceIt(it); sl@0: ::GetRawKeys(rv, raw2 + KCollKeyPosA, KRawKeyCnt - KCollKeyPosA); sl@0: // sl@0: test(0 == ::CountDiscrepancies(raw1, raw2, KRawKeyCnt)); sl@0: sl@0: //Get the raw key sequence for character Y in KAYZAccentsAbove string. sl@0: it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosY, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); sl@0: rv.SetSourceIt(it); sl@0: ::GetRawKeys(rv, raw2 + KCollKeyPosY, KRawKeyCnt - KCollKeyPosY); sl@0: // sl@0: test(0 == ::CountDiscrepancies(raw1, raw2, KRawKeyCnt)); sl@0: sl@0: //Get the raw key sequence for character Z in KAYZAccentsAbove string. sl@0: it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosZ, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); sl@0: rv.SetSourceIt(it); sl@0: ::GetRawKeys(rv, raw2 + KCollKeyPosZ, KRawKeyCnt - KCollKeyPosZ); sl@0: // sl@0: test(0 == ::CountDiscrepancies(raw1, raw2, KRawKeyCnt)); sl@0: sl@0: //Test starting at different points in the iteration sl@0: sl@0: //Level 0 sl@0: //The whole string sl@0: it = TUTF32Iterator(KAYZAccentsAbove().Ptr(), KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf1, 0, KBaseCharCnt); sl@0: //String from Y pos. sl@0: it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosY, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf2, 0, KBaseCharCnt - 1); sl@0: // sl@0: test(0 == ::CountDiscrepancies(buf1 + 1, buf2, KBaseCharCnt - 1)); sl@0: //String from Z pos. sl@0: it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosZ, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf2, 0, KBaseCharCnt - 2); sl@0: // sl@0: test(0 == ::CountDiscrepancies(buf1 + 2, buf2, KBaseCharCnt - 2)); sl@0: sl@0: //Level 1 sl@0: //KCapitalAYZAccentsAbove is used in this test. sl@0: it = TUTF32Iterator(KCapitalAYZAccentsAbove().Ptr(), KCapitalAYZAccentsAbove().Ptr() + KCapitalAYZAccentsAbove().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetRawKeys(v, raw1, 8); sl@0: const TInt KOrgPosY2 = 3;//Y position in KCapitalAYZAccentsAbove sl@0: const TInt KCollKeyPosY2 = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 1); sl@0: //The whole string sl@0: it = TUTF32Iterator(KCapitalAYZAccentsAbove().Ptr(), KCapitalAYZAccentsAbove().Ptr() + KCapitalAYZAccentsAbove().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf1, 1, 8); sl@0: //String from Y pos. sl@0: it = TUTF32Iterator(KCapitalAYZAccentsAbove().Ptr() + KOrgPosY2, KCapitalAYZAccentsAbove().Ptr() + KCapitalAYZAccentsAbove().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf2, 1, 8 - KCollKeyPosY2); sl@0: // sl@0: test(0 == ::CountDiscrepancies(buf1 + KCollKeyPosY2, buf2, 8 - KCollKeyPosY2)); sl@0: sl@0: //Level 2 sl@0: //Capitals do not match at level 2 sl@0: it = TUTF32Iterator(KAYZAccentsAbove().Ptr(), KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf1, 2, 8); sl@0: it = TUTF32Iterator(KCapitalYAYZAccentsAbove().Ptr(), KCapitalYAYZAccentsAbove().Ptr() + KCapitalYAYZAccentsAbove().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf2, 2, 8); sl@0: // sl@0: test(1 == CountDiscrepancies(buf1, buf2, 8)); sl@0: test(buf1[3] != buf2[3]); sl@0: sl@0: //Test funny collation keys, when they succeed and when they fail half way. sl@0: it = TUTF32Iterator(KABCRuleTest().Ptr(), KABCRuleTest().Ptr() + KABCRuleTest().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf1, 0, 8); sl@0: it = TUTF32Iterator(KABCRuleExpected().Ptr(), KABCRuleExpected().Ptr() + KABCRuleExpected().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf2, 0, 8); sl@0: // sl@0: test(0 == ::CountDiscrepancies(buf1, buf2, 8)); sl@0: sl@0: //Test different decompositions at level 3 sl@0: it = TUTF32Iterator(KGreekOPVY1().Ptr(), KGreekOPVY1().Ptr() + KGreekOPVY1().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf1, 3, 4); sl@0: // sl@0: it = TUTF32Iterator(KGreekOPVY2().Ptr(), KGreekOPVY2().Ptr() + KGreekOPVY2().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf2, 3, 4); sl@0: // sl@0: test(0 == ::CountDiscrepancies(buf1, buf2, 4)); sl@0: // sl@0: it = TUTF32Iterator(KGreekOPVY3().Ptr(), KGreekOPVY3().Ptr() + KGreekOPVY3().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf2, 3, 4); sl@0: // sl@0: test(0 == ::CountDiscrepancies(buf1, buf2, 4)); sl@0: // sl@0: it = TUTF32Iterator(KGreekOPVY4().Ptr(), KGreekOPVY4().Ptr() + KGreekOPVY4().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf2, 3, 4); sl@0: // sl@0: test(0 == ::CountDiscrepancies(buf1, buf2, 4)); sl@0: // sl@0: it = TUTF32Iterator(KGreekOPVY5().Ptr(), KGreekOPVY5().Ptr() + KGreekOPVY5().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf2, 3, 4); sl@0: // sl@0: test(0 == ::CountDiscrepancies(buf1, buf2, 4)); sl@0: // sl@0: it = TUTF32Iterator(KGreekOPVY6().Ptr(), KGreekOPVY6().Ptr() + KGreekOPVY6().Length()); sl@0: v.SetSourceIt(it); sl@0: ::GetKeys(v, buf2, 3, 4); sl@0: // sl@0: test(0 == ::CountDiscrepancies(buf1, buf2, 4)); sl@0: } sl@0: sl@0: // folding tests sl@0: sl@0: // equivalence classes: all codes that fold to the same letter (which must be present sl@0: // in the list). The lists are separated by -1. The end is marked with two -1s. sl@0: // Each list must be in increasing order. sl@0: TInt FoldingEquivalenceClasses[] = sl@0: { sl@0: 'A', 'a', -1, 'Z', 'z', -1, '@', -1, '[', -1, '{', -1, 127, -1, 'I', 'i', 0x131, -1, 0, -1, sl@0: ' ', 0xA0, -1, sl@0: 0x300, -1, 0x301, -1, sl@0: 0x141, 0x142, -1, sl@0: 0x1c4, 0x1c5, 0x1c6, -1, 0x1c7, 0x1c8, 0x1c9, -1, 0x1ca, 0x1cb, 0x1cc, -1, sl@0: 0x1f1, 0x1f2, 0x1f3, -1, 0x3a3, 0x3c2, 0x3c3, 0x3f2, -1, sl@0: 0x402, 0x452, -1, 0x40F, 0x45F, -1, 0x460, 0x461, -1, 0x480, 0x481, -1, 0x482, -1, sl@0: 0x410, 0x430, -1, 0x42F, 0x44f, -1, 0x48C, 0x48D, -1, 0x4e8, 0x4e9, -1, sl@0: 0x531, 0x561, -1, 0x556, 0x586, -1, 0x559, -1, 0x55f, -1, -1 sl@0: }; sl@0: sl@0: //_LIT(KMatchLeadingCandidate1, "\xE1\x65\x300\x301\x302\x303pqa\x301"); sl@0: //_LIT(KNoQMs, "a???"); sl@0: //_LIT(KOneQM, "?a"); sl@0: //_LIT(KTwoQMs, "??"); sl@0: //_LIT(KThreeQMs, "???*?"); sl@0: sl@0: //Constructs TUTF32Iterator iterator from aStr sl@0: TUTF32Iterator UTF32It(const TDesC16& aStr) sl@0: { sl@0: return TUTF32Iterator(aStr.Ptr(), aStr.Ptr() + aStr.Length()); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-0107 sl@0: @SYMTestCaseDesc MatchSectionFolded test sl@0: @SYMTestPriority High sl@0: @SYMTestActions MatchSectionFolded test sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ814 Optimise folded string comparisons. sl@0: */ sl@0: void MatchSectionFoldedTest() sl@0: { sl@0: TUTF32Iterator candidateIt, searchTermIt; sl@0: sl@0: candidateIt = UTF32It(_L16("\xE1")); sl@0: searchTermIt = UTF32It(_L16("a")); sl@0: test(!MatchSectionFolded(candidateIt, searchTermIt)); sl@0: sl@0: candidateIt = UTF32It(_L16("a")); sl@0: searchTermIt = UTF32It(_L16("\xE1")); sl@0: test(!MatchSectionFolded(candidateIt, searchTermIt)); sl@0: sl@0: candidateIt = UTF32It(_L16("abca\xE1\x62\x62\x61\x61\x61\x62\x63\x62\x61")); sl@0: searchTermIt = UTF32It(_L16("aBc")); sl@0: test(MatchSectionFolded(candidateIt, searchTermIt)); sl@0: test(searchTermIt.AtEnd()); sl@0: TPtrC16 p1(_L16("a\xE1\x62\x62\x61\x61\x61\x62\x63\x62\x61")); sl@0: TPtrC16 p2(candidateIt.CurrentPosition(), 11); sl@0: test(p1 == p2); sl@0: sl@0: candidateIt = UTF32It(_L16("aaaacdeiooo")); sl@0: searchTermIt = UTF32It(_L16("acde")); sl@0: test(!MatchSectionFolded(candidateIt, searchTermIt)); sl@0: } sl@0: sl@0: //FindMatchSectionFolded test sl@0: void DoFindMatchSectionFoldedTest(const TDesC16& aCandidate, const TDesC16& aSearchTerm, TInt aPos) sl@0: { sl@0: TUTF32Iterator candidateIt, searchTermIt; sl@0: candidateIt = UTF32It(aCandidate); sl@0: searchTermIt = UTF32It(aSearchTerm); sl@0: if(aPos >= 0) sl@0: { sl@0: test(FindMatchSectionFolded(candidateIt, searchTermIt)); sl@0: test(searchTermIt.AtEnd()); sl@0: } sl@0: else sl@0: { sl@0: test(!FindMatchSectionFolded(candidateIt, searchTermIt)); sl@0: } sl@0: } sl@0: sl@0: //This class is used for reading lines from the unicode data file. sl@0: class RUnicodeTestDataFile sl@0: { sl@0: public: sl@0: RUnicodeTestDataFile(); sl@0: void OpenLC(); sl@0: void Close(); sl@0: TBool NextStmt(TPtrC8& aStmt); sl@0: private: sl@0: HBufC8* iFileData; sl@0: TInt iStartPos; sl@0: }; sl@0: sl@0: RUnicodeTestDataFile::RUnicodeTestDataFile() : sl@0: iFileData(NULL), sl@0: iStartPos(0) sl@0: { sl@0: } sl@0: sl@0: void RUnicodeTestDataFile::OpenLC() sl@0: { sl@0: __ASSERT_ALWAYS(!iFileData && !iStartPos, User::Invariant()); sl@0: iFileData = NULL; sl@0: iStartPos = 0; sl@0: CleanupClosePushL(*this); sl@0: sl@0: RFs fileSess; sl@0: CleanupClosePushL(fileSess); sl@0: User::LeaveIfError(fileSess.Connect()); sl@0: sl@0: RFile file; sl@0: CleanupClosePushL(file); sl@0: User::LeaveIfError(file.Open(fileSess, KUnicodeTestDataFile, EFileRead)); sl@0: sl@0: TInt fileSize; sl@0: User::LeaveIfError(file.Size(fileSize)); sl@0: __ASSERT_ALWAYS(fileSize > 0, User::Invariant()); sl@0: sl@0: iFileData = HBufC8::NewL(fileSize + 1); sl@0: sl@0: TPtr8 p = iFileData->Des(); sl@0: User::LeaveIfError(file.Read(p)); sl@0: sl@0: CleanupStack::PopAndDestroy(2, &fileSess); sl@0: } sl@0: sl@0: void RUnicodeTestDataFile::Close() sl@0: { sl@0: delete iFileData; sl@0: iFileData = NULL; sl@0: iStartPos = 0; sl@0: } sl@0: sl@0: TBool RUnicodeTestDataFile::NextStmt(TPtrC8& aStmt) sl@0: { sl@0: aStmt.Set(NULL, 0); sl@0: if(iStartPos < iFileData->Length()) sl@0: { sl@0: const TUint8* pStart = iFileData->Des().Ptr() + iStartPos; sl@0: const TUint8* pEnd = pStart; sl@0: while(*pEnd++ != 0x0A) sl@0: { sl@0: } sl@0: iStartPos += pEnd - pStart; sl@0: aStmt.Set(pStart, pEnd - pStart - 1); sl@0: return ETrue; sl@0: } sl@0: return EFalse; sl@0: } sl@0: sl@0: //Get a field "aFieldNo" from "aStr" statement containing encoded unicode character data sl@0: TPtrC8 GetUnicodeDataField(const TPtrC8& aStr, TInt aFieldNo) sl@0: { sl@0: const TUint8* pStart = aStr.Ptr(); sl@0: //Find the beginning of the field sl@0: TInt count = 0; sl@0: while(count < aFieldNo) sl@0: { sl@0: if(*pStart++ == ';') sl@0: { sl@0: ++count; sl@0: } sl@0: } sl@0: //Find the end of the field sl@0: const TUint8* pEnd = pStart; sl@0: while(*pEnd++ != ';') sl@0: { sl@0: } sl@0: //Construct a string from the field data sl@0: TPtrC8 ptr(pStart, pEnd - pStart - 1); sl@0: return ptr; sl@0: } sl@0: sl@0: //Construct a string "aStr" with the extracted hex codes from "aUnicodeData" sl@0: //The extracted unicodes are placed not from position 0, because some of sl@0: //the decomposable unicode characters are combining characters. If "aStr" is a search sl@0: //string, then the searching algorithm will not work. sl@0: void FillStringL(TDes16& aStr, const TDesC8& aUnicodeData) sl@0: { sl@0: aStr.SetLength(aStr.MaxLength()); sl@0: TLex8 lex(aUnicodeData); sl@0: TInt len = 0; sl@0: for(len=0;!lex.Eos();++len) sl@0: { sl@0: TUint32 code; sl@0: User::LeaveIfError(lex.Val(code, EHex)); sl@0: lex.Assign(lex.NextToken()); sl@0: if (!IsSupplementary(code)) sl@0: { sl@0: aStr[1+len] = (TUint16)code; sl@0: } sl@0: else sl@0: { sl@0: aStr[1+len] = GetHighSurrogate(code); sl@0: ++len; sl@0: aStr[1+len] = GetLowSurrogate(code); sl@0: } sl@0: } sl@0: __ASSERT_ALWAYS(len > 0, User::Invariant()); sl@0: aStr.SetLength(1 + len); sl@0: } sl@0: sl@0: //Get the character unicode, which is at position 0 sl@0: TUint32 GetChCodeL(const TDesC8& aStr) sl@0: { sl@0: TLex8 lex(aStr); sl@0: TUint32 chCode; sl@0: User::LeaveIfError(lex.Val(chCode, EHex)); sl@0: return chCode; sl@0: } sl@0: sl@0: //Simple unicode folding tests sl@0: void FindMatchSectionFoldedTestSimple() sl@0: { sl@0: _LIT16(KCandidate, "abca\xE1\x62\x62\x61\x61\x61\x62\x63\x62\x61"); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("abc"), 0); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("abb"), -1); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("caa"), -1); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("abcb"), 9); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("\xE1"), 4); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("a\x301"), 4); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("A\xC1\x42\x42"), 3); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("a\x301\x42\x42"), 4); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("a?BB"), 3); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L(""), 0); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("?"), 0); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("??????????????"), 0); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("???????????????"), -1); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("????a?????????"), -1); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("???a??????????"), 0); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("caa?"), -1); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("abcb?"), 9); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("abcb??"), -1); sl@0: DoFindMatchSectionFoldedTest(KCandidate, _L("b?aa"), 5); sl@0: } sl@0: sl@0: //Extended tests - all characters, having non-zero "character decomposition mapping" field sl@0: //or non-zero "upper case mapping" field sl@0: void FindMatchSectionFoldedTestComplexL() sl@0: { sl@0: TBuf16<10> candidate; sl@0: candidate.Copy(_L16("abcdefghij")); sl@0: TBuf16<10> searchTerm; sl@0: searchTerm.Copy(_L16("eeeeefghij")); sl@0: const TInt KChPos = 5; sl@0: //Read and parse each line from the unicode data file. sl@0: RUnicodeTestDataFile unicodeTestDataFile; sl@0: unicodeTestDataFile.OpenLC(); sl@0: TPtrC8 stmt; sl@0: while(unicodeTestDataFile.NextStmt(stmt) && stmt.Length() > 0) sl@0: { sl@0: //Get the character code sl@0: TUint32 chCode = GetChCodeL(stmt); sl@0: //"LATIN CAPITAL LETTER I WITH DOT ABOVE" - the searching algorithm does not work with it. sl@0: if(chCode == (TUint32)0x0130) sl@0: { sl@0: continue; sl@0: } sl@0: if (!IsSupplementary(chCode)) sl@0: { sl@0: candidate[KChPos] = (TUint16)chCode; sl@0: } sl@0: else sl@0: { sl@0: candidate[KChPos] = GetHighSurrogate(chCode); sl@0: candidate[KChPos+1] = GetLowSurrogate(chCode); sl@0: } sl@0: //"Character decomposition mapping" is the 5th field, starting from 0. sl@0: TPtrC8 decomp(GetUnicodeDataField(stmt, 5)); sl@0: if(decomp.Length() > 1 && decomp[0] != '<') sl@0: { sl@0: //This character has valid decomposition mapping - test it. sl@0: //Construct the search string sl@0: FillStringL(searchTerm, decomp); sl@0: //Test sl@0: DoFindMatchSectionFoldedTest(candidate, searchTerm, KChPos); sl@0: } sl@0: //"Uppercase mapping" is the 12th field, starting from 0. sl@0: TPtrC8 upperc(GetUnicodeDataField(stmt, 12)); sl@0: if(upperc.Length() > 1) sl@0: { sl@0: //This character has valid uppercase mapping - test it. sl@0: //Construct the search string sl@0: FillStringL(searchTerm, upperc); sl@0: //Test sl@0: DoFindMatchSectionFoldedTest(candidate, searchTerm, KChPos); sl@0: } sl@0: }//end of "while" - for each file statement sl@0: CleanupStack::PopAndDestroy(&unicodeTestDataFile); sl@0: } sl@0: sl@0: //MatchStringFolded test sl@0: void MatchStringFoldedTestL() sl@0: { sl@0: TBuf16<3> candidate; sl@0: candidate.Copy(_L16("aa")); sl@0: TBuf16<10> searchTerm; sl@0: searchTerm.Copy(_L16("aaaaaaaaaa")); sl@0: const TInt KChPos = 1; sl@0: //Read and parse each line from the unicode data file. sl@0: RUnicodeTestDataFile unicodeTestDataFile; sl@0: unicodeTestDataFile.OpenLC(); sl@0: TPtrC8 stmt; sl@0: while(unicodeTestDataFile.NextStmt(stmt) && stmt.Length() > 0) sl@0: { sl@0: //Get the character code sl@0: TUint32 chCode = GetChCodeL(stmt); sl@0: //"LATIN CAPITAL LETTER I WITH DOT ABOVE" - the searching algorithm does not work with it. sl@0: if(chCode == (TUint32)0x0130) sl@0: { sl@0: continue; sl@0: } sl@0: if (!IsSupplementary(chCode)) sl@0: { sl@0: candidate[KChPos] = (TUint16)chCode; sl@0: candidate.SetLength(2); sl@0: } sl@0: else sl@0: { sl@0: candidate[KChPos] = GetHighSurrogate(chCode); sl@0: candidate.SetLength(3); sl@0: candidate[KChPos+1] = GetLowSurrogate(chCode); sl@0: } sl@0: //"Character decomposition mapping" is the 5th field, starting from 0. sl@0: TPtrC8 decomp(GetUnicodeDataField(stmt, 5)); sl@0: if(decomp.Length() > 1 && decomp[0] != '<') sl@0: { sl@0: //This character has valid decomposition mapping - test it. sl@0: //Construct the search string sl@0: FillStringL(searchTerm, decomp); sl@0: //Test sl@0: test(MatchStringFolded(candidate.Ptr(), candidate.Ptr() + candidate.Length(), sl@0: searchTerm.Ptr(), searchTerm.Ptr() + searchTerm.Length())); sl@0: } sl@0: //"Uppercase mapping" is the 12th field, starting from 0. sl@0: TPtrC8 upperc(GetUnicodeDataField(stmt, 12)); sl@0: if(upperc.Length() > 1) sl@0: { sl@0: //This character has valid uppercase mapping - test it. sl@0: //Construct the search string sl@0: FillStringL(searchTerm, upperc); sl@0: //Test sl@0: test(MatchStringFolded(candidate.Ptr(), candidate.Ptr() + candidate.Length(), sl@0: searchTerm.Ptr(), searchTerm.Ptr() + searchTerm.Length())); sl@0: } sl@0: }//end of "while" - for each file statement sl@0: CleanupStack::PopAndDestroy(&unicodeTestDataFile); sl@0: } sl@0: sl@0: void FindMatchSectionFoldedTestL() sl@0: { sl@0: FindMatchSectionFoldedTestSimple(); sl@0: FindMatchSectionFoldedTestComplexL(); sl@0: } sl@0: sl@0: void TestFindMatchFoldedL() sl@0: { sl@0: MatchSectionFoldedTest(); sl@0: FindMatchSectionFoldedTestL(); sl@0: MatchStringFoldedTestL(); sl@0: } sl@0: sl@0: void TestCompareFoldedEqual(const TDesC& a, const TDesC& b) sl@0: { sl@0: test(a.CompareF(b) == 0); sl@0: test(b.CompareF(a) == 0); sl@0: } sl@0: sl@0: void TestCompareFolded() sl@0: { sl@0: // Latin Extended A sl@0: TestCompareFoldedEqual(_L("\x100"), _L("\x101")); sl@0: TestCompareFoldedEqual(_L("\x100"), _L("A\x304")); sl@0: TestCompareFoldedEqual(_L("\x100"), _L("a\x304")); sl@0: TestCompareFoldedEqual(_L("\x104"), _L("\x105")); sl@0: TestCompareFoldedEqual(_L("\x104"), _L("a\x328")); sl@0: TestCompareFoldedEqual(_L("\x107"), _L("C\x301")); sl@0: TestCompareFoldedEqual(_L("\x10F"), _L("\x10E")); sl@0: TestCompareFoldedEqual(_L("\x10F"), _L("D\x30C")); sl@0: TestCompareFoldedEqual(_L("\x110"), _L("\x111")); sl@0: TestCompareFoldedEqual(_L("\x123"), _L("G\x327")); sl@0: TestCompareFoldedEqual(_L("\x132"), _L("\x133")); sl@0: TestCompareFoldedEqual(_L("\x131"), _L("i")); sl@0: TestCompareFoldedEqual(_L("\x131"), _L("I")); sl@0: TestCompareFoldedEqual(_L("i"), _L("I")); sl@0: TestCompareFoldedEqual(_L("\x13F"), _L("\x140")); sl@0: TestCompareFoldedEqual(_L("\x141"), _L("\x142")); sl@0: TestCompareFoldedEqual(_L("\x14A"), _L("\x14B")); sl@0: TestCompareFoldedEqual(_L("\x150"), _L("\x151")); sl@0: TestCompareFoldedEqual(_L("\x150"), _L("o\x30B")); sl@0: TestCompareFoldedEqual(_L("\x152"), _L("\x153")); sl@0: TestCompareFoldedEqual(_L("\x17D"), _L("\x17E")); sl@0: TestCompareFoldedEqual(_L("\x17D"), _L("z\x30C")); sl@0: // Latin Extended B sl@0: TestCompareFoldedEqual(_L("\x182"), _L("\x183")); sl@0: TestCompareFoldedEqual(_L("\x184"), _L("\x185")); sl@0: TestCompareFoldedEqual(_L("\x187"), _L("\x188")); sl@0: TestCompareFoldedEqual(_L("\x18A"), _L("\x257")); sl@0: TestCompareFoldedEqual(_L("\x194"), _L("\x263")); sl@0: TestCompareFoldedEqual(_L("\x195"), _L("\x1F6")); sl@0: TestCompareFoldedEqual(_L("\x196"), _L("\x269")); sl@0: TestCompareFoldedEqual(_L("\x1A2"), _L("\x1A3")); sl@0: TestCompareFoldedEqual(_L("\x1A6"), _L("\x280")); sl@0: TestCompareFoldedEqual(_L("\x1BF"), _L("\x1F7")); sl@0: TestCompareFoldedEqual(_L("\x1DC"), _L("\x1DB")); sl@0: TestCompareFoldedEqual(_L("\x1DC"), _L("u\x308\x300")); sl@0: TestCompareFoldedEqual(_L("\x1DD"), _L("\x18E")); sl@0: TestCompareFoldedEqual(_L("\x1EC"), _L("\x1ED")); sl@0: TestCompareFoldedEqual(_L("\x1FC"), _L("\x1FD")); sl@0: TestCompareFoldedEqual(_L("\x200"), _L("\x201")); sl@0: TestCompareFoldedEqual(_L("\x216"), _L("u\x311")); sl@0: TestCompareFoldedEqual(_L("\x21B"), _L("T\x326")); sl@0: TestCompareFoldedEqual(_L("\x21C"), _L("\x21D")); sl@0: TestCompareFoldedEqual(_L("\x229"), _L("E\x327")); sl@0: TestCompareFoldedEqual(_L("\x22A"), _L("\x22B")); sl@0: TestCompareFoldedEqual(_L("\x22A"), _L("O\x308\x304")); sl@0: TestCompareFoldedEqual(_L("\x22A"), _L("\xF6\x304")); sl@0: TestCompareFoldedEqual(_L("\x233"), _L("y\x304")); sl@0: TestCompareFoldedEqual(_L("\x233"), _L("\x232")); sl@0: } sl@0: sl@0: void TestCompareFoldedNotEqual(TDesC& a, TDesC& b, TInt aValue) sl@0: { sl@0: test(a.CompareF(b) == aValue); sl@0: } sl@0: sl@0: static void TestCompareFoldedAdditional() sl@0: { sl@0: const TText16 UnicodeTextOne16[] = {'a', 0}; sl@0: const TText16 ErrUnicodeTextOne16[] = {'[', 0}; sl@0: sl@0: const TText16 UnicodeTextTwo16[] = {0x00EA, 0x0323, 0}; sl@0: const TText16 ErrUnicodeTextTwo16[] = {0x00EA, 't', 0}; sl@0: sl@0: const TText16 UnicodeTextThree16[] = {0x00EA, 0x03B1, 0}; sl@0: const TText16 ErrUnicodeTextThree16[] = {0x00EA, 0x0323, 0}; sl@0: sl@0: TBufC16 oriUnicodeSmallTextOne(UnicodeTextOne16); sl@0: TBufC16 nonMatchUnicodeSmallTextOne(ErrUnicodeTextOne16); sl@0: sl@0: TBufC16 oriUnicodeSmallTextTwo(UnicodeTextTwo16); sl@0: TBufC16 nonMatchUnicodeSmallTextTwo(ErrUnicodeTextTwo16); sl@0: sl@0: TBufC16 oriUnicodeSmallTextThree(UnicodeTextThree16); sl@0: TBufC16 nonMatchUnicodeSmallTextThree(ErrUnicodeTextThree16); sl@0: sl@0: const TText16 AsciiText16[] = {'A', 'B', 'C', 'D', 'E', 0}; sl@0: sl@0: TBufC16<5> oriAsciiSmallText(_L("ABCDE")); sl@0: sl@0: // Check that characters are non matching with return value as stated sl@0: sl@0: TestCompareFoldedNotEqual(oriUnicodeSmallTextOne, nonMatchUnicodeSmallTextOne, 6); sl@0: TestCompareFoldedNotEqual(oriUnicodeSmallTextTwo, nonMatchUnicodeSmallTextTwo, 33); sl@0: TestCompareFoldedNotEqual(oriUnicodeSmallTextThree, nonMatchUnicodeSmallTextThree, -33); sl@0: sl@0: // Try other way around... sl@0: sl@0: TestCompareFoldedNotEqual(nonMatchUnicodeSmallTextOne, oriUnicodeSmallTextOne, -6); sl@0: TestCompareFoldedNotEqual(nonMatchUnicodeSmallTextTwo, oriUnicodeSmallTextTwo, -33); sl@0: TestCompareFoldedNotEqual(nonMatchUnicodeSmallTextThree, oriUnicodeSmallTextThree, 33); sl@0: sl@0: // Declare a TPtrC16 which is base from AsciiText16... sl@0: sl@0: TPtrC16 AsciiSmallText; sl@0: sl@0: AsciiSmallText.Set(AsciiText16, 4); sl@0: sl@0: // Check the boundary case sl@0: sl@0: TestCompareFoldedNotEqual(oriAsciiSmallText, AsciiSmallText, 1); sl@0: sl@0: // Try other way around... sl@0: sl@0: TestCompareFoldedNotEqual(AsciiSmallText, oriAsciiSmallText, -1); sl@0: sl@0: } sl@0: sl@0: void TestFoldingL() sl@0: { sl@0: TestFindMatchFoldedL(); sl@0: TestCompareFolded(); sl@0: TestCompareFoldedAdditional(); sl@0: } sl@0: sl@0: // collation tests sl@0: _LIT(KCandidateString1, "abcdefg"); sl@0: _LIT(KCandidateString2, "\x1f82\x1f02\x345\x1f00\x300\x345\x3b1\x313\x300\x345"); sl@0: _LIT(KCandidateString3, "abcabcdababc"); sl@0: _LIT(KCandidateString4, "xyzxyxyzxyxyyxyzxyy"); sl@0: sl@0: _LIT(KMatch1, "abc"); sl@0: _LIT(KMatch2, "abc*"); sl@0: _LIT(KMatch3, "*abc*"); sl@0: _LIT(KMatch4, "abc*def"); sl@0: _LIT(KMatch5, "abc*def*g*"); sl@0: _LIT(KMatch6, "*def"); sl@0: _LIT(KMatch7, "**d?f?"); sl@0: _LIT(KMatch8, "*d?f??"); sl@0: _LIT(KMatch9, "***d?f??*"); sl@0: _LIT(KMatch10, "a*c*g"); sl@0: _LIT(KMatch11, "*c*g"); sl@0: sl@0: _LIT(KMatch12, "*\x1f82"); sl@0: _LIT(KMatch13, "*\x1f82*"); sl@0: //_LIT(KMatch14, "*\x3b1*"); sl@0: _LIT(KMatch15, "*\x313*"); sl@0: _LIT(KMatch16, "*\x300*"); sl@0: //_LIT(KMatch17, "*\x345*"); sl@0: //_LIT(KMatch18, "*\x3b1\x313*"); sl@0: //_LIT(KMatch19, "*\x3b1\x313\x300*"); sl@0: _LIT(KMatch20, "*\x1f82*\x1f82*\x1f82\x1f82"); sl@0: _LIT(KMatch21, "*\x1f82*\x1f82*\x1f82\x1f82*\x1f82*"); sl@0: sl@0: _LIT(KMatch22, "*aba*"); sl@0: _LIT(KMatch23, "*abc"); sl@0: _LIT(KMatch24, "a*abc"); sl@0: _LIT(KMatch25, "a*ab"); sl@0: _LIT(KMatch26, "*ca*abc"); sl@0: _LIT(KMatch27, "*ca*??c"); sl@0: _LIT(KMatch28, "*??c"); sl@0: _LIT(KMatch29, "a*babc"); sl@0: _LIT(KMatch30, "*xyy"); sl@0: sl@0: _LIT(KFoo1, "foo"); sl@0: _LIT(KPeach, "pe\x302\x63he"); sl@0: _LIT(KFooMatch1, "fo*"); sl@0: _LIT(KFooMatch2, "*Fo*"); sl@0: _LIT(KFooMatch3, "*f*O*o"); sl@0: _LIT(KFooMatch4, "*f*o*o*"); sl@0: _LIT(KFooMatch5, "*o"); sl@0: _LIT(KFooMatch6, "???"); sl@0: _LIT(KFooMatch7, "*?o?*"); sl@0: _LIT(KFooMatch8, "*?"); sl@0: _LIT(KFooNonMatch1, "oo*"); sl@0: _LIT(KFooNonMatch2, "??"); sl@0: _LIT(KFooNonMatch3, "????"); sl@0: _LIT(KFooNonMatch4, "*?f*"); sl@0: _LIT(KFooNonMatch5, "*f*f*"); sl@0: _LIT(KFooNonMatch6, "*?*f*"); sl@0: _LIT(KPeachMatch1, "p?che"); sl@0: _LIT(KPeachNonMatch1, "peche"); sl@0: _LIT(KPeachNonMatch2, "pe?che"); sl@0: _LIT(KPeachNonMatch3, "pe?he"); sl@0: _LIT(KPeachNonMatch4, "pe*"); sl@0: sl@0: void TestMatchIdentifiersTDesC(const TDesC& aCandidate, const TDesC& aSearchTerm, TInt aExpectedResult) sl@0: { sl@0: const TText16* candidateStart = aCandidate.Ptr(); sl@0: const TText16* candidateEnd = candidateStart + aCandidate.Length(); sl@0: const TText16* searchTermStart = aSearchTerm.Ptr(); sl@0: const TText16* searchTermEnd = searchTermStart + aSearchTerm.Length(); sl@0: TInt pos = ::LocateMatchStringFolded(candidateStart, candidateEnd, searchTermStart, searchTermEnd); sl@0: test(aExpectedResult == pos); sl@0: } sl@0: sl@0: void TestMatchIdentifiers() sl@0: { sl@0: TestMatchIdentifiersTDesC(KCandidateString1, KMatch1, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KCandidateString1, KMatch2, 0); sl@0: TestMatchIdentifiersTDesC(KCandidateString1, KMatch3, 0); sl@0: TestMatchIdentifiersTDesC(KCandidateString1, KMatch4, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KCandidateString1, KMatch5, 0); sl@0: TestMatchIdentifiersTDesC(KCandidateString1, KMatch6, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KCandidateString1, KMatch7, 3); sl@0: TestMatchIdentifiersTDesC(KCandidateString1, KMatch8, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KCandidateString1, KMatch9, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KCandidateString1, KMatch10, 0); sl@0: TestMatchIdentifiersTDesC(KCandidateString1, KMatch11, 2); sl@0: TestMatchIdentifiersTDesC(KCandidateString2, KMatch12, 6); sl@0: TestMatchIdentifiersTDesC(KCandidateString2, KMatch13, 0); sl@0: //The next test does not pass with the new optimised methods sl@0: //TestMatchIdentifiersTDesC(KCandidateString2, KMatch14, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KCandidateString2, KMatch15, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KCandidateString2, KMatch16, KErrNotFound); sl@0: // I have taken this test out: it tests that combining ypogegrammeni is not sl@0: // found on its own: but with case folding it can become a non-combining sl@0: // character (iota), so this test is not relevant. sl@0: // TestMatchIdentifiersTDesC(KCandidateString2, KMatch17, KErrNotFound); sl@0: //The next tests do not pass with the new optimised methods sl@0: //TestMatchIdentifiersTDesC(KCandidateString2, KMatch18, KErrNotFound); sl@0: //TestMatchIdentifiersTDesC(KCandidateString2, KMatch19, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KCandidateString2, KMatch20, 0); sl@0: TestMatchIdentifiersTDesC(KCandidateString2, KMatch21, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KCandidateString3, KMatch22, 7); sl@0: TestMatchIdentifiersTDesC(KCandidateString3, KMatch23, 9); sl@0: TestMatchIdentifiersTDesC(KCandidateString3, KMatch24, 0); sl@0: TestMatchIdentifiersTDesC(KCandidateString3, KMatch25, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KCandidateString3, KMatch26, 2); sl@0: TestMatchIdentifiersTDesC(KCandidateString3, KMatch27, 2); sl@0: TestMatchIdentifiersTDesC(KCandidateString3, KMatch28, 9); sl@0: TestMatchIdentifiersTDesC(KCandidateString3, KMatch29, 0); sl@0: TestMatchIdentifiersTDesC(KCandidateString4, KMatch30, 16); sl@0: sl@0: TestMatchIdentifiersTDesC(KFoo1, KFoo1, 0); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooMatch1, 0); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooMatch2, 0); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooMatch3, 0); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooMatch4, 0); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooMatch5, 2); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooMatch6, 0); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooMatch7, 0); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooMatch8, 2); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch1, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch2, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch3, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch4, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch5, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch6, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KPeach, KPeachMatch1, 0); sl@0: TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch1, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch2, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch3, KErrNotFound); sl@0: TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch4, KErrNotFound); sl@0: sl@0: TestMatchIdentifiersTDesC(_L(""), _L(""), 0); sl@0: TestMatchIdentifiersTDesC(_L("a"), _L(""), KErrNotFound); sl@0: TestMatchIdentifiersTDesC(_L(""), _L("*"), 0); sl@0: } sl@0: sl@0: void TestFindIdentifierTDesC(const TDesC& aCandidateString, const TDesC& aSearchTerm, TInt /*aExpectedResult*/) sl@0: { sl@0: TUTF32Iterator candidateIt(aCandidateString.Ptr(), aCandidateString.Ptr() + aCandidateString.Length()); sl@0: TUTF32Iterator searchIt(aSearchTerm.Ptr(), aSearchTerm.Ptr() + aSearchTerm.Length()); sl@0: /*aExpectedResult = */::FindFolded(candidateIt, searchIt); sl@0: } sl@0: sl@0: //INC057641 - NTT Functional BC break in 8.1a: string comparison changed sl@0: static void INC057641L() sl@0: { sl@0: _LIT16(KEmptyText, ""); sl@0: HBufC16* str = HBufC16::NewLC(4); sl@0: str->Des().Copy(_L("****")); sl@0: TInt res = str->CompareC(KEmptyText); sl@0: CleanupStack::PopAndDestroy(str); sl@0: test(res == 1); sl@0: } sl@0: sl@0: _LIT(KFind1, "abc"); sl@0: _LIT(KFind2, "def"); sl@0: _LIT(KFind3, "efg"); sl@0: _LIT(KFind4, "fga"); sl@0: _LIT(KFind5, "acd"); sl@0: _LIT(KFind6, "\x1f82"); sl@0: _LIT(KFind7, "\x3b1\x313\x300\x345"); sl@0: _LIT(KFind8, "\x3b1"); sl@0: _LIT(KFind9, "aba"); sl@0: _LIT(KFind10, "abc"); sl@0: sl@0: void TestFindIdentifier() sl@0: { sl@0: TestFindIdentifierTDesC(KCandidateString1, TPtrC(), 0); sl@0: TestFindIdentifierTDesC(KCandidateString1, KFind1, 0); sl@0: TestFindIdentifierTDesC(KCandidateString1, KFind2, 3); sl@0: TestFindIdentifierTDesC(KCandidateString1, KFind3, 4); sl@0: TestFindIdentifierTDesC(KCandidateString1, KFind4, KErrNotFound); sl@0: TestFindIdentifierTDesC(KCandidateString1, KFind5, KErrNotFound); sl@0: TestFindIdentifierTDesC(KCandidateString2, KFind6, 0); sl@0: TestFindIdentifierTDesC(KCandidateString2, KFind7, 0); sl@0: TestFindIdentifierTDesC(KCandidateString2, KFind8, KErrNotFound); sl@0: TestFindIdentifierTDesC(KCandidateString3, KFind9, 7); sl@0: TestFindIdentifierTDesC(KCandidateString3, KFind10, 0); sl@0: } sl@0: sl@0: struct TestMatch8 sl@0: { sl@0: TText8 const* iLeft; sl@0: TText8 const* iRight; sl@0: TInt iResult; sl@0: }; sl@0: sl@0: TestMatch8 const Tests8[]= sl@0: { sl@0: {_S8(""),_S8(""),0}, sl@0: {_S8(""),_S8("?"),KErrNotFound}, sl@0: {_S8(""),_S8("*"),0}, sl@0: {_S8(""),_S8("**"),0}, sl@0: {_S8(""),_S8("*x*"),KErrNotFound}, sl@0: {_S8("x"),_S8(""),KErrNotFound}, sl@0: {_S8("x"),_S8("?"),0}, sl@0: {_S8("x"),_S8("*"),0}, sl@0: {_S8("x"),_S8("**"),0}, sl@0: {_S8("x"),_S8("**?"),0}, sl@0: {_S8("x"),_S8("?**"),0}, sl@0: {_S8("x"),_S8("**?*"),0}, sl@0: {_S8("x"),_S8("x"),0}, sl@0: {_S8("x"),_S8("a"),KErrNotFound}, sl@0: {_S8("x"),_S8("xx"),KErrNotFound}, sl@0: {_S8("x"),_S8("?x"),KErrNotFound}, sl@0: {_S8("x"),_S8("x*"),0}, sl@0: {_S8("x"),_S8("*x"),0}, sl@0: {_S8("x"),_S8("*x*"),0}, sl@0: {_S8("x"),_S8("**x*"),0}, sl@0: {_S8("abc"),_S8(""),KErrNotFound}, sl@0: {_S8("abc"),_S8("?*"),0}, sl@0: {_S8("abc"),_S8("*?"),2}, sl@0: {_S8("abc"),_S8("*?*?"),0}, sl@0: {_S8("abc"),_S8("*a*"),0}, sl@0: {_S8("abc"),_S8("*b*"),1}, sl@0: {_S8("abc"),_S8("*c*"),2}, sl@0: {_S8("abc"),_S8("*a"),KErrNotFound}, sl@0: {_S8("abc"),_S8("*c"),2}, sl@0: {_S8("abc"),_S8("*?c"),1}, sl@0: {_S8("abc"),_S8("??c"),0}, sl@0: {_S8("abc"),_S8("*b?"),1}, sl@0: }; sl@0: sl@0: struct TestMatch16 sl@0: { sl@0: TText16 const* iLeft; sl@0: TText16 const* iRight; sl@0: TInt iResult; sl@0: }; sl@0: sl@0: TestMatch16 const Tests16[]= sl@0: { sl@0: {_S16(""),_S16(""),0}, sl@0: {_S16(""),_S16("?"),KErrNotFound}, sl@0: {_S16(""),_S16("*"),0}, sl@0: {_S16(""),_S16("**"),0}, sl@0: {_S16(""),_S16("*x*"),KErrNotFound}, sl@0: {_S16("x"),_S16(""),KErrNotFound}, sl@0: {_S16("x"),_S16("?"),0}, sl@0: {_S16("x"),_S16("*"),0}, sl@0: {_S16("x"),_S16("**"),0}, sl@0: {_S16("x"),_S16("**?"),0}, sl@0: {_S16("x"),_S16("?**"),0}, sl@0: {_S16("x"),_S16("**?*"),0}, sl@0: {_S16("x"),_S16("x"),0}, sl@0: {_S16("x"),_S16("a"),KErrNotFound}, sl@0: {_S16("x"),_S16("xx"),KErrNotFound}, sl@0: {_S16("x"),_S16("?x"),KErrNotFound}, sl@0: {_S16("x"),_S16("x*"),0}, sl@0: {_S16("x"),_S16("*x"),0}, sl@0: {_S16("x"),_S16("*x*"),0}, sl@0: {_S16("x"),_S16("**x*"),0}, sl@0: {_S16("abc"),_S16(""),KErrNotFound}, sl@0: {_S16("abc"),_S16("?*"),0}, sl@0: {_S16("abc"),_S16("*?"),2}, sl@0: {_S16("abc"),_S16("*?*?"),0}, sl@0: {_S16("abc"),_S16("*a*"),0}, sl@0: {_S16("abc"),_S16("*b*"),1}, sl@0: {_S16("abc"),_S16("*c*"),2}, sl@0: {_S16("abc"),_S16("*a"),KErrNotFound}, sl@0: {_S16("abc"),_S16("*c"),2}, sl@0: {_S16("abc"),_S16("*?c"),1}, sl@0: {_S16("abc"),_S16("??c"),0}, sl@0: {_S16("abc"),_S16("*b?"),1}, sl@0: {_S16("\x0100"),_S16("\x0100"),0}, sl@0: {_S16("\x0100"),_S16("*"),0}, sl@0: {_S16("\x0100"),_S16("?"),0}, sl@0: {_S16("\x0100"),_S16("*\x0100"),0}, sl@0: {_S16("\x0100"),_S16("*\x0100?"),KErrNotFound}, sl@0: {_S16("\x0101"),_S16("\x0101"),0}, sl@0: {_S16("\x0101"),_S16("*"),0}, sl@0: {_S16("\x0101"),_S16("?"),0}, sl@0: {_S16("\x0101"),_S16("*\x0101"),0}, sl@0: {_S16("\x0101"),_S16("*\x0101?"),KErrNotFound}, sl@0: {_S16("\x0ffe"),_S16("\x0ffe"),0}, sl@0: {_S16("\x0ffe"),_S16("*"),0}, sl@0: {_S16("\x0ffe"),_S16("?"),0}, sl@0: {_S16("\x0ffe"),_S16("*\x0ffe"),0}, sl@0: {_S16("\x0ffe"),_S16("*\x0ffe?"),KErrNotFound}, sl@0: {_S16("\x0fff"),_S16("\x0fff"),0}, sl@0: {_S16("\x0fff"),_S16("*"),0}, sl@0: {_S16("\x0fff"),_S16("?"),0}, sl@0: {_S16("\x0fff"),_S16("*\x0fff"),0}, sl@0: {_S16("\x0fff"),_S16("*\x0fff?"),KErrNotFound}, sl@0: {_S16("\x1000"),_S16("\x1000"),0}, sl@0: {_S16("\x1000"),_S16("*"),0}, sl@0: {_S16("\x1000"),_S16("?"),0}, sl@0: {_S16("\x1000"),_S16("*\x1000"),0}, sl@0: {_S16("\x1000"),_S16("*\x1000?"),KErrNotFound}, sl@0: {_S16("\x1001"),_S16("\x1001"),0}, sl@0: {_S16("\x1001"),_S16("*"),0}, sl@0: {_S16("\x1001"),_S16("?"),0}, sl@0: {_S16("\x1001"),_S16("*\x1001"),0}, sl@0: {_S16("\x1001"),_S16("*\x1001?"),KErrNotFound}, sl@0: // fffe, ffff is special sl@0: //{_S16("\xfffe"),_S16("\xfffe"),0}, sl@0: //{_S16("\xfffe"),_S16("*"),0}, sl@0: //{_S16("\xfffe"),_S16("?"),0}, sl@0: //{_S16("\xfffe"),_S16("*\xfffe"),0}, //reserved sl@0: //{_S16("\xfffe"),_S16("*\xfffe?"),KErrNotFound}, sl@0: //{_S16("\xffff"),_S16("\xffff"),0}, sl@0: //{_S16("\xffff"),_S16("*"),0}, sl@0: //{_S16("\xffff"),_S16("?"),0}, sl@0: //{_S16("\xffff"),_S16("*\xffff?"),KErrNotFound}, sl@0: //{_S16("\x0101\xffff\x0ffe"),_S16("*\xffff"),0}, sl@0: //{_S16("\x0101\xffff\x0ffe"),_S16("*\xffff"),0}, sl@0: //{_S16("\x0101\xfffe\x0ffe"),_S16("\xffff?"),0}, sl@0: //{_S16("\x0101\xfffe\x0ffe"),_S16("*\xffff?"),0}, sl@0: {_S16("\x04fa"),_S16("*"),0}, sl@0: }; sl@0: sl@0: TInt KTests=sizeof(Tests8)/sizeof(Tests8[0]); sl@0: TInt KTests16=sizeof(Tests16)/sizeof(Tests16[0]); sl@0: sl@0: TestMatch16 const TestsSurrogate[]= sl@0: { sl@0: // not duplicate, test MatchSurrogate here sl@0: {_S16(""),_S16(""),0}, sl@0: {_S16(""),_S16("?"),KErrNotFound}, sl@0: {_S16(""),_S16("*"),0}, sl@0: {_S16(""),_S16("**"),0}, sl@0: {_S16(""),_S16("*x*"),KErrNotFound}, sl@0: {_S16("x"),_S16(""),KErrNotFound}, sl@0: {_S16("x"),_S16("?"),0}, sl@0: {_S16("x"),_S16("*"),0}, sl@0: {_S16("x"),_S16("**"),0}, sl@0: {_S16("x"),_S16("**?"),0}, sl@0: {_S16("x"),_S16("?**"),0}, // 10 sl@0: {_S16("x"),_S16("**?*"),0}, sl@0: {_S16("x"),_S16("x"),0}, sl@0: {_S16("x"),_S16("a"),KErrNotFound}, sl@0: {_S16("x"),_S16("xx"),KErrNotFound}, sl@0: {_S16("x"),_S16("?x"),KErrNotFound}, sl@0: {_S16("x"),_S16("x*"),0}, sl@0: {_S16("x"),_S16("*x"),0}, sl@0: {_S16("x"),_S16("*x*"),0}, sl@0: {_S16("x"),_S16("**x*"),0}, sl@0: {_S16("abc"),_S16(""),KErrNotFound}, // 20 sl@0: {_S16("abc"),_S16("?*"),0}, sl@0: {_S16("abc"),_S16("*?"),2}, sl@0: {_S16("abc"),_S16("*?*?"),0}, sl@0: {_S16("abc"),_S16("*a*"),0}, sl@0: {_S16("abc"),_S16("*b*"),1}, sl@0: {_S16("abc"),_S16("*c*"),2}, sl@0: {_S16("abc"),_S16("*a"),KErrNotFound}, sl@0: {_S16("abc"),_S16("*c"),2}, sl@0: {_S16("abc"),_S16("*?c"),1}, sl@0: {_S16("abc"),_S16("??c"),0}, // 30 sl@0: {_S16("abc"),_S16("*b?"),1}, sl@0: sl@0: // ones containing supplementary characters sl@0: {_S16("ab\xD840\xDDAD"),_S16("*b*"),1}, sl@0: {_S16("ab\xD840\xDDAD"),_S16("*b?"),1}, sl@0: {_S16("a\xD840\xDDAD\x0063"),_S16("*c*"),3}, sl@0: {_S16("a\xD840\xDDAD\x0063"),_S16("*\xD840\xDDAD*"),1}, sl@0: {_S16("a\xD840\xDDAB\xD830\xDDAC\xD840\xDDAC\x0063"),_S16("*\xD840\xDDAC*"),5}, sl@0: {_S16("\xD840\xDDAB\xD840\xDDAC\x0063"),_S16("?\xD840\xDDAC*"),0}, sl@0: {_S16("\xD840\xDDAB\xD840\xDDAC\x0063"),_S16("\xD840\xDDAB*"),0}, sl@0: {_S16("\xD840\xDDAB\xD840\xDDAC\x0063"),_S16("*?\xD840\xDDAC*"),0}, sl@0: {_S16("\xD840\xDDAB\xD840\xDDAC\xD840\xDDAD\x0063"),_S16("*?\xD840\xDDAD*"),2}, // 40 sl@0: }; sl@0: sl@0: TInt KTestsSurrogate=sizeof(TestsSurrogate)/sizeof(TestsSurrogate[0]); sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-1770 sl@0: @SYMTestCaseDesc TDes16 Collation conversion function test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Testing the three collation conversion function sl@0: in TDesC16::GetNormalizedDecomposedFormL, sl@0: TDesC16::GetFoldedDecomposedFormL, sl@0: TDesC16::GetCollationKeysL sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMREQ 6178 Add several new Unicode utility functions sl@0: */ sl@0: static void TestDes16CollationFunctionL() sl@0: { sl@0: /**----------------Test TDesC16::GetNormalizedDecomposedFormL------------------*/ sl@0: sl@0: HBufC16* outputBuffer=NULL; sl@0: _LIT16(KTestString1,"abc") ; sl@0: //LATIN CAPITAL LETTER W WITH DIAERESIS(\x0057\x0308) sl@0: //LATIN SMALL LETTER A(\x0061) sl@0: //LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE(\x006F\x0302\x0303) sl@0: //GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI(\x03B1\x0313\x0342\x0345) sl@0: _LIT16(KTestString2,"\x1E84\x0061\x1ED7\x1F86"); sl@0: _LIT16(KTestStringNDF2,"\x0057\x0308\x0061\x006F\x0302\x0303\x03B1\x0313\x0342\x0345"); sl@0: sl@0: outputBuffer=KTestString1().GetNormalizedDecomposedFormL(); sl@0: test(outputBuffer->Compare(KTestString1())==0); sl@0: delete outputBuffer; sl@0: sl@0: outputBuffer=KTestString2().GetNormalizedDecomposedFormL(); sl@0: test(outputBuffer->Compare(KTestStringNDF2())==0); sl@0: delete outputBuffer; sl@0: sl@0: /**----------------Test TDesC16::GetFoldedDecomposedFormL------------------*/ sl@0: _LIT16(KTestString6,"AbC"); sl@0: _LIT16(KTestStringFolded6,"abc"); sl@0: //GREEK CAPITAL LETTER OMICRON WITH PSILI =>\x03BF\x0313 sl@0: //LATIN SMALL LETTER M WITH ACUTE =>\x006D\x0301 sl@0: //LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE => \x006F\x0302\x0309 sl@0: _LIT16(KTestString7,"\x1F48\x1E3F\x1ED4"); sl@0: _LIT16(KTestStringFolded7,"\x03BF\x0313\x006D\x0301\x006F\x0302\x0309"); sl@0: sl@0: outputBuffer=KTestString6().GetFoldedDecomposedFormL(); sl@0: test(outputBuffer->Compare(KTestStringFolded6())==0); sl@0: delete outputBuffer; sl@0: sl@0: outputBuffer=KTestString7().GetFoldedDecomposedFormL(); sl@0: test(outputBuffer->Compare(KTestStringFolded7())==0); sl@0: delete outputBuffer; sl@0: sl@0: /**----------------Test TDesC16::GetCollationKeysL------------------*/ sl@0: TCollationMethod method; sl@0: method.iId = 0; sl@0: //purposely set the maintable to NULL, this will result in the DefaultTable being used sl@0: method.iMainTable = 0; sl@0: method.iOverrideTable = 0; sl@0: method.iFlags = TCollationMethod::EIgnoreNone; sl@0: sl@0: //---------------Test key generation functionality---------------- sl@0: /** sl@0: Collation keys for sl@0: x=08b90108-00000078 sl@0: y=08bd0108-00000079 sl@0: z=08c90108-0000007a sl@0: */ sl@0: _LIT(KInputString1,"xyz"); sl@0: HBufC8* outbuf=NULL; sl@0: //Max Level 0 keys sl@0: _LIT8(KMaxLevel0Key,"\x08\xb9\x08\xbd\x08\xc9"); sl@0: outbuf=KInputString1().GetCollationKeysL(0,&method); sl@0: test(outbuf->Compare(KMaxLevel0Key())==0); sl@0: delete outbuf; sl@0: //Max Level 1 keys sl@0: _LIT8(KMaxLevel1Key,"\x08\xb9\x08\xbd\x08\xc9\x00\x00\x01\x01\x01"); sl@0: outbuf=KInputString1().GetCollationKeysL(1,&method); sl@0: test(outbuf->Compare(KMaxLevel1Key())==0); sl@0: delete outbuf; sl@0: //Max Level 2 keys sl@0: _LIT8(KMaxLevel2Key,"\x08\xb9\x08\xbd\x08\xc9\x00\x00\x01\x01\x01\x00\x08\x08\x08"); sl@0: outbuf=KInputString1().GetCollationKeysL(2,&method); sl@0: test(outbuf->Compare(KMaxLevel2Key())==0); sl@0: delete outbuf; sl@0: //Max Level 3 keys sl@0: _LIT8(KMaxLevel3Key,"\x08\xb9\x08\xbd\x08\xc9\x00\x00\x01\x01\x01\x00\x08\x08\x08\x00\x00\x00\x78\x00\x00\x79\x00\x00\x7A"); sl@0: outbuf=KInputString1().GetCollationKeysL(3,&method); sl@0: test(outbuf->Compare(KMaxLevel3Key())==0); sl@0: delete outbuf; sl@0: sl@0: /** sl@0: Decomposition for 1F70 sl@0: 1F70=03B1 0300 sl@0: Collation keys for sl@0: \x03B1 =09360108-000003B1 sl@0: \x0300 =00001609-00000300 sl@0: y =08bd0108-00000079 sl@0: */ sl@0: _LIT(KInputString2,"\x1F70y"); sl@0: //Max Level 2 keys sl@0: _LIT8(KCollationString22,"\x09\x36\x08\xBD\x00\x00\x01\x16\x01\x00\x08\x08\x08"); sl@0: outbuf=KInputString2().GetCollationKeysL(2,&method); sl@0: test(outbuf->Compare(KCollationString22())==0); sl@0: delete outbuf; sl@0: sl@0: //Max Level 3 keys sl@0: _LIT8(KCollationString23,"\x09\x36\x08\xBD\x00\x00\x01\x16\x01\x00\x08\x08\x08\x00\x00\x03\xB1\x00\x03\x00\x00\x00\x79"); sl@0: outbuf=KInputString2().GetCollationKeysL(3,&method); sl@0: test(outbuf->Compare(KCollationString23())==0); sl@0: delete outbuf; sl@0: sl@0: /** sl@0: Decomposition for 1EAC sl@0: 1EAC= 1EA0 0302 = 0041 0323 0302 sl@0: Collation keys for sl@0: \x0041 =06CF0121-00000041 sl@0: \x0323 =FF800104-00000001,83230105-00000000(2 keys for one character) sl@0: \x0302 =00001D09-00000302 sl@0: */ sl@0: _LIT(KInputString3,"\x1EAC"); sl@0: //Max Level 0 keys sl@0: _LIT8(KCollationString30,"\x06\xCF\xFF\x80\x83\x23"); sl@0: //Max Level 1 keys sl@0: _LIT8(KCollationString31,"\x06\xCF\xFF\x80\x83\x23\x00\x00\x01\x01\x01\x1d"); sl@0: outbuf=KInputString3().GetCollationKeysL(1,&method); sl@0: test(outbuf->Compare(KCollationString31())==0); sl@0: delete outbuf; sl@0: sl@0: //Max Level 3 keys sl@0: _LIT8(KCollationString33,"\x06\xCF\xFF\x80\x83\x23\x00\x00\x01\x01\x01\x1d\x00\x20\x04\x04\x08\x00\x00\x00\x41\x00\x00\x01\x00\x03\x02"); sl@0: outbuf=KInputString3().GetCollationKeysL(3,&method); sl@0: test(outbuf->Compare(KCollationString33())==0); sl@0: delete outbuf; sl@0: sl@0: //--------------Test using NULL collationMethod----------------------- sl@0: outbuf=KInputString3().GetCollationKeysL(3,NULL); sl@0: test(outbuf->Compare(KCollationString33())==0); sl@0: delete outbuf; sl@0: sl@0: //--------------Test using out of limit level------------------------- sl@0: outbuf=KInputString3().GetCollationKeysL(6,NULL); sl@0: test(outbuf->Compare(KCollationString33())==0); sl@0: delete outbuf; sl@0: sl@0: outbuf=KInputString3().GetCollationKeysL(-1,NULL); sl@0: test(outbuf->Compare(KCollationString30())==0); sl@0: delete outbuf; sl@0: sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-UNICODE-CT-1771 sl@0: @SYMTestCaseDesc TDes16 Collation conversion function OOM test sl@0: @SYMTestPriority High sl@0: @SYMTestActions OOM Testing the three collation conversion function sl@0: in TDesC16::GetNormalizedDecomposedFormL, sl@0: TDesC16::GetFoldedDecomposedFormL, sl@0: TDesC16::GetCollationKeysL sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMREQ 6178 Add several new Unicode utility functions sl@0: */ sl@0: static void TestDes16CollationFunctionOOM() sl@0: { sl@0: test.Next(_L("TestDes16CollationFunctionOOM")); sl@0: 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: TRAP(err,TestDes16CollationFunctionL() ); 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: test.Printf(_L("- TestDes16CollationFunctionOOM succeeded at heap failure rate of %i\n"), tryCount); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: // sl@0: // entry point sl@0: // sl@0: { sl@0: CTrapCleanup* trapCleanup = CTrapCleanup::New(); sl@0: test(trapCleanup != NULL); sl@0: sl@0: test.Title(); sl@0: // sl@0: sl@0: test.Start(_L("Match8")); sl@0: TInt ii; sl@0: for (ii=0;ii buf00b5; sl@0: buf00b5.Copy( K00b5() ); sl@0: buf00b5.UpperCase(); sl@0: test( 0 == buf00b5.Find( K039c() ) ); sl@0: test( 0 == buf00b5.MatchF( K039c() ) ); sl@0: sl@0: // check code points with both upper and lower cases sl@0: test.Next( _L("Check characters with upper and lower cases") ); sl@0: // 01C5: upper 01C4, folded 01C6 sl@0: _LIT( K01c5, "\x01c5" ); sl@0: _LIT( K01c4, "\x01c4" ); sl@0: _LIT( K01c6, "\x01c6" ); sl@0: test( 0 == TPtrC16( K01c5() ).MatchF( TPtrC16( K01c6() ) ) ); sl@0: test( 0 == TPtrC16( K01c5() ).MatchF( TPtrC16( K01c4() ) ) ); sl@0: test( 0 == TPtrC16( K01c4() ).MatchF( TPtrC16( K01c5() ) ) ); sl@0: test( 0 == TPtrC16( K01c4() ).MatchF( TPtrC16( K01c6() ) ) ); sl@0: TBuf<20> buf01c5; sl@0: buf01c5.Copy( K01c5() ); sl@0: buf01c5.UpperCase(); sl@0: test( 0 == buf01c5.Find( K01c4() ) ); sl@0: test( 0 == buf01c5.MatchF( K01c6() ) ); sl@0: sl@0: test.Next(_L("MatchSurrogate")); sl@0: for (ii=0;ii