Update contrib.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\buffer\t_match.cpp
16 // Test the match methods of TPtrC8 and TPtrC16 objects and the
17 // TCharIterator TCombiningCharIterator, TCollationValueIterator
18 // and TCollationRawValueIterator classes.
20 // TPtrC8, TPtrC16, TCharIterator, TCombiningCharIterator,
21 // TCollationValueIterator, TCollationRawValueIterator
23 // - Test and verify the results of TPtrC8 Match and MatchF methods
24 // on a variety of constant strings. Verify both match and mismatch
26 // - Test and verify the results of TPtrC16 Match and MatchF methods
27 // on a variety of constant strings. Verify both match and mismatch
29 // - For a TCharIterator object, test and verify:
30 // - basic character handling
31 // - ability to reset the iterator correctly
32 // - combining characters works as expected
33 // - ability to jump into the middle of combined characters
34 // - full-width variants are not modified
35 // - narrow strings work as expected
36 // - surrogate pairs work as expected
37 // - Using a TCombiningCharIterator object with a variety of character
38 // strings as input, verify that the output is as expected.
39 // - Using TCollationValueIterator and TCollationRawValueIterator objects:
40 // - test the raw iterator
41 // - test starting at different points in the iteration and verify capitals
42 // are ignored at level 0
43 // - verify capitals are ignored at level 1
44 // - verify capitals do not match at level 2
45 // - check the TCollationValueIterator Restart method
46 // - test collation keys, when they success and when they fail halfway
47 // - exhaust the internal cache, verify object still works
48 // - test different decompositions at level 3
49 // - verify results are as expected
50 // - Test and verify the results of the TUnicodeFold::FindWildcardMatchFolded()
51 // method on a variety of constant strings: find a string within another
52 // string, verify the offset into the candidate string if it is present, or
53 // KErrNotFound if it is not.
54 // - Test and verify the results of the TUnicodeFold::FindFolded() method on
55 // a variety of constant strings: compare two strings, verify return value.
56 // - Test and verify results of UnicodeFoldCase() on a variety of characters.
57 // - Test and verify results of MatchLeadingWildcards() on a variety of strings.
58 // - Test and verify results of MatchesHereFoldedWithPrefixTest() on a variety
60 // - Test and verify results of LocateFolded() on a variety of strings.
61 // - Test and verify results of FindFoldedWithWildcard() and FindMatchFolded()
62 // on a variety of strings.
63 // - Test and verify results of TDesc.CompareF() on a variety of strings.
64 // Platforms/Drives/Compatibility:
66 // Assumptions/Requirement/Pre-requisites:
67 // Failures and causes:
68 // Base Port information:
75 #include "collateimp.h"
76 #include "CompareImp.h"
79 static inline TBool IsSupplementary(TUint aChar)
81 @param aChar The 32-bit code point value of a Unicode character.
83 @return True, if aChar is supplementary character; false, otherwise.
86 return (aChar > 0xFFFF);
89 static inline TText16 GetHighSurrogate(TUint aChar)
91 Retrieve the high surrogate of a supplementary character.
93 @param aChar The 32-bit code point value of a Unicode character.
95 @return High surrogate of aChar, if aChar is a supplementary character;
96 aChar itself, if aChar is not a supplementary character.
98 @see TChar::GetLowSurrogate
101 return STATIC_CAST(TText16, 0xD7C0 + (aChar >> 10));
104 static inline TText16 GetLowSurrogate(TUint aChar)
106 Retrieve the low surrogate of a supplementary character.
108 @param aChar The 32-bit code point value of a Unicode character.
110 @return Low surrogate of aChar, if aChar is a supplementary character;
111 zero, if aChar is not a supplementary character.
113 @see TChar::GetHighSurrogate
116 return STATIC_CAST(TText16, 0xDC00 | (aChar & 0x3FF));
120 ///***************** copied from locale euser source code ***********************
121 static const TCollationMethod TheCollationMethod[] =
124 KUidBasicCollationMethod, // this is the standard unlocalised method
125 NULL, // null means use the standard table
126 NULL, // there's no override table
127 0 // the flags are standard
130 static const TCollationDataSet TheCollationDataSet =
135 const LCharSet TheCharSet =
140 const LCharSet* GetLocaleCharSet()
144 ///*******************************************************************************
148 // Solve compilation problem caused by non-English locale
149 #pragma setlocale("english")
152 #define ARRAY_SIZE(ar) (sizeof(ar) / (sizeof(ar[0])))
154 LOCAL_D RTest test(_L("T_MATCH"));
156 _LIT(KUnicodeTestDataFile, "z:\\Test\\UnicodeData.txt");
158 static const TUint32 TheDevanagariKey[] =
160 0x22a010b,0x22b010b,0x285010b,0xb109,0xb209,0xb309,0xb409,0xb509,
161 0x6c5e609,0x6c6e609,0x6c7e609,0x6c8e609,0x6c9e609,0x6cae609,0x6cbe609,0x6cce609,
162 0x6cde609,0x6cee609,0xba40109,0xba50109,0xba60109,0xba70109,0xba80109,0xba90109,
163 0xbaa0109,0xbab0109,0xbac0109,0xbad0109,0xbae0109,0xbaf0109,0xbb00109,0xbb10109,
164 0xbb20109,0xbb30109,0xbb40109,0xbb50109,0xbb60109,0xbb70109,0xbb80109,0xbb90109,
165 0xbb9b109,0xbba0109,0xbbab109,0xbbb0109,0xbbbb109,0xbbc0109,0xbbd0109,0xbbe0109,
166 0xbbf0109,0xbc00109,0xbc0b109,0xbc10109,0xbc20109,0xbc30109,0xbc40109,0xbc50109,
167 0xbc5b109,0xbc60109,0xbc6b109,0xbc70109,0xbc80109,0xbc90109,0xbca0109,0xbcb0109,
168 0xbcc0109,0xbccb109,0xbcd0109,0xbce0109,0xbceb109,0xbcf0109,0xbd00109,0xbd10109,
169 0xbd20109,0xbd2b109,0xbd30109,0xbd3b109,0xbd40109,0xbd50109,0xbd5b109,0xbd60109,
170 0xbd70109,0xbd80109,0xbd90109,0xbda0109,0xbdb0109,0xbdc0109,0xbdd0109,0xbde0109,
171 0xbdf0109,0xbe00109,0xbe10109,0xbe20109,0xbe30109,0xbe40109,0xbe50109,0xbe60109,
172 0xbe70109,0xbe80109,0xbe90109,0xbea0109,0xbeb0109,0xbec0109,0xbed0109,
175 static const TUint32 TheDevanagariIndex[] =
177 0x9010012,0x9020013,0x9030014,0x9050015,0x9060016,0x9070017,0x9080018,0x9090019,
178 0x90a001a,0x90b001b,0x90c001d,0x90d001f,0x90e0020,0x90f0021,0x9100022,0x9110023,
179 0x9120024,0x9130025,0x9140026,0x9150027,0x9160029,0x917002b,0x918002d,0x919002e,
180 0x91a002f,0x91b0030,0x91c0031,0x91d0033,0x91e0034,0x91f0035,0x9200036,0x9210037,
181 0x9220039,0x923003b,0x924003c,0x925003d,0x926003e,0x927003f,0x9280040,0x9290041,
182 0x92a0042,0x92b0043,0x92c0045,0x92d0046,0x92e0047,0x92f0048,0x930004a,0x931004b,
183 0x932004c,0x933004d,0x934004e,0x935004f,0x9360050,0x9370051,0x9380052,0x9390053,
184 0x93c0003,0x93d0054,0x93e0055,0x93f0056,0x9400057,0x9410058,0x9420059,0x943005a,
185 0x944005b,0x945005e,0x946005f,0x9470060,0x9480061,0x9490062,0x94a0063,0x94b0064,
186 0x94c0065,0x94d0066,0x9510004,0x9520005,0x9530006,0x9540007,0x9580028,0x959002a,
187 0x95a002c,0x95b0032,0x95c0038,0x95d003a,0x95e0044,0x95f0049,0x960001c,0x961001e,
188 0x962005c,0x963005d,0x9640000,0x9650001,0x9660008,0x9670009,0x968000a,0x969000b,
189 0x96a000c,0x96b000d,0x96c000e,0x96d000f,0x96e0010,0x96f0011,0x9700002,
192 static const TCollationKeyTable TheDevanagariTable =
193 { TheDevanagariKey, TheDevanagariIndex, 103, 0, 0, 0 };
195 static const TCollationMethod TheDevanagariMethod =
196 { 0, 0, &TheDevanagariTable, 0 };
198 static const TCollationMethod TheDevanagariIgnoreCombiningMethod =
199 { 0, 0, &TheDevanagariTable, TCollationMethod::EIgnoreCombining };
201 static const TUint32 TheSwedishKey[] =
203 0x8f60109,0x8f70109,0x8f80109,0x8f60121,0x8f70121,0x8f80121,0x8dd0109,0x8dd0121,
207 static const TUint32 TheSwedishIndex[] =
212 static const TUint16 TheSwedishStringElement[] =
214 0x2,0x61,0x30a,0x2,0x61,0x308,0x2,0x6f,
215 0x308,0x2,0x41,0x30a,0x2,0x41,0x308,0x2,
216 0x4f,0x308,0x2,0x75,0x308,0x2,0x55,0x308,
219 static const TUint32 TheSwedishStringIndex[] =
221 0xc0004,0x90003,0xf0005,0x150007,0x30001,0x0,0x60002,0x120006,
224 static const TCollationKeyTable TheSwedishTable =
225 { TheSwedishKey, TheSwedishIndex, 2, TheSwedishStringElement, TheSwedishStringIndex, 8 };
227 static const TCollationMethod TheSwedishMethod =
228 { 0, 0, &TheSwedishTable, TCollationMethod::EIgnoreNone };
230 static const TCollationMethod TheIgnoreNoneMethod =
231 { 0, 0, 0, TCollationMethod::EIgnoreNone };
233 void TestPrintCaption(const TDesC& aTestName, const TText16 aStr[], TInt aLen)
235 test.Next(aTestName);
236 RDebug::Print(_L("Char seq: "));
237 for(TInt i=0;i<aLen;++i)
239 RDebug::Print(_L("%04X "), aStr[i]);
241 RDebug::Print(_L("\nOutput: "));
244 TInt MatchC(const TDesC16& aCandidate, const TDesC16& aSearchTerm,
245 const TCollationMethod* aMethod, TInt aLevel)
250 TCollate m(*aMethod);
253 return method.Match(aCandidate.Ptr(), aCandidate.Length(),
254 aSearchTerm.Ptr(), aSearchTerm.Length(), aLevel);
257 _LIT(KCand1, "baot");
258 _LIT(KCand2, "ba\x308o\x308t");
259 _LIT(KCand3, "b\xe4\xf6t");
260 _LIT(KSearch1, "BAOT");
261 _LIT(KSearch2, "?AO?");
262 _LIT(KSearch3, "?\xe4o?");
263 _LIT(KSearch4, "*o*");
264 _LIT(KSearch5, "*ao*");
265 _LIT(KSearch6, "*b\x308*");
266 _LIT(KSearch7, "ba\x308*");
267 _LIT(KSearch8, "ba*");
271 // MatchC should be working at level 0, let us test that this is so.
272 test(0 == KCand1().MatchC(KSearch1));
273 test(0 == KCand1().MatchC(KCand2));
274 test(1 == KCand1().MatchC(KSearch5));
275 test(1 == KCand2().MatchC(KSearch5));
276 test(0 <= KCand1().MatchC(KSearch2));
277 // Test the internals at level 0: It must fail to match Swedish accents
278 // with the Swedish collation algorithm.
279 test(0 == MatchC(KCand1, KSearch1, &TheIgnoreNoneMethod, 0));
280 test(0 == MatchC(KCand1, KSearch1, &TheSwedishMethod, 0));
281 test(0 == MatchC(KCand2, KSearch1, &TheIgnoreNoneMethod, 0));
282 test(KErrNotFound == MatchC(KCand2, KSearch1, &TheSwedishMethod, 0));
283 test(0 == MatchC(KCand3, KSearch1, &TheIgnoreNoneMethod, 0));
284 test(KErrNotFound == MatchC(KCand3, KSearch1, &TheSwedishMethod, 0));
285 test(0 <= MatchC(KCand1, KSearch2, &TheIgnoreNoneMethod, 0));
286 test(0 <= MatchC(KCand1, KSearch2, &TheSwedishMethod, 0));
287 test(0 <= MatchC(KCand2, KSearch2, &TheIgnoreNoneMethod, 0));
288 test(KErrNotFound == MatchC(KCand2, KSearch2, &TheSwedishMethod, 0));
289 test(0 <= MatchC(KCand3, KSearch2, &TheIgnoreNoneMethod, 0));
290 test(KErrNotFound == MatchC(KCand3, KSearch2, &TheSwedishMethod, 0));
291 test(0 <= MatchC(KCand2, KSearch3, &TheIgnoreNoneMethod, 0));
292 test(KErrNotFound == MatchC(KCand3, KSearch2, &TheSwedishMethod, 0));
293 test(3 == MatchC(KCand2, KSearch4, &TheIgnoreNoneMethod, 0));
294 test(KErrNotFound == MatchC(KCand2, KSearch4, &TheSwedishMethod, 0));
295 test(1 == MatchC(KCand2, KSearch5, &TheIgnoreNoneMethod, 0));
296 test(KErrNotFound == MatchC(KCand2, KSearch5, &TheSwedishMethod, 0));
297 test(0 == MatchC(KCand2, KSearch6, &TheIgnoreNoneMethod, 0));
298 test(0 == MatchC(KCand2, KSearch6, &TheSwedishMethod, 0));
299 test(0 == MatchC(KCand1, KSearch7, &TheIgnoreNoneMethod, 0));
300 test(KErrNotFound == MatchC(KCand1, KSearch7, &TheSwedishMethod, 0));
301 test(0 == MatchC(KCand1, KSearch8, &TheIgnoreNoneMethod, 0));
302 test(0 == MatchC(KCand1, KSearch8, &TheSwedishMethod, 0));
303 test(0 == MatchC(KCand2, KSearch7, &TheIgnoreNoneMethod, 0));
304 test(0 == MatchC(KCand2, KSearch7, &TheSwedishMethod, 0));
305 test(0 == MatchC(KCand2, KSearch8, &TheIgnoreNoneMethod, 0));
306 test(KErrNotFound == MatchC(KCand2, KSearch8, &TheSwedishMethod, 0));
307 test(0 == MatchC(KCand3, KSearch7, &TheIgnoreNoneMethod, 0));
308 test(0 == MatchC(KCand3, KSearch7, &TheSwedishMethod, 0));
309 test(0 == MatchC(KCand3, KSearch8, &TheIgnoreNoneMethod, 0));
310 test(KErrNotFound == MatchC(KCand3, KSearch8, &TheSwedishMethod, 0));
311 _LIT(KCandidate1, "axyz");
312 _LIT(KSearchStr1, "a*z");
313 test(0 == KCandidate1().MatchC(KSearchStr1()));
314 _LIT(KCandidate2, "azzz");
315 _LIT(KSearchStr2, "a*z");
316 test(0 == KCandidate2().MatchC(KSearchStr2()));
318 // Added tests for INC105311...
319 _LIT(KCandJpg1, "jpg_jjg.jpg");
320 _LIT(KCandJpg2, "jpgAjjg.jpg");
321 _LIT(KCandJpg3, "jpg@jjg.jpg");
322 _LIT(KCandJpg4, "hpg&jjg.jpg");
323 _LIT(KCandJpg5, "hpg&jpg.jpg");
324 _LIT(KSearchJpg1, "*jp?");
325 _LIT(KSearchJpg2, "*jpg");
326 _LIT(KSearchJpg3, "*jpg*");
327 _LIT(KSearchJpg4, "*jpg*jpg");
328 test(8 == KCandJpg1().MatchC(KSearchJpg1));
329 test(8 == KCandJpg2().MatchC(KSearchJpg1));
330 test(8 == KCandJpg3().MatchC(KSearchJpg1));
331 test(8 == KCandJpg4().MatchC(KSearchJpg1));
332 test(8 == KCandJpg5().MatchC(KSearchJpg1));
333 test(8 == KCandJpg1().MatchC(KSearchJpg2));
334 test(8 == KCandJpg2().MatchC(KSearchJpg2));
335 test(8 == KCandJpg3().MatchC(KSearchJpg2));
336 test(8 == KCandJpg4().MatchC(KSearchJpg2));
337 test(8 == KCandJpg5().MatchC(KSearchJpg2));
338 test(0 == KCandJpg1().MatchC(KSearchJpg3));
339 test(0 == KCandJpg2().MatchC(KSearchJpg3));
340 test(0 == KCandJpg3().MatchC(KSearchJpg3));
341 test(8 == KCandJpg4().MatchC(KSearchJpg3));
342 test(4 == KCandJpg5().MatchC(KSearchJpg3));
343 test(0 == KCandJpg1().MatchC(KSearchJpg4));
344 test(0 == KCandJpg2().MatchC(KSearchJpg4));
345 test(0 == KCandJpg3().MatchC(KSearchJpg4));
346 test(KErrNotFound == KCandJpg4().MatchC(KSearchJpg4));
347 test(4 == KCandJpg5().MatchC(KSearchJpg4));
348 _LIT(KCand4, "abcxaxaxa");
349 _LIT(KSearch9, "*xaxa");
350 test(5 == KCand4().MatchC(KSearch9));
351 _LIT(KCand6, "abxa");
352 _LIT(KSearch10, "*x?");
353 test(2 == KCand6().MatchC(KSearch10));
355 _LIT(KSearch11, "x?");
356 test(KErrNotFound == KCand7().MatchC(KSearch11));
358 _LIT(KSearch12, "x?");
359 test(0 == KCand8().MatchC(KSearch12));
360 _LIT(KCand9, "xaxa");
361 _LIT(KSearch13, "*x?");
362 test(2 == KCand9().MatchC(KSearch13));
363 _LIT(KCand10, "abjpgcjig.jpg");
364 _LIT(KSearch14, "*jp?");
365 test(10 == KCand10().MatchC(KSearch14));
366 _LIT(KCand11, "abjpg_jig.jpg");
367 _LIT(KSearch15, "*jp?");
368 test(10 == KCand11().MatchC(KSearch15));
369 _LIT(KCand12, "jpg");
370 _LIT(KSearch16, "*jp?");
371 test(0 == KCand12().MatchC(KSearch16));
372 _LIT(KCand13, "abjpgig.jpg");
373 _LIT(KSearch17, "*jp?");
374 test(8 == KCand13().MatchC(KSearch17));
375 _LIT(KCand14, "abjcgig.jpg");
376 _LIT(KSearch18, "jp?");
377 test(KErrNotFound == KCand14().MatchC(KSearch18));
378 _LIT(KCand15, "xax\xE2");
379 _LIT(KSearch19, "*xa\x302");
380 test(2 == KCand15().MatchC(KSearch19));
381 _LIT(KCand5, "blahblahblah\xE2");
382 _LIT(KSearch20, "*a\x302");
383 test(12 == KCand5().MatchC(KSearch20));
384 _LIT(KCand16, "bl\xE2hblahblaha\x302");
385 _LIT(KSearch21, "*a\x302*\xE2");
386 test(2 == KCand16().MatchC(KSearch21));
387 _LIT(KCand17, "abcxaxaxa");
388 _LIT(KSearch22, "*x?x?");
389 test(5 == KCand17().MatchC(KSearch22));
393 @SYMTestCaseID SYSLIB-EUSER-CT-1759
394 @SYMTestCaseDesc Various tests for the new TDesC16::MatchC() method. Testing that the new method works with
395 different wild card characters and different escape characters.
396 @SYMTestPriority High
397 @SYMTestActions Test for TDesC16::MatchC(const TDesC16 &aPattern, TInt aMaxLevel, TInt aWildChar, TInt aWildSequenceChar, TInt aEscapeChar, const TCollationMethod* aCollationMethod = NULL).
398 @SYMTestExpectedResults The test must not fail.
403 _LIT(KCandidate1, "ab/cRRRdef__grt");
404 _LIT(KSearchStr1, "ab//c%def/_/_grt");
405 TInt rc = KCandidate1().MatchC(KSearchStr1(), '_', '%', '/', 0);
407 _LIT(KCandidate2, "_*");
408 _LIT(KSearchStr2, "/_/*");
409 rc = KCandidate2().MatchC(KSearchStr2(), '_', '*', '/', 0);
411 _LIT(KCandidate3, "aa");
412 _LIT(KSearchStr3, "aaaa");
413 rc = KCandidate3().MatchC(KSearchStr3(), '_', '%', 'a', 0);
415 _LIT(KCandidate4, "\\4%3=1");
416 _LIT(KSearchStr4, "\\\\4_3%");
417 rc = KCandidate4().MatchC(KSearchStr4(), '_', '%', '\\', 0);
419 _LIT(KCandidate5, "abcd&efgh");
420 _LIT(KSearchStr5, "----!&efgh");
421 rc = KCandidate5().MatchC(KSearchStr5(), '-', '&', '!', 0);
423 _LIT(KCandidate6, "abc#1234:5678#xyz");
424 _LIT(KSearchStr6, "#!#1234!:56::!##z");
425 rc = KCandidate6().MatchC(KSearchStr6(), ':', '#', '!', 0);
427 _LIT(KCandidate7, "abc#1234:5678#zzz");
428 _LIT(KSearchStr7, "#!#1234!:56::!##z");
429 rc = KCandidate7().MatchC(KSearchStr7(), ':', '#', '!', 0);
431 _LIT(KCandidate8, "abc");
432 _LIT(KSearchStr8, "a_c");
433 rc = KCandidate8().MatchC(KSearchStr8(), '_', '%', '7', 0);
435 _LIT(KCandidate9, "abc");
436 _LIT(KSearchStr9, "A_C");
437 rc = KCandidate9().MatchC(KSearchStr9(), '_', '%', '7', 0);
439 _LIT(KCandidate10, "a_c");
440 _LIT(KSearchStr10, "a7_c");
441 rc = KCandidate10().MatchC(KSearchStr10(), '_', '%', '7', 0);
443 _LIT(KCandidate11, "a_c");
444 _LIT(KSearchStr11, "A7_C");
445 rc = KCandidate11().MatchC(KSearchStr11(), '_', '%', '7', 0);
447 _LIT(KCandidate12, "abc");
448 _LIT(KSearchStr12, "a7_c");
449 rc = KCandidate12().MatchC(KSearchStr12(), '_', '%', '7', 0);
450 test(rc == KErrNotFound);
451 _LIT(KCandidate13, "abc");
452 _LIT(KSearchStr13, "A7_C");
453 rc = KCandidate13().MatchC(KSearchStr13(), '_', '%', '7', 0);
454 test(rc == KErrNotFound);
455 _LIT(KCandidate14, "a7Xc");
456 _LIT(KSearchStr14, "a7_c");
457 rc = KCandidate14().MatchC(KSearchStr14(), '_', '%', '7', 0);
458 test(rc == KErrNotFound);
459 _LIT(KCandidate15, "a7Xc");
460 _LIT(KSearchStr15, "A7_C");
461 rc = KCandidate15().MatchC(KSearchStr15(), '_', '%', '7', 0);
462 test(rc == KErrNotFound);
463 _LIT(KCandidate16, "abcde");
464 _LIT(KSearchStr16, "a%e");
465 rc = KCandidate16().MatchC(KSearchStr16(), '_', '%', '7', 0);
467 _LIT(KCandidate17, "abcde");
468 _LIT(KSearchStr17, "A%E");
469 rc = KCandidate17().MatchC(KSearchStr17(), '_', '%', '7', 0);
471 _LIT(KCandidate18, "abcde");
472 _LIT(KSearchStr18, "a7%e");
473 rc = KCandidate18().MatchC(KSearchStr18(), '_', '%', '7', 0);
474 test(rc == KErrNotFound);
475 _LIT(KCandidate19, "abcde");
476 _LIT(KSearchStr19, "A7%E");
477 rc = KCandidate19().MatchC(KSearchStr19(), '_', '%', '7', 0);
478 test(rc == KErrNotFound);
479 _LIT(KCandidate20, "a7cde");
480 _LIT(KSearchStr20, "a7%e");
481 rc = KCandidate20().MatchC(KSearchStr20(), '_', '%', '7', 0);
482 test(rc == KErrNotFound);
483 _LIT(KCandidate21, "a7cde");
484 _LIT(KSearchStr21, "A7%E");
485 rc = KCandidate21().MatchC(KSearchStr21(), '_', '%', '7', 0);
486 test(rc == KErrNotFound);
487 _LIT(KCandidate22, "a7cde");
488 _LIT(KSearchStr22, "a77%e");
489 rc = KCandidate22().MatchC(KSearchStr22(), '_', '%', '7', 0);
491 _LIT(KCandidate23, "a7cde");
492 _LIT(KSearchStr23, "A77%E");
493 rc = KCandidate23().MatchC(KSearchStr23(), '_', '%', '7', 0);
495 _LIT(KCandidate24, "abc7");
496 _LIT(KSearchStr24, "a%77");
497 rc = KCandidate24().MatchC(KSearchStr24(), '_', '%', '7', 0);
499 _LIT(KCandidate25, "abc7");
500 _LIT(KSearchStr25, "A%77");
501 rc = KCandidate25().MatchC(KSearchStr25(), '_', '%', '7', 0);
503 _LIT(KCandidate26, "abc_");
504 _LIT(KSearchStr26, "a%7_");
505 rc = KCandidate26().MatchC(KSearchStr26(), '_', '%', '7', 0);
507 _LIT(KCandidate27, "abc_");
508 _LIT(KSearchStr27, "A%7_");
509 rc = KCandidate27().MatchC(KSearchStr27(), '_', '%', '7', 0);
511 _LIT(KCandidate28, "abc7");
512 _LIT(KSearchStr28, "a%7_");
513 rc = KCandidate28().MatchC(KSearchStr28(), '_', '%', '7', 0);
514 test(rc == KErrNotFound);
515 _LIT(KCandidate29, "abc7");
516 _LIT(KSearchStr29, "A%7_");
517 rc = KCandidate29().MatchC(KSearchStr29(), '_', '%', '7', 0);
518 test(rc == KErrNotFound);
519 _LIT(KCandidate30, "ba\x308o\x308t");
520 _LIT(KSearchStr30, "-b\x308-");
521 rc = KCandidate30().MatchC(KSearchStr30(), '%', '-', 0, 0);
523 rc = KCandidate30().MatchC(KSearchStr30(), '%', '-', 0, 0, &TheSwedishMethod);
525 _LIT(KSearchStr31, "ba\x308*");
526 rc = KCandidate30().MatchC(KSearchStr31(), '%', '*', 0, 0, &TheSwedishMethod);
530 void DoTestCanonicalDecompositionIterator(const TDesC& aTest, const TDesC& aCanonical)
532 TUTF32Iterator i(aTest.Ptr(), aTest.Ptr() + aTest.Length());
533 TCanonicalDecompositionIterator cci;
538 test(index != aCanonical.Length());
539 TChar ch1 = aCanonical[index];
540 TChar ch2 = cci.Current();
545 test(index == aCanonical.Length());
548 // exciting combining characters include:
549 // U+0327 cedilla, class = 202
550 // U+031B horn, class = 216
551 // U+0316 grave below, class = 220
552 // U+0300 grave above, class = 230
553 // U+031A left angle above, class = 232
554 // U+0360 double tilde, class = 234
555 // U+0345 ypogegrameni, class = 240
557 _LIT(KAllOnce, "\x327\x31b\x316\x300\x31a\x360\x345xyz");
558 _LIT(KBackwards, "\x345\x360\x31a\x300\x316\x31b\x327xyz");
559 _LIT(KRandom, "\x300\x316\x31b\x327\x31a\x345\x360xyz");
560 _LIT(KAllOnceThenAcute, "\x327\x31b\x316\x300\x301\x31a\x360\x345");
561 _LIT(KBackwardsThenAcute, "\x345\x360\x31a\x300\x301\x316\x31b\x327");
562 _LIT(KRandomThenAcute, "\x300\x316\x31b\x327\x31a\x301\x345\x360");
563 _LIT(KAllSame, "\x300\x301\x302\x303\x304\x306\x307\x308\x30b\x30c\x30f");
564 _LIT(KLotsSameCanonical, "\x327\x31b\x316\x300\x301\x302\x303\x304\x306\x307\x308\x30b\x30c\x30f\x31a\x360\x345xyz");
565 _LIT(KLotsSameNotCanonical, "\x31b\x300\x345\x301\x302\x316\x303\x304\x31a\x306\x307\x327\x308\x30b\x30c\x30f\x360xyz");
568 @SYMTestCaseID SYSLIB-UNICODE-CT-0106
569 @SYMTestCaseDesc TCanonicalDecompositionIterator test
570 @SYMTestPriority High
571 @SYMTestActions TCanonicalDecompositionIterator test
572 @SYMTestExpectedResults The test must not fail.
573 @SYMPREQ814 Optimise folded string comparisons.
575 void TestCanonicalDecompositionIterator()
577 DoTestCanonicalDecompositionIterator(KAllOnce, KAllOnce);
578 DoTestCanonicalDecompositionIterator(KBackwards, KAllOnce);
579 DoTestCanonicalDecompositionIterator(KRandom, KAllOnce);
580 DoTestCanonicalDecompositionIterator(KBackwardsThenAcute, KAllOnceThenAcute);
581 DoTestCanonicalDecompositionIterator(KRandomThenAcute, KAllOnceThenAcute);
582 DoTestCanonicalDecompositionIterator(KAllSame, KAllSame);
583 DoTestCanonicalDecompositionIterator(KLotsSameCanonical, KLotsSameCanonical);
584 DoTestCanonicalDecompositionIterator(KLotsSameNotCanonical, KLotsSameCanonical);
588 @SYMTestCaseID SYSLIB-UNICODE-CT-3337
589 @SYMTestCaseDesc Test latest MatchC override that has the advanced TCollationMethod flag input
590 @SYMTestPriority High
591 @SYMTestActions Test matching of combined characters with simple character.
592 Note- this action only applies to certain classes of combining characters
593 @SYMTestExpectedResults Old MatchC character against character + combining character
594 will not match but new MatchC with same characters and flag set will match.
595 @SYMINC092513: RR S60: Variant testing: Searching does not work properly in contacts
597 void TestDisableCombiningCharacterCheckFlag(const TDesC16 &aLeft, const TDesC16 &aRight)
599 //Without flag, characters combine to make new character not matched by search
600 test(KErrNotFound ==aLeft.MatchC(aRight,&TheDevanagariMethod));
601 //With flag, combining character check is disabled so that search is matched
602 test(KErrNone ==aLeft.MatchC(aRight,&TheDevanagariIgnoreCombiningMethod));
604 void TestDisableCombiningCharacterCheck()
606 test.Next(_L("INC092513"));
607 TBuf<2> search, target;
608 //All Devanagari dependant vowels are in the following range
609 for(TInt dependantVowel=0x93e; dependantVowel<=0x94c; dependantVowel++)
611 //Most of the Devanagari consonants are in the following range
612 for(TInt consonant=0x915; consonant<=0x939; consonant++)
614 target.Format(_L("%c%c"),consonant,dependantVowel);
615 search.Format(_L("%c*"),consonant);
616 TestDisableCombiningCharacterCheckFlag(target, search);
619 //Test same situation but where consonants decompose to consonant + dependant vowel
620 TestDisableCombiningCharacterCheckFlag(_L("\x929"), _L("\x928*"));
621 TestDisableCombiningCharacterCheckFlag(_L("\x931"), _L("\x930*"));
622 TestDisableCombiningCharacterCheckFlag(_L("\x934"), _L("\x933*"));
623 TestDisableCombiningCharacterCheckFlag(_L("\x958"), _L("\x915*"));
624 TestDisableCombiningCharacterCheckFlag(_L("\x959"), _L("\x916*"));
625 TestDisableCombiningCharacterCheckFlag(_L("\x95a"), _L("\x917*"));
626 TestDisableCombiningCharacterCheckFlag(_L("\x95b"), _L("\x91c*"));
627 TestDisableCombiningCharacterCheckFlag(_L("\x95c"), _L("\x921*"));
628 TestDisableCombiningCharacterCheckFlag(_L("\x95d"), _L("\x922*"));
629 TestDisableCombiningCharacterCheckFlag(_L("\x95e"), _L("\x92b*"));
630 TestDisableCombiningCharacterCheckFlag(_L("\x95f"), _L("\x92f*"));
633 _LIT(KHelloT, "Hello");
634 _LIT(KLatin1AccentsC, "\xE0\xD2p\xE2\xEB\xED\xF1\xC7");
635 _LIT(KLatin1AccentsD, "a\x300O\x300pa\x302\x65\x308i\x301n\x303\x43\x327");
636 // four alpha + psili + varia + ypogegrameni
637 _LIT(KGreekAccentsC, "\x1f82\x1f82\x1f82\x1f82");
638 // decomposed in four different ways
639 _LIT(KGreekAccentsS, "\x1f82\x1f02\x345\x1f00\x300\x345\x3b1\x313\x300\x345");
640 // completely decomposed
641 _LIT(KGreekAccentsD, "\x3b1\x313\x300\x345\x3b1\x313\x300\x345\x3b1\x313\x300\x345\x3b1\x313\x300\x345");
642 // full-width variants
643 _LIT(KFullWidth, "\xFF21\xFF42\xFF43");
644 // surrogate pair, unpaired low surrogate, unpaired high surrogate, unpaired
645 // high surrogate at end of string
646 _LIT(KSurrogates, "\xD965\xDEF0\xDF12\xDB10\xDA4E");
647 _LIT(KSurrogatesTest, "\xD965\xDEF0");
649 void TestIteratorOutput(TDecompositionIterator& aIt, const TDesC& aCheck)
651 TBool unpairedHighSurrogate = EFalse;
652 for(TInt i = 0; i != aCheck.Length(); aIt.Next())
659 TInt c = aIt.Current();
660 // test that we are not looking at an unpaired low surrogate that
661 // follows an unpaired high surrogate: this is not possible.
662 test((c & 0xFC00) != 0xDC00 || !unpairedHighSurrogate);
663 unpairedHighSurrogate = (c & 0xFC00) == 0xD800? (TBool)ETrue : (TBool)EFalse;
666 test(c == aCheck[i]);
671 TInt sp = ((aCheck[i] - 0xD7F7) << 10) + aCheck[i + 1];
680 @SYMTestCaseID SYSLIB-UNICODE-CT-0097
681 @SYMTestCaseDesc TUTF32Iterator functionality tested on 2 character sequences:
684 @SYMTestPriority High
685 @SYMTestActions TUTF32Iterator test.
686 @SYMTestExpectedResults The test must not fail.
687 @SYMPREQ814 Optimise folded string comparisons.
689 void TestUTF32Iterator()
692 const TText16 KStr[] = {0x01D5};
693 ::TestPrintCaption(_L("TUTF32Iterator"), KStr, ARRAY_SIZE(KStr));
694 TUTF32Iterator it(KStr, KStr + ARRAY_SIZE(KStr));
696 for(;!it.AtEnd();++itCount, it.Next())
698 TChar ch = it.Current();
699 test(ch == static_cast <TUint> (KStr[0]));
700 RDebug::Print(_L("%04X "), (TUint)ch);
703 RDebug::Print(_L("\n"));
706 ::TestPrintCaption(_L("TUTF32Iterator-surrogates"), KSurrogatesTest().Ptr(), KSurrogatesTest().Length());
707 it = TUTF32Iterator(KSurrogatesTest().Ptr(), KSurrogatesTest().Ptr() + KSurrogatesTest().Length());
708 for(itCount=0;!it.AtEnd();++itCount, it.Next())
710 TChar ch = it.Current();
712 RDebug::Print(_L("%06X "), (TUint)ch);
715 RDebug::Print(_L("\n"));
718 _LIT( KSurrogatesTest2, "\xd800\xdc00" );
719 ::TestPrintCaption(_L("TUTF32Iterator-surrogates2"), KSurrogatesTest2().Ptr(), KSurrogatesTest2().Length());
720 it = TUTF32Iterator(KSurrogatesTest2().Ptr(), KSurrogatesTest2().Ptr() + KSurrogatesTest2().Length());
721 for(itCount=0;!it.AtEnd();++itCount, it.Next())
723 TChar ch = it.Current();
725 RDebug::Print(_L("%06X "), (TUint)ch);
728 RDebug::Print(_L("\n"));
731 _LIT( KSurrogatesTest3, "\xd840\xdc00" );
732 ::TestPrintCaption(_L("TUTF32Iterator-surrogates3"), KSurrogatesTest3().Ptr(), KSurrogatesTest3().Length());
733 it = TUTF32Iterator(KSurrogatesTest3().Ptr(), KSurrogatesTest3().Ptr() + KSurrogatesTest3().Length());
734 for(itCount=0;!it.AtEnd();++itCount, it.Next())
736 TChar ch = it.Current();
738 RDebug::Print(_L("%06X "), (TUint)ch);
741 RDebug::Print(_L("\n"));
744 _LIT( KSurrogatesTest4, "\xD87F\xDFFF" );
745 ::TestPrintCaption(_L("TUTF32Iterator-surrogates4"), KSurrogatesTest4().Ptr(), KSurrogatesTest4().Length());
746 it = TUTF32Iterator(KSurrogatesTest4().Ptr(), KSurrogatesTest4().Ptr() + KSurrogatesTest4().Length());
747 for(itCount=0;!it.AtEnd();++itCount, it.Next())
749 TChar ch = it.Current();
751 RDebug::Print(_L("%06X "), (TUint)ch);
753 //test(itCount == 1);
754 RDebug::Print(_L("\n"));
757 _LIT( KSurrogatesTest5, "\xD800" );
758 ::TestPrintCaption(_L("TUTF32Iterator-surrogates5"), KSurrogatesTest5().Ptr(), KSurrogatesTest5().Length());
759 it = TUTF32Iterator(KSurrogatesTest5().Ptr(), KSurrogatesTest5().Ptr() + KSurrogatesTest5().Length());
760 for(itCount=0;!it.AtEnd();++itCount, it.Next())
762 TChar ch = it.Current();
763 RDebug::Print(_L("%06X "), (TUint)ch);
766 RDebug::Print(_L("\n"));
769 _LIT( KSurrogatesTest6, "\xDc00" );
770 ::TestPrintCaption(_L("TUTF32Iterator-surrogates6"), KSurrogatesTest6().Ptr(), KSurrogatesTest6().Length());
771 it = TUTF32Iterator(KSurrogatesTest6().Ptr(), KSurrogatesTest6().Ptr() + KSurrogatesTest6().Length());
772 for(itCount=0;!it.AtEnd();++itCount, it.Next())
774 TChar ch = it.Current();
775 RDebug::Print(_L("%06X "), (TUint)ch);
778 RDebug::Print(_L("\n"));
781 _LIT( KSurrogatesTest7, "\xDfff" );
782 ::TestPrintCaption(_L("TUTF32Iterator-surrogates7"), KSurrogatesTest7().Ptr(), KSurrogatesTest7().Length());
783 it = TUTF32Iterator(KSurrogatesTest7().Ptr(), KSurrogatesTest7().Ptr() + KSurrogatesTest7().Length());
784 for(itCount=0;!it.AtEnd();++itCount, it.Next())
786 TChar ch = it.Current();
787 RDebug::Print(_L("%06X "), (TUint)ch);
790 RDebug::Print(_L("\n"));
794 @SYMTestCaseID SYSLIB-UNICODE-CT-0098
795 @SYMTestCaseDesc TFoldedDecompIterator functionality tested on 2 character sequences.
796 @SYMTestPriority High
797 @SYMTestActions TFoldedDecompIterator test.
798 @SYMTestExpectedResults The test must not fail.
799 @SYMPREQ814 Optimise folded string comparisons.
801 void TestFoldedDecompIterator()
803 //Character sequence 1:
804 //(1) DEVANAGARI LETTER FA - 0x095E
805 //(2) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5
807 //(1) 0x095E decomposed to: 0x092B 0x093C
808 //(2) 0x01D5 decomposed to: 0x00DC 0x0304
809 // 0x00DC decomposed to: 0x0055 0x0308
810 // 0x0055 decomposed to: 0x0075
811 const TText16 KStr[] = {0x095E, 0x01D5};
812 const TText16 KStrOut[] = {0x092B, 0x093C, 0x0075, 0x0308, 0x0304};
813 ::TestPrintCaption(_L("TFoldedDecompIterator-1"), KStr, ARRAY_SIZE(KStr));
814 TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr));
815 TFoldedDecompIterator it(itSrc);
817 for(;!it.AtEnd();++itCount, it.Next())
819 if(!it.IsInFoldedSequence())
821 it.EnterFoldedSequence();
823 TChar ch = it.Current();
824 test(ch == static_cast <TUint> (KStrOut[itCount]));
825 RDebug::Print(_L("%04X "), (TUint)ch);
827 test(itCount == ARRAY_SIZE(KStrOut));
828 RDebug::Print(_L("\n"));
830 //Character sequence 2:
831 //(1) GREEK CAPITAL LETTER BETA - 0x0392
832 //(2) COMBINING GRAVE ACCENT - 0x0300
833 //(3) COMBINING GRAVE ACCENT BELOW - 0x0316
834 //(4) GREEK CAPITAL LETTER GAMMA - 0x0393
835 //(5) HEBREW POINT TSERE - 0x05B5
836 //(6) TIBETAN MARK HALANTA - 0x0F84
838 //(1) 0x0392 decomposed to: 0x03B2
839 //(2) 0x0300 decomposed to: 0x0300
840 //(3) 0x0316 decomposed to: 0x0316
841 //(4) 0x0393 decomposed to: 0x03B3
842 //(5) 0x05B5 decomposed to: 0x05B5
843 //(6) 0x0F84 decomposed to: 0x0F84
844 const TText16 KStr2[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0x0F84};
845 const TText16 KStrOut2[] = {0x03B2, 0x0300, 0x0316, 0x03B3, 0x05B5, 0x0F84};
846 ::TestPrintCaption(_L("TFoldedDecompIterator-2"), KStr2, ARRAY_SIZE(KStr2));
847 itSrc = TUTF32Iterator(KStr2, KStr2 + ARRAY_SIZE(KStr2));
848 it = TFoldedDecompIterator(itSrc);
849 for(itCount=0;!it.AtEnd();++itCount, it.Next())
851 if(!it.IsInFoldedSequence())
853 it.EnterFoldedSequence();
855 TChar ch = it.Current();
856 test(ch == static_cast <TUint> (KStrOut2[itCount]));
857 RDebug::Print(_L("%04X "), (TUint)ch);
859 test(itCount == ARRAY_SIZE(KStrOut2));
860 RDebug::Print(_L("\n"));
862 //Character sequence 3:
863 //(1) MUSICAL SYMBOL EIGHTH NOTE - 0x1D161 (D834, DD61)
865 //(1) 0x1D161 decomposed to: 0x1D15F 0x1D16F
866 // 0x1D15F decomposed to: 0x1D158 0x1D165
867 const TText16 KStr3[] = {0xD834, 0xDD61};
868 const TUint32 KStrOut3[] = {0x1D158, 0x1D165, 0x1D16F};
869 ::TestPrintCaption(_L("TFoldedDecompIterator-3"), KStr3, ARRAY_SIZE(KStr3));
870 itSrc = TUTF32Iterator(KStr3, KStr3 + ARRAY_SIZE(KStr3));
871 it = TFoldedDecompIterator(itSrc);
872 for(itCount=0;!it.AtEnd();++itCount, it.Next())
874 if(!it.IsInFoldedSequence())
876 it.EnterFoldedSequence();
878 TChar ch = it.Current();
879 test(ch == static_cast <TUint> (KStrOut3[itCount]));
880 RDebug::Print(_L("%04X "), (TUint)ch);
882 test(itCount == ARRAY_SIZE(KStrOut3));
883 RDebug::Print(_L("\n"));
887 @SYMTestCaseID SYSLIB-UNICODE-CT-0099
888 @SYMTestCaseDesc TFoldedSortedDecompIterator functionality tested on 1 character sequence.
889 @SYMTestPriority High
890 @SYMTestActions TFoldedSortedDecompIterator test.
891 @SYMTestExpectedResults The test must not fail.
892 @SYMPREQ814 Optimise folded string comparisons.
894 void TestFoldedSortedDecompIterator()
896 //Character sequence 1:
897 //(1) GREEK CAPITAL LETTER BETA - 0x0392 (fold: 0x3B2, ccc=0)
898 //(2) COMBINING GRAVE ACCENT - 0x0300 (no fold, ccc=230)
899 //(3) COMBINING GRAVE ACCENT BELOW - 0x0316 (no fold, ccc=220)
900 //(4) GREEK CAPITAL LETTER GAMMA - 0x0393 (fold: 0x3B3, ccc=0)
901 //(5) HEBREW POINT TSERE - 0x05B5 (no fold, ccc=15)
902 //(6) 0x10A39 (no fold, ccc=1)
903 //(7) TIBETAN MARK HALANTA - 0x0F84 (no fold, ccc=9)
904 //(8) 0x10400 (fold: 0x10428, ccc=0)
905 //(9) 0x10A38 (no fold, ccc=230)
906 //(10) 0xFB1E (no fold, ccc=26)
918 //const TText16 KStr[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0x0F84};
919 //const TText16 KStrOut[] = {0x03B2, 0x0316, 0x0300, 0x03B3, 0x0F84, 0x05B5};
920 //const TInt KClass[] = {0, 220, 230, 0, 9, 15};
921 const TText16 KStr[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0xD802, 0xDE39, 0x0F84, 0xD801, 0xDC00, 0xD802, 0xDE38, 0xFB1E};
922 const TUint32 KStrOut[] = {0x03B2, 0x0316, 0x0300, 0x03B3, 0x10A39, 0x0F84, 0x05B5, 0x10428, 0xFB1E, 0x10A38};
923 const TInt KClass[] = {0, 220, 230, 0, 1, 9, 15, 0, 26, 230};
924 ::TestPrintCaption(_L("TFoldedSortedDecompIterator"), KStr, ARRAY_SIZE(KStr));
925 RDebug::Print(_L("\n"));
926 TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr));
927 TFoldedDecompIterator itDecomp(itSrc);
929 while(!itDecomp.AtEnd())
931 if(!itDecomp.IsInFoldedSequence())
933 itDecomp.EnterFoldedSequence();
935 if(itDecomp.Current().GetCombiningClass() == 0)
937 TChar ch = itDecomp.Current();
938 TInt clss = itDecomp.Current().GetCombiningClass();
939 RDebug::Print(_L("BaseCh %04X Class %d\n"), (TUint)ch, clss);
940 test(ch == static_cast <TUint> (KStrOut[itCount]));
941 test(clss == KClass[itCount]);
947 TFoldedSortedDecompIterator it;
951 TChar ch = it.Current();
952 TInt clss = it.Current().GetCombiningClass();
953 RDebug::Print(_L("CombCh %08X Class %d\n"), (TUint)ch, clss);
954 test(ch == static_cast <TUint> (KStrOut[itCount]));
955 test(clss == KClass[itCount]);
961 test(itCount == ARRAY_SIZE(KStrOut));
965 @SYMTestCaseID SYSLIB-UNICODE-CT-0100
966 @SYMTestCaseDesc TFoldedCanonicalIterator functionality tested on 1 character sequence.
967 @SYMTestPriority High
968 @SYMTestActions TFoldedCanonicalIterator test.
969 @SYMTestExpectedResults The test must not fail.
970 @SYMPREQ814 Optimise folded string comparisons.
972 void TestFoldedCanonicalIterator()
974 //Character sequence 1:
975 //(1) GREEK CAPITAL LETTER BETA - 0x0392
976 //(2) COMBINING GRAVE ACCENT - 0x0300
977 //(3) COMBINING GRAVE ACCENT BELOW - 0x0316
978 //(4) GREEK CAPITAL LETTER GAMMA - 0x0393
979 //(5) HEBREW POINT TSERE - 0x05B5
980 //(6) TIBETAN MARK HALANTA - 0x0F84
981 //(7) MUSICAL SYMBOL EIGHTH NOTE - 0x1D161 (D834, DD61)
982 //(8) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5
990 //0x1D161 to 0x1D158 0x1D165 0x1D16F
991 //0x01D5 to 0x0075 0x0308 0x0304
992 const TText16 KStr[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0x0F84, 0xD834, 0xDD61, 0x01D5};
993 const TUint32 KStrOut[] = {0x03B2, 0x0316, 0x0300, 0x03B3, 0x0F84, 0x05B5, 0x1D158, 0x1D165, 0x1D16F, 0x0075, 0x0308, 0x0304};
994 TestPrintCaption(_L("TFoldedCanonicalIterator"), KStr, ARRAY_SIZE(KStr));
995 TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr));
996 TFoldedCanonicalIterator it(itSrc);
999 const TUnicodeDataSet* charDataSet = GetLocaleCharSet()->iCharDataSet;
1001 for(;!it.AtEnd();++itCount, it.Next(charDataSet))
1003 TChar ch = it.Current();
1004 test(ch == static_cast <TUint> (KStrOut[itCount]));
1005 RDebug::Print(_L("%04X "), (TUint)ch);
1007 test(itCount == ARRAY_SIZE(KStrOut));
1008 RDebug::Print(_L("\n"));
1015 @SYMTestCaseID SYSLIB-UNICODE-CT-0101
1016 @SYMTestCaseDesc TDecompositionIterator functionality tested on 1 character sequence
1017 @SYMTestPriority High
1018 @SYMTestActions TDecompositionIterator test.
1019 @SYMTestExpectedResults The test must not fail.
1020 @SYMPREQ814 Optimise folded string comparisons.
1022 void TestDecompositionIterator2()
1024 //Character sequence 1
1025 //LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5
1027 //0x01D5 to: 0x0055 0x0308 0x0304
1028 const TText16 KStr[] = {0x01D5};
1029 const TText16 KStrOut[] = {0x0055, 0x0308, 0x0304};
1030 TestPrintCaption(_L("TDecompositionIterator"), KStr, ARRAY_SIZE(KStr));
1031 TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr));
1032 TDecompositionIterator it;
1035 for(;!it.AtEnd(); ++itCount, it.Next())
1037 TChar ch = it.Current();
1038 test(ch == static_cast <TUint> (KStrOut[itCount]));
1039 RDebug::Print(_L("%04X "), (TUint)ch);
1041 test(itCount == ARRAY_SIZE(KStrOut));
1042 RDebug::Print(_L("\n"));
1044 // Character sequence 2
1045 // MUSICAL SYMBOL THIRTY-SECOND NOTE - 0x1D162 (D834, DD62)
1047 // 0x1D162 to: 0x1D15F 0x1D170, then to: 0x1D158 0x1D165 0x1D170
1048 const TText16 KStr2[] = {0xD834, 0xDD62};
1049 const TUint32 KStrOut2[] = {0x1D158, 0x1D165, 0x1D170};
1050 TestPrintCaption(_L("TDecompositionIterator"), KStr2, ARRAY_SIZE(KStr2));
1051 TUTF32Iterator itSrc2(KStr2, KStr2 + ARRAY_SIZE(KStr2));
1052 TDecompositionIterator it2;
1055 for(;!it2.AtEnd(); ++itCount2, it2.Next())
1057 TChar ch = it2.Current();
1058 //test.Printf(_L(" expect = %08X, result = %08X\n"), KStrOut2[itCount2], ch);
1059 test(ch == KStrOut2[itCount2]);
1060 RDebug::Print(_L("%04X "), (TUint)ch);
1062 test(itCount2 == ARRAY_SIZE(KStrOut2));
1063 RDebug::Print(_L("\n"));
1067 @SYMTestCaseID SYSLIB-UNICODE-CT-0102
1068 @SYMTestCaseDesc TCanonicalDecompositionIterator functionality tested on 1 character sequence
1069 @SYMTestPriority High
1070 @SYMTestActions TCanonicalDecompositionIterator test.
1071 @SYMTestExpectedResults The test must not fail.
1072 @SYMPREQ814 Optimise folded string comparisons.
1074 void TestCanonicalDecompositionIterator2()
1076 //Character sequence 1
1077 //(1) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5
1078 //(2) MUSICAL SYMBOL THIRTY-SECOND NOTE - 0x1D162 (D834, DD62)
1080 //0x01D5 to: 0x0055 0x0308 0x0304
1081 //0x1D162 to: 0x1D15F 0x1D170, then to: 0x1D158 0x1D165 0x1D170
1082 const TText16 KStr[] = {0x01D5, 0xD834, 0xDD62};
1083 const TUint32 KStrOut[] = {0x0055, 0x0308, 0x0304, 0x1D158, 0x1D165, 0x1D170};
1084 TestPrintCaption(_L("TCanonicalDecompositionIterator"), KStr, ARRAY_SIZE(KStr));
1085 TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr));
1086 TCanonicalDecompositionIterator it;
1089 for(;!it.AtEnd();++itCount, it.Next())
1091 TChar ch = it.Current();
1092 test(ch == static_cast <TUint> (KStrOut[itCount]));
1093 RDebug::Print(_L("%04X "), (TUint)ch);
1095 test(itCount == ARRAY_SIZE(KStrOut));
1096 RDebug::Print(_L("\n"));
1100 @SYMTestCaseID SYSLIB-UNICODE-CT-0103
1101 @SYMTestCaseDesc TCanonicalDecompositionIteratorCached functionality tested on 1 character sequence
1102 @SYMTestPriority High
1103 @SYMTestActions TCanonicalDecompositionIteratorCached test.
1104 @SYMTestExpectedResults The test must not fail.
1105 @SYMPREQ814 Optimise folded string comparisons.
1107 void TestCanonicalDecompositionIteratorCached()
1109 //Character sequence 1
1110 //(1) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5
1111 //(2) MUSICAL SYMBOL THIRTY-SECOND NOTE - 0x1D162 (D834, DD62)
1113 //0x01D5 to: 0x0055 0x0308 0x0304
1114 //0x1D162 to: 0x1D15F 0x1D170, then to: 0x1D158 0x1D165 0x1D170
1115 const TText16 KStr[] = {0x01D5, 0xD834, 0xDD62};
1116 const TUint32 KStrOut[] = {0x0055, 0x0308, 0x0304, 0x1D158, 0x1D165, 0x1D170};
1117 TestPrintCaption(_L("TCanonicalDecompositionIteratorCached"), KStr, ARRAY_SIZE(KStr));
1118 TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr));
1119 TCanonicalDecompositionIteratorCached it;
1122 for(;!it.AtEnd();++itCount, it.Next(1))
1124 TChar ch = it.Get(0);
1125 test(ch == static_cast <TUint> (KStrOut[itCount]));
1126 RDebug::Print(_L("%04X "), (TUint)ch);
1128 test(itCount == ARRAY_SIZE(KStrOut));
1129 RDebug::Print(_L("\n"));
1133 @SYMTestCaseID SYSLIB-UNICODE-CT-0104
1134 @SYMTestCaseDesc TDecompositionIterator test
1135 @SYMTestPriority High
1136 @SYMTestActions TDecompositionIterator test.
1137 @SYMTestExpectedResults The test must not fail.
1138 @SYMPREQ814 Optimise folded string comparisons.
1140 void TestDecompositionIterator()
1142 TDecompositionIterator i;
1144 // test basic character handling
1145 TUTF32Iterator i1(KHelloT().Ptr(), KHelloT().Ptr() + KHelloT().Length());
1147 TestIteratorOutput(i, KHelloT);
1149 TUTF32Iterator i2(KHelloT().Ptr() + 3, KHelloT().Ptr() + KHelloT().Length());
1151 TestIteratorOutput(i, KHelloT().Mid(3));
1153 // test combining characters
1154 TUTF32Iterator i3(KLatin1AccentsC().Ptr(), KLatin1AccentsC().Ptr() + KLatin1AccentsC().Length());
1156 TestIteratorOutput(i, KLatin1AccentsD);
1158 TUTF32Iterator i4(KGreekAccentsC().Ptr(), KGreekAccentsC().Ptr() + KGreekAccentsC().Length());
1160 TestIteratorOutput(i, KGreekAccentsD);
1162 TUTF32Iterator i5(KGreekAccentsS().Ptr(), KGreekAccentsS().Ptr() + KGreekAccentsS().Length());
1164 TestIteratorOutput(i, KGreekAccentsD);
1166 // test that full-width variants are not fiddled with
1167 TUTF32Iterator i6(KFullWidth().Ptr(), KFullWidth().Ptr() + KFullWidth().Length());
1169 TestIteratorOutput(i, KFullWidth);
1171 TUTF32Iterator i7(KSurrogates().Ptr(), KSurrogates().Ptr() + KSurrogates().Length());
1173 TestIteratorOutput(i, KSurrogatesTest);
1176 //The function collects collation keys at the specified level aLevel from aIt iterator
1177 //and stores them in aBuf output parameter.
1178 //aExpectedNumKeys value specifies the count of expected collation keys.
1179 void GetKeys(TCollationValueIterator& aIt, TUint32* aBuf, TInt aLevel, TInt aExpectedNumKeys)
1181 //Zero the output parameter
1182 Mem::FillZ(aBuf, sizeof(TUint32) * aExpectedNumKeys);
1185 for(;i!=aExpectedNumKeys;++i)
1189 (void)aIt.GetCurrentKey(aLevel, aBuf[i]);
1190 test(aIt.Increment());
1197 //The rest of the keys at that level should have 0 value.
1198 for(;aIt.Increment();)
1201 (void)aIt.GetCurrentKey(aLevel, key);
1206 //The function collects the raw keys from aIt iterator and stores them in aBuf output parameter.
1207 //aExpectedNumKeys value specifies the count of expected raw collation keys.
1208 void GetRawKeys(TCollationValueIterator& aIt, TCollationKey* aBuf, TInt aExpectedNumKeys)
1210 //Zero the output parameter
1211 Mem::FillZ(aBuf, sizeof(TCollationKey) * aExpectedNumKeys);
1213 for(TInt i=0;i!=aExpectedNumKeys;++i)
1215 test(aIt.GetCurrentKey(aBuf[i]));
1218 //One additional GetCurrentKey() call. Because there shouldn't be more raw keys than
1219 //aExpectedNumKeys, the call should fail returning EFalse.
1220 TCollationKey dummy;
1221 test(!aIt.GetCurrentKey(dummy));
1224 //The function gets a sequence of raw collation keys in aBuf parameter and a character number
1225 //aCharNo in the original string.
1226 //It returns the position in aBuf where raw collation key sequence for aCharNo starts.
1227 TInt CharNo2CollKeyPos(const TCollationKey* aBuf, TInt aBufLen, TInt aCharNo)
1229 TInt starterCnt = 0;
1233 if(aBuf[pos].IsStarter())
1237 } while(starterCnt!=(aCharNo+1) && ++pos!=aBufLen);
1238 test(pos != aBufLen);
1242 //The function compares aBuf1 and aBuf2 and returns how many elements in aBuf1 differ
1243 //from the elements in aBuf2 at the same position.
1244 TInt CountDiscrepancies(TUint32* aBuf1, TUint32* aBuf2, TInt aCount)
1246 TInt discrepancies = 0;
1247 for (; aCount; --aCount)
1249 if (*aBuf1++ != *aBuf2++)
1252 return discrepancies;
1255 TInt CountDiscrepancies(TCollationKey* aBuf1, TCollationKey* aBuf2, TInt aCount)
1257 TInt discrepancies = 0;
1258 for (; aCount; --aCount)
1260 if (aBuf1->iHigh != aBuf2->iHigh || aBuf1->iLow != aBuf2->iLow)
1265 return discrepancies;
1268 _LIT(KAYZAccentsAbove, "\xE0\x301y\x302z\x303\x304");
1269 _LIT(KCapitalAYZAccentsAbove, "A\x300\x301Y\x302Z\x303\x304");
1270 _LIT(KCapitalYAYZAccentsAbove, "a\x300\x301Y\x302z\x303\x304");
1271 _LIT(KABCRuleTest, "abcwabkakb");
1272 _LIT(KABCRuleExpected, "eeabkakb");
1273 //_LIT(KExhaustCaches, "0123456789ABCDEFexhausted");
1274 _LIT(KGreekOPVY1, "\x1f82");
1275 _LIT(KGreekOPVY2, "\x1f02\x345");
1276 _LIT(KGreekOPVY3, "\x1f00\x300\x345");
1277 _LIT(KGreekOPVY4, "\x3b1\x313\x300\x345");
1278 _LIT(KGreekOPVY5, "\x3b1\x313\x345\x300");
1279 _LIT(KGreekOPVY6, "\x3b1\x345\x313\x300");
1282 @SYMTestCaseID SYSLIB-UNICODE-CT-0105
1283 @SYMTestCaseDesc TCollationValueIterator test
1284 @SYMTestPriority High
1285 @SYMTestActions TCollationValueIterator tests
1286 @SYMTestExpectedResults The test must not fail.
1287 @SYMPREQ814 Optimise folded string comparisons.
1289 void TestCollationValueIterator()
1291 // a funny pair of extra collation rules: w and abc both collate as e.
1292 TUint32 abcWTLKey[] = {0/* key for 'e' will go here */,
1293 0x8ff00101, 0x8ff10101, 0x8ff20101, 0x8ff30101,
1294 0x8ff40101, 0x8ff50101, 0x8ff60101};
1295 const TUint32 overrideIndex[] = {0x00770000, 0x0E010001, 0x0E400002, 0x0E440003,
1296 0x0E810004, 0x0EC10005, 0x0EC20006, 0xEC30007};
1297 const TUint16 abcString[4] = {0x0003, 0x0061, 0x0062, 0x0063};
1298 const TUint32 abcStringIndex = 0;
1299 TCollationMethod method;
1301 method.iMainTable = StandardCollationMethod();
1302 method.iFlags = TCollationMethod::EIgnoreNone;
1304 for (charindex = 0; method.iMainTable->iIndex[charindex] >> 16 != 'e'; ++charindex)
1307 abcWTLKey[0] = method.iMainTable->iKey[method.iMainTable->iIndex[charindex] & 0xFFFF];
1308 TCollationKeyTable overrideTable = {abcWTLKey, overrideIndex, sizeof(abcWTLKey)/4, abcString, &abcStringIndex, 1};
1309 method.iOverrideTable = &overrideTable;
1311 TCollationValueIterator v(method);
1312 TCollationValueIterator rv(method);
1317 TCollationKey raw1[32];
1318 TCollationKey raw2[32];
1319 const TInt KRawKeyCnt = 8;//Raw collation key count produced from KAYZAccentsAbove string.
1321 //Get the raw key sequence for the whole KAYZAccentsAbove string.
1322 TUTF32Iterator it(KAYZAccentsAbove().Ptr(), KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length());
1324 ::GetRawKeys(rv, raw1, KRawKeyCnt);
1326 //KAYZAccentsAbove related constants
1327 const TInt KBaseCharCnt = 3;//The number of base characters (A, y, z) in KAYZAccentsAbove string.
1328 const TInt KOrgPosA = 0;//A position in KAYZAccentsAbove
1329 const TInt KOrgPosY = 2;//y position in KAYZAccentsAbove
1330 const TInt KOrgPosZ = 4;//z position in KAYZAccentsAbove
1331 //Find where the collation key sequences start for A, y, z characters in KAYZAccentsAbove string.
1332 const TInt KCollKeyPosA = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 0);
1333 const TInt KCollKeyPosY = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 1);
1334 const TInt KCollKeyPosZ = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 2);
1336 //Get the raw key sequence for character A in KAYZAccentsAbove string.
1337 it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosA, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length());
1339 ::GetRawKeys(rv, raw2 + KCollKeyPosA, KRawKeyCnt - KCollKeyPosA);
1341 test(0 == ::CountDiscrepancies(raw1, raw2, KRawKeyCnt));
1343 //Get the raw key sequence for character Y in KAYZAccentsAbove string.
1344 it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosY, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length());
1346 ::GetRawKeys(rv, raw2 + KCollKeyPosY, KRawKeyCnt - KCollKeyPosY);
1348 test(0 == ::CountDiscrepancies(raw1, raw2, KRawKeyCnt));
1350 //Get the raw key sequence for character Z in KAYZAccentsAbove string.
1351 it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosZ, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length());
1353 ::GetRawKeys(rv, raw2 + KCollKeyPosZ, KRawKeyCnt - KCollKeyPosZ);
1355 test(0 == ::CountDiscrepancies(raw1, raw2, KRawKeyCnt));
1357 //Test starting at different points in the iteration
1361 it = TUTF32Iterator(KAYZAccentsAbove().Ptr(), KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length());
1363 ::GetKeys(v, buf1, 0, KBaseCharCnt);
1364 //String from Y pos.
1365 it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosY, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length());
1367 ::GetKeys(v, buf2, 0, KBaseCharCnt - 1);
1369 test(0 == ::CountDiscrepancies(buf1 + 1, buf2, KBaseCharCnt - 1));
1370 //String from Z pos.
1371 it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosZ, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length());
1373 ::GetKeys(v, buf2, 0, KBaseCharCnt - 2);
1375 test(0 == ::CountDiscrepancies(buf1 + 2, buf2, KBaseCharCnt - 2));
1378 //KCapitalAYZAccentsAbove is used in this test.
1379 it = TUTF32Iterator(KCapitalAYZAccentsAbove().Ptr(), KCapitalAYZAccentsAbove().Ptr() + KCapitalAYZAccentsAbove().Length());
1381 ::GetRawKeys(v, raw1, 8);
1382 const TInt KOrgPosY2 = 3;//Y position in KCapitalAYZAccentsAbove
1383 const TInt KCollKeyPosY2 = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 1);
1385 it = TUTF32Iterator(KCapitalAYZAccentsAbove().Ptr(), KCapitalAYZAccentsAbove().Ptr() + KCapitalAYZAccentsAbove().Length());
1387 ::GetKeys(v, buf1, 1, 8);
1388 //String from Y pos.
1389 it = TUTF32Iterator(KCapitalAYZAccentsAbove().Ptr() + KOrgPosY2, KCapitalAYZAccentsAbove().Ptr() + KCapitalAYZAccentsAbove().Length());
1391 ::GetKeys(v, buf2, 1, 8 - KCollKeyPosY2);
1393 test(0 == ::CountDiscrepancies(buf1 + KCollKeyPosY2, buf2, 8 - KCollKeyPosY2));
1396 //Capitals do not match at level 2
1397 it = TUTF32Iterator(KAYZAccentsAbove().Ptr(), KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length());
1399 ::GetKeys(v, buf1, 2, 8);
1400 it = TUTF32Iterator(KCapitalYAYZAccentsAbove().Ptr(), KCapitalYAYZAccentsAbove().Ptr() + KCapitalYAYZAccentsAbove().Length());
1402 ::GetKeys(v, buf2, 2, 8);
1404 test(1 == CountDiscrepancies(buf1, buf2, 8));
1405 test(buf1[3] != buf2[3]);
1407 //Test funny collation keys, when they succeed and when they fail half way.
1408 it = TUTF32Iterator(KABCRuleTest().Ptr(), KABCRuleTest().Ptr() + KABCRuleTest().Length());
1410 ::GetKeys(v, buf1, 0, 8);
1411 it = TUTF32Iterator(KABCRuleExpected().Ptr(), KABCRuleExpected().Ptr() + KABCRuleExpected().Length());
1413 ::GetKeys(v, buf2, 0, 8);
1415 test(0 == ::CountDiscrepancies(buf1, buf2, 8));
1417 //Test different decompositions at level 3
1418 it = TUTF32Iterator(KGreekOPVY1().Ptr(), KGreekOPVY1().Ptr() + KGreekOPVY1().Length());
1420 ::GetKeys(v, buf1, 3, 4);
1422 it = TUTF32Iterator(KGreekOPVY2().Ptr(), KGreekOPVY2().Ptr() + KGreekOPVY2().Length());
1424 ::GetKeys(v, buf2, 3, 4);
1426 test(0 == ::CountDiscrepancies(buf1, buf2, 4));
1428 it = TUTF32Iterator(KGreekOPVY3().Ptr(), KGreekOPVY3().Ptr() + KGreekOPVY3().Length());
1430 ::GetKeys(v, buf2, 3, 4);
1432 test(0 == ::CountDiscrepancies(buf1, buf2, 4));
1434 it = TUTF32Iterator(KGreekOPVY4().Ptr(), KGreekOPVY4().Ptr() + KGreekOPVY4().Length());
1436 ::GetKeys(v, buf2, 3, 4);
1438 test(0 == ::CountDiscrepancies(buf1, buf2, 4));
1440 it = TUTF32Iterator(KGreekOPVY5().Ptr(), KGreekOPVY5().Ptr() + KGreekOPVY5().Length());
1442 ::GetKeys(v, buf2, 3, 4);
1444 test(0 == ::CountDiscrepancies(buf1, buf2, 4));
1446 it = TUTF32Iterator(KGreekOPVY6().Ptr(), KGreekOPVY6().Ptr() + KGreekOPVY6().Length());
1448 ::GetKeys(v, buf2, 3, 4);
1450 test(0 == ::CountDiscrepancies(buf1, buf2, 4));
1455 // equivalence classes: all codes that fold to the same letter (which must be present
1456 // in the list). The lists are separated by -1. The end is marked with two -1s.
1457 // Each list must be in increasing order.
1458 TInt FoldingEquivalenceClasses[] =
1460 'A', 'a', -1, 'Z', 'z', -1, '@', -1, '[', -1, '{', -1, 127, -1, 'I', 'i', 0x131, -1, 0, -1,
1462 0x300, -1, 0x301, -1,
1464 0x1c4, 0x1c5, 0x1c6, -1, 0x1c7, 0x1c8, 0x1c9, -1, 0x1ca, 0x1cb, 0x1cc, -1,
1465 0x1f1, 0x1f2, 0x1f3, -1, 0x3a3, 0x3c2, 0x3c3, 0x3f2, -1,
1466 0x402, 0x452, -1, 0x40F, 0x45F, -1, 0x460, 0x461, -1, 0x480, 0x481, -1, 0x482, -1,
1467 0x410, 0x430, -1, 0x42F, 0x44f, -1, 0x48C, 0x48D, -1, 0x4e8, 0x4e9, -1,
1468 0x531, 0x561, -1, 0x556, 0x586, -1, 0x559, -1, 0x55f, -1, -1
1471 //_LIT(KMatchLeadingCandidate1, "\xE1\x65\x300\x301\x302\x303pqa\x301");
1472 //_LIT(KNoQMs, "a???");
1473 //_LIT(KOneQM, "?a");
1474 //_LIT(KTwoQMs, "??");
1475 //_LIT(KThreeQMs, "???*?");
1477 //Constructs TUTF32Iterator iterator from aStr
1478 TUTF32Iterator UTF32It(const TDesC16& aStr)
1480 return TUTF32Iterator(aStr.Ptr(), aStr.Ptr() + aStr.Length());
1484 @SYMTestCaseID SYSLIB-UNICODE-CT-0107
1485 @SYMTestCaseDesc MatchSectionFolded test
1486 @SYMTestPriority High
1487 @SYMTestActions MatchSectionFolded test
1488 @SYMTestExpectedResults The test must not fail.
1489 @SYMPREQ814 Optimise folded string comparisons.
1491 void MatchSectionFoldedTest()
1493 TUTF32Iterator candidateIt, searchTermIt;
1495 candidateIt = UTF32It(_L16("\xE1"));
1496 searchTermIt = UTF32It(_L16("a"));
1497 test(!MatchSectionFolded(candidateIt, searchTermIt));
1499 candidateIt = UTF32It(_L16("a"));
1500 searchTermIt = UTF32It(_L16("\xE1"));
1501 test(!MatchSectionFolded(candidateIt, searchTermIt));
1503 candidateIt = UTF32It(_L16("abca\xE1\x62\x62\x61\x61\x61\x62\x63\x62\x61"));
1504 searchTermIt = UTF32It(_L16("aBc"));
1505 test(MatchSectionFolded(candidateIt, searchTermIt));
1506 test(searchTermIt.AtEnd());
1507 TPtrC16 p1(_L16("a\xE1\x62\x62\x61\x61\x61\x62\x63\x62\x61"));
1508 TPtrC16 p2(candidateIt.CurrentPosition(), 11);
1511 candidateIt = UTF32It(_L16("aaaacdeiooo"));
1512 searchTermIt = UTF32It(_L16("acde"));
1513 test(!MatchSectionFolded(candidateIt, searchTermIt));
1516 //FindMatchSectionFolded test
1517 void DoFindMatchSectionFoldedTest(const TDesC16& aCandidate, const TDesC16& aSearchTerm, TInt aPos)
1519 TUTF32Iterator candidateIt, searchTermIt;
1520 candidateIt = UTF32It(aCandidate);
1521 searchTermIt = UTF32It(aSearchTerm);
1524 test(FindMatchSectionFolded(candidateIt, searchTermIt));
1525 test(searchTermIt.AtEnd());
1529 test(!FindMatchSectionFolded(candidateIt, searchTermIt));
1533 //This class is used for reading lines from the unicode data file.
1534 class RUnicodeTestDataFile
1537 RUnicodeTestDataFile();
1540 TBool NextStmt(TPtrC8& aStmt);
1546 RUnicodeTestDataFile::RUnicodeTestDataFile() :
1552 void RUnicodeTestDataFile::OpenLC()
1554 __ASSERT_ALWAYS(!iFileData && !iStartPos, User::Invariant());
1557 CleanupClosePushL(*this);
1560 CleanupClosePushL(fileSess);
1561 User::LeaveIfError(fileSess.Connect());
1564 CleanupClosePushL(file);
1565 User::LeaveIfError(file.Open(fileSess, KUnicodeTestDataFile, EFileRead));
1568 User::LeaveIfError(file.Size(fileSize));
1569 __ASSERT_ALWAYS(fileSize > 0, User::Invariant());
1571 iFileData = HBufC8::NewL(fileSize + 1);
1573 TPtr8 p = iFileData->Des();
1574 User::LeaveIfError(file.Read(p));
1576 CleanupStack::PopAndDestroy(2, &fileSess);
1579 void RUnicodeTestDataFile::Close()
1586 TBool RUnicodeTestDataFile::NextStmt(TPtrC8& aStmt)
1589 if(iStartPos < iFileData->Length())
1591 const TUint8* pStart = iFileData->Des().Ptr() + iStartPos;
1592 const TUint8* pEnd = pStart;
1593 while(*pEnd++ != 0x0A)
1596 iStartPos += pEnd - pStart;
1597 aStmt.Set(pStart, pEnd - pStart - 1);
1603 //Get a field "aFieldNo" from "aStr" statement containing encoded unicode character data
1604 TPtrC8 GetUnicodeDataField(const TPtrC8& aStr, TInt aFieldNo)
1606 const TUint8* pStart = aStr.Ptr();
1607 //Find the beginning of the field
1609 while(count < aFieldNo)
1611 if(*pStart++ == ';')
1616 //Find the end of the field
1617 const TUint8* pEnd = pStart;
1618 while(*pEnd++ != ';')
1621 //Construct a string from the field data
1622 TPtrC8 ptr(pStart, pEnd - pStart - 1);
1626 //Construct a string "aStr" with the extracted hex codes from "aUnicodeData"
1627 //The extracted unicodes are placed not from position 0, because some of
1628 //the decomposable unicode characters are combining characters. If "aStr" is a search
1629 //string, then the searching algorithm will not work.
1630 void FillStringL(TDes16& aStr, const TDesC8& aUnicodeData)
1632 aStr.SetLength(aStr.MaxLength());
1633 TLex8 lex(aUnicodeData);
1635 for(len=0;!lex.Eos();++len)
1638 User::LeaveIfError(lex.Val(code, EHex));
1639 lex.Assign(lex.NextToken());
1640 if (!IsSupplementary(code))
1642 aStr[1+len] = (TUint16)code;
1646 aStr[1+len] = GetHighSurrogate(code);
1648 aStr[1+len] = GetLowSurrogate(code);
1651 __ASSERT_ALWAYS(len > 0, User::Invariant());
1652 aStr.SetLength(1 + len);
1655 //Get the character unicode, which is at position 0
1656 TUint32 GetChCodeL(const TDesC8& aStr)
1660 User::LeaveIfError(lex.Val(chCode, EHex));
1664 //Simple unicode folding tests
1665 void FindMatchSectionFoldedTestSimple()
1667 _LIT16(KCandidate, "abca\xE1\x62\x62\x61\x61\x61\x62\x63\x62\x61");
1668 DoFindMatchSectionFoldedTest(KCandidate, _L("abc"), 0);
1669 DoFindMatchSectionFoldedTest(KCandidate, _L("abb"), -1);
1670 DoFindMatchSectionFoldedTest(KCandidate, _L("caa"), -1);
1671 DoFindMatchSectionFoldedTest(KCandidate, _L("abcb"), 9);
1672 DoFindMatchSectionFoldedTest(KCandidate, _L("\xE1"), 4);
1673 DoFindMatchSectionFoldedTest(KCandidate, _L("a\x301"), 4);
1674 DoFindMatchSectionFoldedTest(KCandidate, _L("A\xC1\x42\x42"), 3);
1675 DoFindMatchSectionFoldedTest(KCandidate, _L("a\x301\x42\x42"), 4);
1676 DoFindMatchSectionFoldedTest(KCandidate, _L("a?BB"), 3);
1677 DoFindMatchSectionFoldedTest(KCandidate, _L(""), 0);
1678 DoFindMatchSectionFoldedTest(KCandidate, _L("?"), 0);
1679 DoFindMatchSectionFoldedTest(KCandidate, _L("??????????????"), 0);
1680 DoFindMatchSectionFoldedTest(KCandidate, _L("???????????????"), -1);
1681 DoFindMatchSectionFoldedTest(KCandidate, _L("????a?????????"), -1);
1682 DoFindMatchSectionFoldedTest(KCandidate, _L("???a??????????"), 0);
1683 DoFindMatchSectionFoldedTest(KCandidate, _L("caa?"), -1);
1684 DoFindMatchSectionFoldedTest(KCandidate, _L("abcb?"), 9);
1685 DoFindMatchSectionFoldedTest(KCandidate, _L("abcb??"), -1);
1686 DoFindMatchSectionFoldedTest(KCandidate, _L("b?aa"), 5);
1689 //Extended tests - all characters, having non-zero "character decomposition mapping" field
1690 //or non-zero "upper case mapping" field
1691 void FindMatchSectionFoldedTestComplexL()
1693 TBuf16<10> candidate;
1694 candidate.Copy(_L16("abcdefghij"));
1695 TBuf16<10> searchTerm;
1696 searchTerm.Copy(_L16("eeeeefghij"));
1697 const TInt KChPos = 5;
1698 //Read and parse each line from the unicode data file.
1699 RUnicodeTestDataFile unicodeTestDataFile;
1700 unicodeTestDataFile.OpenLC();
1702 while(unicodeTestDataFile.NextStmt(stmt) && stmt.Length() > 0)
1704 //Get the character code
1705 TUint32 chCode = GetChCodeL(stmt);
1706 //"LATIN CAPITAL LETTER I WITH DOT ABOVE" - the searching algorithm does not work with it.
1707 if(chCode == (TUint32)0x0130)
1711 if (!IsSupplementary(chCode))
1713 candidate[KChPos] = (TUint16)chCode;
1717 candidate[KChPos] = GetHighSurrogate(chCode);
1718 candidate[KChPos+1] = GetLowSurrogate(chCode);
1720 //"Character decomposition mapping" is the 5th field, starting from 0.
1721 TPtrC8 decomp(GetUnicodeDataField(stmt, 5));
1722 if(decomp.Length() > 1 && decomp[0] != '<')
1724 //This character has valid decomposition mapping - test it.
1725 //Construct the search string
1726 FillStringL(searchTerm, decomp);
1728 DoFindMatchSectionFoldedTest(candidate, searchTerm, KChPos);
1730 //"Uppercase mapping" is the 12th field, starting from 0.
1731 TPtrC8 upperc(GetUnicodeDataField(stmt, 12));
1732 if(upperc.Length() > 1)
1734 //This character has valid uppercase mapping - test it.
1735 //Construct the search string
1736 FillStringL(searchTerm, upperc);
1738 DoFindMatchSectionFoldedTest(candidate, searchTerm, KChPos);
1740 }//end of "while" - for each file statement
1741 CleanupStack::PopAndDestroy(&unicodeTestDataFile);
1744 //MatchStringFolded test
1745 void MatchStringFoldedTestL()
1747 TBuf16<3> candidate;
1748 candidate.Copy(_L16("aa"));
1749 TBuf16<10> searchTerm;
1750 searchTerm.Copy(_L16("aaaaaaaaaa"));
1751 const TInt KChPos = 1;
1752 //Read and parse each line from the unicode data file.
1753 RUnicodeTestDataFile unicodeTestDataFile;
1754 unicodeTestDataFile.OpenLC();
1756 while(unicodeTestDataFile.NextStmt(stmt) && stmt.Length() > 0)
1758 //Get the character code
1759 TUint32 chCode = GetChCodeL(stmt);
1760 //"LATIN CAPITAL LETTER I WITH DOT ABOVE" - the searching algorithm does not work with it.
1761 if(chCode == (TUint32)0x0130)
1765 if (!IsSupplementary(chCode))
1767 candidate[KChPos] = (TUint16)chCode;
1768 candidate.SetLength(2);
1772 candidate[KChPos] = GetHighSurrogate(chCode);
1773 candidate.SetLength(3);
1774 candidate[KChPos+1] = GetLowSurrogate(chCode);
1776 //"Character decomposition mapping" is the 5th field, starting from 0.
1777 TPtrC8 decomp(GetUnicodeDataField(stmt, 5));
1778 if(decomp.Length() > 1 && decomp[0] != '<')
1780 //This character has valid decomposition mapping - test it.
1781 //Construct the search string
1782 FillStringL(searchTerm, decomp);
1784 test(MatchStringFolded(candidate.Ptr(), candidate.Ptr() + candidate.Length(),
1785 searchTerm.Ptr(), searchTerm.Ptr() + searchTerm.Length()));
1787 //"Uppercase mapping" is the 12th field, starting from 0.
1788 TPtrC8 upperc(GetUnicodeDataField(stmt, 12));
1789 if(upperc.Length() > 1)
1791 //This character has valid uppercase mapping - test it.
1792 //Construct the search string
1793 FillStringL(searchTerm, upperc);
1795 test(MatchStringFolded(candidate.Ptr(), candidate.Ptr() + candidate.Length(),
1796 searchTerm.Ptr(), searchTerm.Ptr() + searchTerm.Length()));
1798 }//end of "while" - for each file statement
1799 CleanupStack::PopAndDestroy(&unicodeTestDataFile);
1802 void FindMatchSectionFoldedTestL()
1804 FindMatchSectionFoldedTestSimple();
1805 FindMatchSectionFoldedTestComplexL();
1808 void TestFindMatchFoldedL()
1810 MatchSectionFoldedTest();
1811 FindMatchSectionFoldedTestL();
1812 MatchStringFoldedTestL();
1815 void TestCompareFoldedEqual(const TDesC& a, const TDesC& b)
1817 test(a.CompareF(b) == 0);
1818 test(b.CompareF(a) == 0);
1821 void TestCompareFolded()
1824 TestCompareFoldedEqual(_L("\x100"), _L("\x101"));
1825 TestCompareFoldedEqual(_L("\x100"), _L("A\x304"));
1826 TestCompareFoldedEqual(_L("\x100"), _L("a\x304"));
1827 TestCompareFoldedEqual(_L("\x104"), _L("\x105"));
1828 TestCompareFoldedEqual(_L("\x104"), _L("a\x328"));
1829 TestCompareFoldedEqual(_L("\x107"), _L("C\x301"));
1830 TestCompareFoldedEqual(_L("\x10F"), _L("\x10E"));
1831 TestCompareFoldedEqual(_L("\x10F"), _L("D\x30C"));
1832 TestCompareFoldedEqual(_L("\x110"), _L("\x111"));
1833 TestCompareFoldedEqual(_L("\x123"), _L("G\x327"));
1834 TestCompareFoldedEqual(_L("\x132"), _L("\x133"));
1835 TestCompareFoldedEqual(_L("\x131"), _L("i"));
1836 TestCompareFoldedEqual(_L("\x131"), _L("I"));
1837 TestCompareFoldedEqual(_L("i"), _L("I"));
1838 TestCompareFoldedEqual(_L("\x13F"), _L("\x140"));
1839 TestCompareFoldedEqual(_L("\x141"), _L("\x142"));
1840 TestCompareFoldedEqual(_L("\x14A"), _L("\x14B"));
1841 TestCompareFoldedEqual(_L("\x150"), _L("\x151"));
1842 TestCompareFoldedEqual(_L("\x150"), _L("o\x30B"));
1843 TestCompareFoldedEqual(_L("\x152"), _L("\x153"));
1844 TestCompareFoldedEqual(_L("\x17D"), _L("\x17E"));
1845 TestCompareFoldedEqual(_L("\x17D"), _L("z\x30C"));
1847 TestCompareFoldedEqual(_L("\x182"), _L("\x183"));
1848 TestCompareFoldedEqual(_L("\x184"), _L("\x185"));
1849 TestCompareFoldedEqual(_L("\x187"), _L("\x188"));
1850 TestCompareFoldedEqual(_L("\x18A"), _L("\x257"));
1851 TestCompareFoldedEqual(_L("\x194"), _L("\x263"));
1852 TestCompareFoldedEqual(_L("\x195"), _L("\x1F6"));
1853 TestCompareFoldedEqual(_L("\x196"), _L("\x269"));
1854 TestCompareFoldedEqual(_L("\x1A2"), _L("\x1A3"));
1855 TestCompareFoldedEqual(_L("\x1A6"), _L("\x280"));
1856 TestCompareFoldedEqual(_L("\x1BF"), _L("\x1F7"));
1857 TestCompareFoldedEqual(_L("\x1DC"), _L("\x1DB"));
1858 TestCompareFoldedEqual(_L("\x1DC"), _L("u\x308\x300"));
1859 TestCompareFoldedEqual(_L("\x1DD"), _L("\x18E"));
1860 TestCompareFoldedEqual(_L("\x1EC"), _L("\x1ED"));
1861 TestCompareFoldedEqual(_L("\x1FC"), _L("\x1FD"));
1862 TestCompareFoldedEqual(_L("\x200"), _L("\x201"));
1863 TestCompareFoldedEqual(_L("\x216"), _L("u\x311"));
1864 TestCompareFoldedEqual(_L("\x21B"), _L("T\x326"));
1865 TestCompareFoldedEqual(_L("\x21C"), _L("\x21D"));
1866 TestCompareFoldedEqual(_L("\x229"), _L("E\x327"));
1867 TestCompareFoldedEqual(_L("\x22A"), _L("\x22B"));
1868 TestCompareFoldedEqual(_L("\x22A"), _L("O\x308\x304"));
1869 TestCompareFoldedEqual(_L("\x22A"), _L("\xF6\x304"));
1870 TestCompareFoldedEqual(_L("\x233"), _L("y\x304"));
1871 TestCompareFoldedEqual(_L("\x233"), _L("\x232"));
1874 void TestCompareFoldedNotEqual(TDesC& a, TDesC& b, TInt aValue)
1876 test(a.CompareF(b) == aValue);
1879 static void TestCompareFoldedAdditional()
1881 const TText16 UnicodeTextOne16[] = {'a', 0};
1882 const TText16 ErrUnicodeTextOne16[] = {'[', 0};
1884 const TText16 UnicodeTextTwo16[] = {0x00EA, 0x0323, 0};
1885 const TText16 ErrUnicodeTextTwo16[] = {0x00EA, 't', 0};
1887 const TText16 UnicodeTextThree16[] = {0x00EA, 0x03B1, 0};
1888 const TText16 ErrUnicodeTextThree16[] = {0x00EA, 0x0323, 0};
1890 TBufC16<ARRAY_SIZE(UnicodeTextOne16) - 1> oriUnicodeSmallTextOne(UnicodeTextOne16);
1891 TBufC16<ARRAY_SIZE(ErrUnicodeTextOne16) - 1> nonMatchUnicodeSmallTextOne(ErrUnicodeTextOne16);
1893 TBufC16<ARRAY_SIZE(UnicodeTextTwo16) - 1> oriUnicodeSmallTextTwo(UnicodeTextTwo16);
1894 TBufC16<ARRAY_SIZE(ErrUnicodeTextTwo16) - 1> nonMatchUnicodeSmallTextTwo(ErrUnicodeTextTwo16);
1896 TBufC16<ARRAY_SIZE(UnicodeTextThree16) - 1> oriUnicodeSmallTextThree(UnicodeTextThree16);
1897 TBufC16<ARRAY_SIZE(ErrUnicodeTextThree16) - 1> nonMatchUnicodeSmallTextThree(ErrUnicodeTextThree16);
1899 const TText16 AsciiText16[] = {'A', 'B', 'C', 'D', 'E', 0};
1901 TBufC16<5> oriAsciiSmallText(_L("ABCDE"));
1903 // Check that characters are non matching with return value as stated
1905 TestCompareFoldedNotEqual(oriUnicodeSmallTextOne, nonMatchUnicodeSmallTextOne, 6);
1906 TestCompareFoldedNotEqual(oriUnicodeSmallTextTwo, nonMatchUnicodeSmallTextTwo, 33);
1907 TestCompareFoldedNotEqual(oriUnicodeSmallTextThree, nonMatchUnicodeSmallTextThree, -33);
1909 // Try other way around...
1911 TestCompareFoldedNotEqual(nonMatchUnicodeSmallTextOne, oriUnicodeSmallTextOne, -6);
1912 TestCompareFoldedNotEqual(nonMatchUnicodeSmallTextTwo, oriUnicodeSmallTextTwo, -33);
1913 TestCompareFoldedNotEqual(nonMatchUnicodeSmallTextThree, oriUnicodeSmallTextThree, 33);
1915 // Declare a TPtrC16 which is base from AsciiText16...
1917 TPtrC16 AsciiSmallText;
1919 AsciiSmallText.Set(AsciiText16, 4);
1921 // Check the boundary case
1923 TestCompareFoldedNotEqual(oriAsciiSmallText, AsciiSmallText, 1);
1925 // Try other way around...
1927 TestCompareFoldedNotEqual(AsciiSmallText, oriAsciiSmallText, -1);
1933 TestFindMatchFoldedL();
1934 TestCompareFolded();
1935 TestCompareFoldedAdditional();
1939 _LIT(KCandidateString1, "abcdefg");
1940 _LIT(KCandidateString2, "\x1f82\x1f02\x345\x1f00\x300\x345\x3b1\x313\x300\x345");
1941 _LIT(KCandidateString3, "abcabcdababc");
1942 _LIT(KCandidateString4, "xyzxyxyzxyxyyxyzxyy");
1944 _LIT(KMatch1, "abc");
1945 _LIT(KMatch2, "abc*");
1946 _LIT(KMatch3, "*abc*");
1947 _LIT(KMatch4, "abc*def");
1948 _LIT(KMatch5, "abc*def*g*");
1949 _LIT(KMatch6, "*def");
1950 _LIT(KMatch7, "**d?f?");
1951 _LIT(KMatch8, "*d?f??");
1952 _LIT(KMatch9, "***d?f??*");
1953 _LIT(KMatch10, "a*c*g");
1954 _LIT(KMatch11, "*c*g");
1956 _LIT(KMatch12, "*\x1f82");
1957 _LIT(KMatch13, "*\x1f82*");
1958 //_LIT(KMatch14, "*\x3b1*");
1959 _LIT(KMatch15, "*\x313*");
1960 _LIT(KMatch16, "*\x300*");
1961 //_LIT(KMatch17, "*\x345*");
1962 //_LIT(KMatch18, "*\x3b1\x313*");
1963 //_LIT(KMatch19, "*\x3b1\x313\x300*");
1964 _LIT(KMatch20, "*\x1f82*\x1f82*\x1f82\x1f82");
1965 _LIT(KMatch21, "*\x1f82*\x1f82*\x1f82\x1f82*\x1f82*");
1967 _LIT(KMatch22, "*aba*");
1968 _LIT(KMatch23, "*abc");
1969 _LIT(KMatch24, "a*abc");
1970 _LIT(KMatch25, "a*ab");
1971 _LIT(KMatch26, "*ca*abc");
1972 _LIT(KMatch27, "*ca*??c");
1973 _LIT(KMatch28, "*??c");
1974 _LIT(KMatch29, "a*babc");
1975 _LIT(KMatch30, "*xyy");
1978 _LIT(KPeach, "pe\x302\x63he");
1979 _LIT(KFooMatch1, "fo*");
1980 _LIT(KFooMatch2, "*Fo*");
1981 _LIT(KFooMatch3, "*f*O*o");
1982 _LIT(KFooMatch4, "*f*o*o*");
1983 _LIT(KFooMatch5, "*o");
1984 _LIT(KFooMatch6, "???");
1985 _LIT(KFooMatch7, "*?o?*");
1986 _LIT(KFooMatch8, "*?");
1987 _LIT(KFooNonMatch1, "oo*");
1988 _LIT(KFooNonMatch2, "??");
1989 _LIT(KFooNonMatch3, "????");
1990 _LIT(KFooNonMatch4, "*?f*");
1991 _LIT(KFooNonMatch5, "*f*f*");
1992 _LIT(KFooNonMatch6, "*?*f*");
1993 _LIT(KPeachMatch1, "p?che");
1994 _LIT(KPeachNonMatch1, "peche");
1995 _LIT(KPeachNonMatch2, "pe?che");
1996 _LIT(KPeachNonMatch3, "pe?he");
1997 _LIT(KPeachNonMatch4, "pe*");
1999 void TestMatchIdentifiersTDesC(const TDesC& aCandidate, const TDesC& aSearchTerm, TInt aExpectedResult)
2001 const TText16* candidateStart = aCandidate.Ptr();
2002 const TText16* candidateEnd = candidateStart + aCandidate.Length();
2003 const TText16* searchTermStart = aSearchTerm.Ptr();
2004 const TText16* searchTermEnd = searchTermStart + aSearchTerm.Length();
2005 TInt pos = ::LocateMatchStringFolded(candidateStart, candidateEnd, searchTermStart, searchTermEnd);
2006 test(aExpectedResult == pos);
2009 void TestMatchIdentifiers()
2011 TestMatchIdentifiersTDesC(KCandidateString1, KMatch1, KErrNotFound);
2012 TestMatchIdentifiersTDesC(KCandidateString1, KMatch2, 0);
2013 TestMatchIdentifiersTDesC(KCandidateString1, KMatch3, 0);
2014 TestMatchIdentifiersTDesC(KCandidateString1, KMatch4, KErrNotFound);
2015 TestMatchIdentifiersTDesC(KCandidateString1, KMatch5, 0);
2016 TestMatchIdentifiersTDesC(KCandidateString1, KMatch6, KErrNotFound);
2017 TestMatchIdentifiersTDesC(KCandidateString1, KMatch7, 3);
2018 TestMatchIdentifiersTDesC(KCandidateString1, KMatch8, KErrNotFound);
2019 TestMatchIdentifiersTDesC(KCandidateString1, KMatch9, KErrNotFound);
2020 TestMatchIdentifiersTDesC(KCandidateString1, KMatch10, 0);
2021 TestMatchIdentifiersTDesC(KCandidateString1, KMatch11, 2);
2022 TestMatchIdentifiersTDesC(KCandidateString2, KMatch12, 6);
2023 TestMatchIdentifiersTDesC(KCandidateString2, KMatch13, 0);
2024 //The next test does not pass with the new optimised methods
2025 //TestMatchIdentifiersTDesC(KCandidateString2, KMatch14, KErrNotFound);
2026 TestMatchIdentifiersTDesC(KCandidateString2, KMatch15, KErrNotFound);
2027 TestMatchIdentifiersTDesC(KCandidateString2, KMatch16, KErrNotFound);
2028 // I have taken this test out: it tests that combining ypogegrammeni is not
2029 // found on its own: but with case folding it can become a non-combining
2030 // character (iota), so this test is not relevant.
2031 // TestMatchIdentifiersTDesC(KCandidateString2, KMatch17, KErrNotFound);
2032 //The next tests do not pass with the new optimised methods
2033 //TestMatchIdentifiersTDesC(KCandidateString2, KMatch18, KErrNotFound);
2034 //TestMatchIdentifiersTDesC(KCandidateString2, KMatch19, KErrNotFound);
2035 TestMatchIdentifiersTDesC(KCandidateString2, KMatch20, 0);
2036 TestMatchIdentifiersTDesC(KCandidateString2, KMatch21, KErrNotFound);
2037 TestMatchIdentifiersTDesC(KCandidateString3, KMatch22, 7);
2038 TestMatchIdentifiersTDesC(KCandidateString3, KMatch23, 9);
2039 TestMatchIdentifiersTDesC(KCandidateString3, KMatch24, 0);
2040 TestMatchIdentifiersTDesC(KCandidateString3, KMatch25, KErrNotFound);
2041 TestMatchIdentifiersTDesC(KCandidateString3, KMatch26, 2);
2042 TestMatchIdentifiersTDesC(KCandidateString3, KMatch27, 2);
2043 TestMatchIdentifiersTDesC(KCandidateString3, KMatch28, 9);
2044 TestMatchIdentifiersTDesC(KCandidateString3, KMatch29, 0);
2045 TestMatchIdentifiersTDesC(KCandidateString4, KMatch30, 16);
2047 TestMatchIdentifiersTDesC(KFoo1, KFoo1, 0);
2048 TestMatchIdentifiersTDesC(KFoo1, KFooMatch1, 0);
2049 TestMatchIdentifiersTDesC(KFoo1, KFooMatch2, 0);
2050 TestMatchIdentifiersTDesC(KFoo1, KFooMatch3, 0);
2051 TestMatchIdentifiersTDesC(KFoo1, KFooMatch4, 0);
2052 TestMatchIdentifiersTDesC(KFoo1, KFooMatch5, 2);
2053 TestMatchIdentifiersTDesC(KFoo1, KFooMatch6, 0);
2054 TestMatchIdentifiersTDesC(KFoo1, KFooMatch7, 0);
2055 TestMatchIdentifiersTDesC(KFoo1, KFooMatch8, 2);
2056 TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch1, KErrNotFound);
2057 TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch2, KErrNotFound);
2058 TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch3, KErrNotFound);
2059 TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch4, KErrNotFound);
2060 TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch5, KErrNotFound);
2061 TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch6, KErrNotFound);
2062 TestMatchIdentifiersTDesC(KPeach, KPeachMatch1, 0);
2063 TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch1, KErrNotFound);
2064 TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch2, KErrNotFound);
2065 TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch3, KErrNotFound);
2066 TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch4, KErrNotFound);
2068 TestMatchIdentifiersTDesC(_L(""), _L(""), 0);
2069 TestMatchIdentifiersTDesC(_L("a"), _L(""), KErrNotFound);
2070 TestMatchIdentifiersTDesC(_L(""), _L("*"), 0);
2073 void TestFindIdentifierTDesC(const TDesC& aCandidateString, const TDesC& aSearchTerm, TInt /*aExpectedResult*/)
2075 TUTF32Iterator candidateIt(aCandidateString.Ptr(), aCandidateString.Ptr() + aCandidateString.Length());
2076 TUTF32Iterator searchIt(aSearchTerm.Ptr(), aSearchTerm.Ptr() + aSearchTerm.Length());
2077 /*aExpectedResult = */::FindFolded(candidateIt, searchIt);
2080 //INC057641 - NTT Functional BC break in 8.1a: string comparison changed
2081 static void INC057641L()
2083 _LIT16(KEmptyText, "");
2084 HBufC16* str = HBufC16::NewLC(4);
2085 str->Des().Copy(_L("****"));
2086 TInt res = str->CompareC(KEmptyText);
2087 CleanupStack::PopAndDestroy(str);
2091 _LIT(KFind1, "abc");
2092 _LIT(KFind2, "def");
2093 _LIT(KFind3, "efg");
2094 _LIT(KFind4, "fga");
2095 _LIT(KFind5, "acd");
2096 _LIT(KFind6, "\x1f82");
2097 _LIT(KFind7, "\x3b1\x313\x300\x345");
2098 _LIT(KFind8, "\x3b1");
2099 _LIT(KFind9, "aba");
2100 _LIT(KFind10, "abc");
2102 void TestFindIdentifier()
2104 TestFindIdentifierTDesC(KCandidateString1, TPtrC(), 0);
2105 TestFindIdentifierTDesC(KCandidateString1, KFind1, 0);
2106 TestFindIdentifierTDesC(KCandidateString1, KFind2, 3);
2107 TestFindIdentifierTDesC(KCandidateString1, KFind3, 4);
2108 TestFindIdentifierTDesC(KCandidateString1, KFind4, KErrNotFound);
2109 TestFindIdentifierTDesC(KCandidateString1, KFind5, KErrNotFound);
2110 TestFindIdentifierTDesC(KCandidateString2, KFind6, 0);
2111 TestFindIdentifierTDesC(KCandidateString2, KFind7, 0);
2112 TestFindIdentifierTDesC(KCandidateString2, KFind8, KErrNotFound);
2113 TestFindIdentifierTDesC(KCandidateString3, KFind9, 7);
2114 TestFindIdentifierTDesC(KCandidateString3, KFind10, 0);
2119 TText8 const* iLeft;
2120 TText8 const* iRight;
2124 TestMatch8 const Tests8[]=
2126 {_S8(""),_S8(""),0},
2127 {_S8(""),_S8("?"),KErrNotFound},
2128 {_S8(""),_S8("*"),0},
2129 {_S8(""),_S8("**"),0},
2130 {_S8(""),_S8("*x*"),KErrNotFound},
2131 {_S8("x"),_S8(""),KErrNotFound},
2132 {_S8("x"),_S8("?"),0},
2133 {_S8("x"),_S8("*"),0},
2134 {_S8("x"),_S8("**"),0},
2135 {_S8("x"),_S8("**?"),0},
2136 {_S8("x"),_S8("?**"),0},
2137 {_S8("x"),_S8("**?*"),0},
2138 {_S8("x"),_S8("x"),0},
2139 {_S8("x"),_S8("a"),KErrNotFound},
2140 {_S8("x"),_S8("xx"),KErrNotFound},
2141 {_S8("x"),_S8("?x"),KErrNotFound},
2142 {_S8("x"),_S8("x*"),0},
2143 {_S8("x"),_S8("*x"),0},
2144 {_S8("x"),_S8("*x*"),0},
2145 {_S8("x"),_S8("**x*"),0},
2146 {_S8("abc"),_S8(""),KErrNotFound},
2147 {_S8("abc"),_S8("?*"),0},
2148 {_S8("abc"),_S8("*?"),2},
2149 {_S8("abc"),_S8("*?*?"),0},
2150 {_S8("abc"),_S8("*a*"),0},
2151 {_S8("abc"),_S8("*b*"),1},
2152 {_S8("abc"),_S8("*c*"),2},
2153 {_S8("abc"),_S8("*a"),KErrNotFound},
2154 {_S8("abc"),_S8("*c"),2},
2155 {_S8("abc"),_S8("*?c"),1},
2156 {_S8("abc"),_S8("??c"),0},
2157 {_S8("abc"),_S8("*b?"),1},
2162 TText16 const* iLeft;
2163 TText16 const* iRight;
2167 TestMatch16 const Tests16[]=
2169 {_S16(""),_S16(""),0},
2170 {_S16(""),_S16("?"),KErrNotFound},
2171 {_S16(""),_S16("*"),0},
2172 {_S16(""),_S16("**"),0},
2173 {_S16(""),_S16("*x*"),KErrNotFound},
2174 {_S16("x"),_S16(""),KErrNotFound},
2175 {_S16("x"),_S16("?"),0},
2176 {_S16("x"),_S16("*"),0},
2177 {_S16("x"),_S16("**"),0},
2178 {_S16("x"),_S16("**?"),0},
2179 {_S16("x"),_S16("?**"),0},
2180 {_S16("x"),_S16("**?*"),0},
2181 {_S16("x"),_S16("x"),0},
2182 {_S16("x"),_S16("a"),KErrNotFound},
2183 {_S16("x"),_S16("xx"),KErrNotFound},
2184 {_S16("x"),_S16("?x"),KErrNotFound},
2185 {_S16("x"),_S16("x*"),0},
2186 {_S16("x"),_S16("*x"),0},
2187 {_S16("x"),_S16("*x*"),0},
2188 {_S16("x"),_S16("**x*"),0},
2189 {_S16("abc"),_S16(""),KErrNotFound},
2190 {_S16("abc"),_S16("?*"),0},
2191 {_S16("abc"),_S16("*?"),2},
2192 {_S16("abc"),_S16("*?*?"),0},
2193 {_S16("abc"),_S16("*a*"),0},
2194 {_S16("abc"),_S16("*b*"),1},
2195 {_S16("abc"),_S16("*c*"),2},
2196 {_S16("abc"),_S16("*a"),KErrNotFound},
2197 {_S16("abc"),_S16("*c"),2},
2198 {_S16("abc"),_S16("*?c"),1},
2199 {_S16("abc"),_S16("??c"),0},
2200 {_S16("abc"),_S16("*b?"),1},
2201 {_S16("\x0100"),_S16("\x0100"),0},
2202 {_S16("\x0100"),_S16("*"),0},
2203 {_S16("\x0100"),_S16("?"),0},
2204 {_S16("\x0100"),_S16("*\x0100"),0},
2205 {_S16("\x0100"),_S16("*\x0100?"),KErrNotFound},
2206 {_S16("\x0101"),_S16("\x0101"),0},
2207 {_S16("\x0101"),_S16("*"),0},
2208 {_S16("\x0101"),_S16("?"),0},
2209 {_S16("\x0101"),_S16("*\x0101"),0},
2210 {_S16("\x0101"),_S16("*\x0101?"),KErrNotFound},
2211 {_S16("\x0ffe"),_S16("\x0ffe"),0},
2212 {_S16("\x0ffe"),_S16("*"),0},
2213 {_S16("\x0ffe"),_S16("?"),0},
2214 {_S16("\x0ffe"),_S16("*\x0ffe"),0},
2215 {_S16("\x0ffe"),_S16("*\x0ffe?"),KErrNotFound},
2216 {_S16("\x0fff"),_S16("\x0fff"),0},
2217 {_S16("\x0fff"),_S16("*"),0},
2218 {_S16("\x0fff"),_S16("?"),0},
2219 {_S16("\x0fff"),_S16("*\x0fff"),0},
2220 {_S16("\x0fff"),_S16("*\x0fff?"),KErrNotFound},
2221 {_S16("\x1000"),_S16("\x1000"),0},
2222 {_S16("\x1000"),_S16("*"),0},
2223 {_S16("\x1000"),_S16("?"),0},
2224 {_S16("\x1000"),_S16("*\x1000"),0},
2225 {_S16("\x1000"),_S16("*\x1000?"),KErrNotFound},
2226 {_S16("\x1001"),_S16("\x1001"),0},
2227 {_S16("\x1001"),_S16("*"),0},
2228 {_S16("\x1001"),_S16("?"),0},
2229 {_S16("\x1001"),_S16("*\x1001"),0},
2230 {_S16("\x1001"),_S16("*\x1001?"),KErrNotFound},
2231 // fffe, ffff is special
2232 //{_S16("\xfffe"),_S16("\xfffe"),0},
2233 //{_S16("\xfffe"),_S16("*"),0},
2234 //{_S16("\xfffe"),_S16("?"),0},
2235 //{_S16("\xfffe"),_S16("*\xfffe"),0}, //reserved
2236 //{_S16("\xfffe"),_S16("*\xfffe?"),KErrNotFound},
2237 //{_S16("\xffff"),_S16("\xffff"),0},
2238 //{_S16("\xffff"),_S16("*"),0},
2239 //{_S16("\xffff"),_S16("?"),0},
2240 //{_S16("\xffff"),_S16("*\xffff?"),KErrNotFound},
2241 //{_S16("\x0101\xffff\x0ffe"),_S16("*\xffff"),0},
2242 //{_S16("\x0101\xffff\x0ffe"),_S16("*\xffff"),0},
2243 //{_S16("\x0101\xfffe\x0ffe"),_S16("\xffff?"),0},
2244 //{_S16("\x0101\xfffe\x0ffe"),_S16("*\xffff?"),0},
2245 {_S16("\x04fa"),_S16("*"),0},
2248 TInt KTests=sizeof(Tests8)/sizeof(Tests8[0]);
2249 TInt KTests16=sizeof(Tests16)/sizeof(Tests16[0]);
2251 TestMatch16 const TestsSurrogate[]=
2253 // not duplicate, test MatchSurrogate here
2254 {_S16(""),_S16(""),0},
2255 {_S16(""),_S16("?"),KErrNotFound},
2256 {_S16(""),_S16("*"),0},
2257 {_S16(""),_S16("**"),0},
2258 {_S16(""),_S16("*x*"),KErrNotFound},
2259 {_S16("x"),_S16(""),KErrNotFound},
2260 {_S16("x"),_S16("?"),0},
2261 {_S16("x"),_S16("*"),0},
2262 {_S16("x"),_S16("**"),0},
2263 {_S16("x"),_S16("**?"),0},
2264 {_S16("x"),_S16("?**"),0}, // 10
2265 {_S16("x"),_S16("**?*"),0},
2266 {_S16("x"),_S16("x"),0},
2267 {_S16("x"),_S16("a"),KErrNotFound},
2268 {_S16("x"),_S16("xx"),KErrNotFound},
2269 {_S16("x"),_S16("?x"),KErrNotFound},
2270 {_S16("x"),_S16("x*"),0},
2271 {_S16("x"),_S16("*x"),0},
2272 {_S16("x"),_S16("*x*"),0},
2273 {_S16("x"),_S16("**x*"),0},
2274 {_S16("abc"),_S16(""),KErrNotFound}, // 20
2275 {_S16("abc"),_S16("?*"),0},
2276 {_S16("abc"),_S16("*?"),2},
2277 {_S16("abc"),_S16("*?*?"),0},
2278 {_S16("abc"),_S16("*a*"),0},
2279 {_S16("abc"),_S16("*b*"),1},
2280 {_S16("abc"),_S16("*c*"),2},
2281 {_S16("abc"),_S16("*a"),KErrNotFound},
2282 {_S16("abc"),_S16("*c"),2},
2283 {_S16("abc"),_S16("*?c"),1},
2284 {_S16("abc"),_S16("??c"),0}, // 30
2285 {_S16("abc"),_S16("*b?"),1},
2287 // ones containing supplementary characters
2288 {_S16("ab\xD840\xDDAD"),_S16("*b*"),1},
2289 {_S16("ab\xD840\xDDAD"),_S16("*b?"),1},
2290 {_S16("a\xD840\xDDAD\x0063"),_S16("*c*"),3},
2291 {_S16("a\xD840\xDDAD\x0063"),_S16("*\xD840\xDDAD*"),1},
2292 {_S16("a\xD840\xDDAB\xD830\xDDAC\xD840\xDDAC\x0063"),_S16("*\xD840\xDDAC*"),5},
2293 {_S16("\xD840\xDDAB\xD840\xDDAC\x0063"),_S16("?\xD840\xDDAC*"),0},
2294 {_S16("\xD840\xDDAB\xD840\xDDAC\x0063"),_S16("\xD840\xDDAB*"),0},
2295 {_S16("\xD840\xDDAB\xD840\xDDAC\x0063"),_S16("*?\xD840\xDDAC*"),0},
2296 {_S16("\xD840\xDDAB\xD840\xDDAC\xD840\xDDAD\x0063"),_S16("*?\xD840\xDDAD*"),2}, // 40
2299 TInt KTestsSurrogate=sizeof(TestsSurrogate)/sizeof(TestsSurrogate[0]);
2303 @SYMTestCaseID SYSLIB-UNICODE-CT-1770
2304 @SYMTestCaseDesc TDes16 Collation conversion function test
2305 @SYMTestPriority High
2306 @SYMTestActions Testing the three collation conversion function
2307 in TDesC16::GetNormalizedDecomposedFormL,
2308 TDesC16::GetFoldedDecomposedFormL,
2309 TDesC16::GetCollationKeysL
2310 @SYMTestExpectedResults The test must not fail.
2311 @SYMREQ 6178 Add several new Unicode utility functions
2313 static void TestDes16CollationFunctionL()
2315 /**----------------Test TDesC16::GetNormalizedDecomposedFormL------------------*/
2317 HBufC16* outputBuffer=NULL;
2318 _LIT16(KTestString1,"abc") ;
2319 //LATIN CAPITAL LETTER W WITH DIAERESIS(\x0057\x0308)
2320 //LATIN SMALL LETTER A(\x0061)
2321 //LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE(\x006F\x0302\x0303)
2322 //GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI(\x03B1\x0313\x0342\x0345)
2323 _LIT16(KTestString2,"\x1E84\x0061\x1ED7\x1F86");
2324 _LIT16(KTestStringNDF2,"\x0057\x0308\x0061\x006F\x0302\x0303\x03B1\x0313\x0342\x0345");
2326 outputBuffer=KTestString1().GetNormalizedDecomposedFormL();
2327 test(outputBuffer->Compare(KTestString1())==0);
2328 delete outputBuffer;
2330 outputBuffer=KTestString2().GetNormalizedDecomposedFormL();
2331 test(outputBuffer->Compare(KTestStringNDF2())==0);
2332 delete outputBuffer;
2334 /**----------------Test TDesC16::GetFoldedDecomposedFormL------------------*/
2335 _LIT16(KTestString6,"AbC");
2336 _LIT16(KTestStringFolded6,"abc");
2337 //GREEK CAPITAL LETTER OMICRON WITH PSILI =>\x03BF\x0313
2338 //LATIN SMALL LETTER M WITH ACUTE =>\x006D\x0301
2339 //LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE => \x006F\x0302\x0309
2340 _LIT16(KTestString7,"\x1F48\x1E3F\x1ED4");
2341 _LIT16(KTestStringFolded7,"\x03BF\x0313\x006D\x0301\x006F\x0302\x0309");
2343 outputBuffer=KTestString6().GetFoldedDecomposedFormL();
2344 test(outputBuffer->Compare(KTestStringFolded6())==0);
2345 delete outputBuffer;
2347 outputBuffer=KTestString7().GetFoldedDecomposedFormL();
2348 test(outputBuffer->Compare(KTestStringFolded7())==0);
2349 delete outputBuffer;
2351 /**----------------Test TDesC16::GetCollationKeysL------------------*/
2352 TCollationMethod method;
2354 //purposely set the maintable to NULL, this will result in the DefaultTable being used
2355 method.iMainTable = 0;
2356 method.iOverrideTable = 0;
2357 method.iFlags = TCollationMethod::EIgnoreNone;
2359 //---------------Test key generation functionality----------------
2366 _LIT(KInputString1,"xyz");
2367 HBufC8* outbuf=NULL;
2369 _LIT8(KMaxLevel0Key,"\x08\xb9\x08\xbd\x08\xc9");
2370 outbuf=KInputString1().GetCollationKeysL(0,&method);
2371 test(outbuf->Compare(KMaxLevel0Key())==0);
2374 _LIT8(KMaxLevel1Key,"\x08\xb9\x08\xbd\x08\xc9\x00\x00\x01\x01\x01");
2375 outbuf=KInputString1().GetCollationKeysL(1,&method);
2376 test(outbuf->Compare(KMaxLevel1Key())==0);
2379 _LIT8(KMaxLevel2Key,"\x08\xb9\x08\xbd\x08\xc9\x00\x00\x01\x01\x01\x00\x08\x08\x08");
2380 outbuf=KInputString1().GetCollationKeysL(2,&method);
2381 test(outbuf->Compare(KMaxLevel2Key())==0);
2384 _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");
2385 outbuf=KInputString1().GetCollationKeysL(3,&method);
2386 test(outbuf->Compare(KMaxLevel3Key())==0);
2390 Decomposition for 1F70
2393 \x03B1 =09360108-000003B1
2394 \x0300 =00001609-00000300
2395 y =08bd0108-00000079
2397 _LIT(KInputString2,"\x1F70y");
2399 _LIT8(KCollationString22,"\x09\x36\x08\xBD\x00\x00\x01\x16\x01\x00\x08\x08\x08");
2400 outbuf=KInputString2().GetCollationKeysL(2,&method);
2401 test(outbuf->Compare(KCollationString22())==0);
2405 _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");
2406 outbuf=KInputString2().GetCollationKeysL(3,&method);
2407 test(outbuf->Compare(KCollationString23())==0);
2411 Decomposition for 1EAC
2412 1EAC= 1EA0 0302 = 0041 0323 0302
2414 \x0041 =06CF0121-00000041
2415 \x0323 =FF800104-00000001,83230105-00000000(2 keys for one character)
2416 \x0302 =00001D09-00000302
2418 _LIT(KInputString3,"\x1EAC");
2420 _LIT8(KCollationString30,"\x06\xCF\xFF\x80\x83\x23");
2422 _LIT8(KCollationString31,"\x06\xCF\xFF\x80\x83\x23\x00\x00\x01\x01\x01\x1d");
2423 outbuf=KInputString3().GetCollationKeysL(1,&method);
2424 test(outbuf->Compare(KCollationString31())==0);
2428 _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");
2429 outbuf=KInputString3().GetCollationKeysL(3,&method);
2430 test(outbuf->Compare(KCollationString33())==0);
2433 //--------------Test using NULL collationMethod-----------------------
2434 outbuf=KInputString3().GetCollationKeysL(3,NULL);
2435 test(outbuf->Compare(KCollationString33())==0);
2438 //--------------Test using out of limit level-------------------------
2439 outbuf=KInputString3().GetCollationKeysL(6,NULL);
2440 test(outbuf->Compare(KCollationString33())==0);
2443 outbuf=KInputString3().GetCollationKeysL(-1,NULL);
2444 test(outbuf->Compare(KCollationString30())==0);
2450 @SYMTestCaseID SYSLIB-UNICODE-CT-1771
2451 @SYMTestCaseDesc TDes16 Collation conversion function OOM test
2452 @SYMTestPriority High
2453 @SYMTestActions OOM Testing the three collation conversion function
2454 in TDesC16::GetNormalizedDecomposedFormL,
2455 TDesC16::GetFoldedDecomposedFormL,
2456 TDesC16::GetCollationKeysL
2457 @SYMTestExpectedResults The test must not fail.
2458 @SYMREQ 6178 Add several new Unicode utility functions
2460 static void TestDes16CollationFunctionOOM()
2462 test.Next(_L("TestDes16CollationFunctionOOM"));
2464 TInt err, tryCount = 0;
2468 // find out the number of open handles
2469 TInt startProcessHandleCount;
2470 TInt startThreadHandleCount;
2471 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
2473 // Setting Heap failure for OOM test
2474 __UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
2475 TRAP(err,TestDes16CollationFunctionL() );
2476 __UHEAP_SETFAIL(RHeap::ENone, 0);
2478 // check that no handles have leaked
2479 TInt endProcessHandleCount;
2480 TInt endThreadHandleCount;
2481 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
2483 test(startProcessHandleCount == endProcessHandleCount);
2484 test(startThreadHandleCount == endThreadHandleCount);
2487 } while(err == KErrNoMemory);
2489 test(err == KErrNone);
2490 test.Printf(_L("- TestDes16CollationFunctionOOM succeeded at heap failure rate of %i\n"), tryCount);
2493 GLDEF_C TInt E32Main()
2498 CTrapCleanup* trapCleanup = CTrapCleanup::New();
2499 test(trapCleanup != NULL);
2504 test.Start(_L("Match8"));
2506 for (ii=0;ii<KTests;++ii)
2508 TInt r=TPtrC8(Tests8[ii].iLeft).Match(TPtrC8(Tests8[ii].iRight));
2509 test (r==Tests8[ii].iResult);
2510 r=TPtrC8(Tests8[ii].iLeft).MatchF(TPtrC8(Tests8[ii].iRight));
2511 test (r==Tests8[ii].iResult);
2513 test.Next(_L("Match16"));
2514 for (ii=0;ii<KTests16;++ii)
2516 TInt r=TPtrC16(Tests16[ii].iLeft).Match(TPtrC16(Tests16[ii].iRight));
2517 test (r==Tests16[ii].iResult);
2518 r=TPtrC16(Tests16[ii].iLeft).MatchF(TPtrC16(Tests16[ii].iRight));
2519 test (r==Tests16[ii].iResult);
2521 // check code points with upper case
2522 test.Next( _L("Check characters with upper case") );
2523 //039c: lower 03bc, folded 03bc
2524 //00b5: upper 039c, folded 03bc
2525 _LIT( K00b5, "\x00b5" );
2526 _LIT( K039c, "\x039c" );
2527 _LIT( K03bc, "\x03bc" );
2528 test( 0 == TPtrC16( K00b5() ).MatchF( TPtrC16( K039c() ) ) );
2529 test( 0 == TPtrC16( K00b5() ).MatchF( TPtrC16( K00b5() ) ) );
2530 test( 0 == TPtrC16( K00b5() ).MatchF( TPtrC16( K039c() ) ) );
2531 test( 0 == TPtrC16( K00b5() ).MatchF( TPtrC16( K03bc() ) ) );
2533 buf00b5.Copy( K00b5() );
2534 buf00b5.UpperCase();
2535 test( 0 == buf00b5.Find( K039c() ) );
2536 test( 0 == buf00b5.MatchF( K039c() ) );
2538 // check code points with both upper and lower cases
2539 test.Next( _L("Check characters with upper and lower cases") );
2540 // 01C5: upper 01C4, folded 01C6
2541 _LIT( K01c5, "\x01c5" );
2542 _LIT( K01c4, "\x01c4" );
2543 _LIT( K01c6, "\x01c6" );
2544 test( 0 == TPtrC16( K01c5() ).MatchF( TPtrC16( K01c6() ) ) );
2545 test( 0 == TPtrC16( K01c5() ).MatchF( TPtrC16( K01c4() ) ) );
2546 test( 0 == TPtrC16( K01c4() ).MatchF( TPtrC16( K01c5() ) ) );
2547 test( 0 == TPtrC16( K01c4() ).MatchF( TPtrC16( K01c6() ) ) );
2549 buf01c5.Copy( K01c5() );
2550 buf01c5.UpperCase();
2551 test( 0 == buf01c5.Find( K01c4() ) );
2552 test( 0 == buf01c5.MatchF( K01c6() ) );
2554 test.Next(_L("MatchSurrogate"));
2555 for (ii=0;ii<KTestsSurrogate;++ii)
2557 TInt r=TPtrC16(TestsSurrogate[ii].iLeft).MatchF(TPtrC16(TestsSurrogate[ii].iRight));
2558 test (r==TestsSurrogate[ii].iResult);
2561 _LIT( KD800, "\xd800" );
2562 _LIT( KQuestion, "?" );
2563 _LIT( KDC00, "\xdc00" );
2564 _LIT( KDFFF, "\xdfff" );
2566 test( KErrNotFound == TPtrC16( KD800() ).MatchF( TPtrC16( KQuestion() ) ) );
2567 test( 0 == TPtrC16( KD800() ).MatchF( TPtrC16( KD800() ) ) );
2568 test( KErrNotFound == TPtrC16( KDC00() ).MatchF( TPtrC16( KQuestion() ) ) );
2569 test( KErrNotFound == TPtrC16( KDFFF() ).MatchF( TPtrC16( KQuestion() ) ) );
2571 test.Next(_L("Iterator tests"));
2573 ::TestUTF32Iterator();
2574 ::TestFoldedDecompIterator();
2575 ::TestFoldedSortedDecompIterator();
2576 ::TestFoldedCanonicalIterator();
2577 ::TestDecompositionIterator2();
2578 ::TestCanonicalDecompositionIterator2();
2579 ::TestCanonicalDecompositionIteratorCached();
2581 test.Next(_L("Unit tests"));
2583 TestDecompositionIterator();
2584 TestCanonicalDecompositionIterator();
2585 TestCollationValueIterator();
2586 TestMatchIdentifiers();
2587 TestFindIdentifier();
2589 TRAPD(err, TestFoldingL());
2590 test(err == KErrNone);
2592 test.Next(_L("INC057641"));
2593 TRAP(err, INC057641L());
2594 test(err == KErrNone);
2599 test.Next(_L("TestDes16CollationFunctionL"));
2600 TRAP(err,TestDes16CollationFunctionL());
2601 test(err==KErrNone);
2602 ::TestDes16CollationFunctionOOM();
2604 TestDisableCombiningCharacterCheck();