author | Mike Kinghan <mikek@symbian.org> |
Thu, 25 Nov 2010 14:35:45 +0000 | |
branch | GCC_SURGE |
changeset 305 | 1ba12ef4ef89 |
parent 90 | 947f0dc9f7a8 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32test\buffer\t_match.cpp |
|
15 |
// Overview: |
|
16 |
// Test the match methods of TPtrC8 and TPtrC16 objects and the |
|
17 |
// TCharIterator TCombiningCharIterator, TCollationValueIterator |
|
18 |
// and TCollationRawValueIterator classes. |
|
19 |
// API Information: |
|
20 |
// TPtrC8, TPtrC16, TCharIterator, TCombiningCharIterator, |
|
21 |
// TCollationValueIterator, TCollationRawValueIterator |
|
22 |
// Details: |
|
23 |
// - Test and verify the results of TPtrC8 Match and MatchF methods |
|
24 |
// on a variety of constant strings. Verify both match and mismatch |
|
25 |
// conditions. |
|
26 |
// - Test and verify the results of TPtrC16 Match and MatchF methods |
|
27 |
// on a variety of constant strings. Verify both match and mismatch |
|
28 |
// conditions. |
|
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 |
|
59 |
// of strings. |
|
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: |
|
65 |
// All |
|
66 |
// Assumptions/Requirement/Pre-requisites: |
|
67 |
// Failures and causes: |
|
68 |
// Base Port information: |
|
69 |
// |
|
70 |
// |
|
71 |
||
72 |
#include <e32test.h> |
|
73 |
#include <f32file.h> |
|
74 |
#include <collate.h> |
|
75 |
#include "collateimp.h" |
|
76 |
#include "CompareImp.h" |
|
77 |
#include "u32std.h" |
|
78 |
||
79 |
///***************** copied from locale euser source code *********************** |
|
80 |
static const TCollationMethod TheCollationMethod[] = |
|
81 |
{ |
|
82 |
{ |
|
83 |
KUidBasicCollationMethod, // this is the standard unlocalised method |
|
84 |
NULL, // null means use the standard table |
|
85 |
NULL, // there's no override table |
|
86 |
0 // the flags are standard |
|
87 |
} |
|
88 |
}; |
|
89 |
static const TCollationDataSet TheCollationDataSet = |
|
90 |
{ |
|
91 |
TheCollationMethod, |
|
92 |
1 |
|
93 |
}; |
|
94 |
const LCharSet TheCharSet = |
|
95 |
{ |
|
96 |
NULL, |
|
97 |
&TheCollationDataSet |
|
98 |
}; |
|
99 |
const LCharSet* GetLocaleCharSet() |
|
100 |
{ |
|
101 |
return &TheCharSet; |
|
102 |
} |
|
103 |
///******************************************************************************* |
|
104 |
||
105 |
||
106 |
#ifdef __VC32__ |
|
107 |
// Solve compilation problem caused by non-English locale |
|
108 |
#pragma setlocale("english") |
|
109 |
#endif |
|
110 |
||
111 |
#define ARRAY_SIZE(ar) (sizeof(ar) / (sizeof(ar[0]))) |
|
112 |
||
113 |
LOCAL_D RTest test(_L("T_MATCH")); |
|
114 |
||
115 |
_LIT(KUnicodeTestDataFile, "z:\\Test\\UnicodeData.txt"); |
|
116 |
||
117 |
static const TUint32 TheDevanagariKey[] = |
|
118 |
{ |
|
119 |
0x22a010b,0x22b010b,0x285010b,0xb109,0xb209,0xb309,0xb409,0xb509, |
|
120 |
0x6c5e609,0x6c6e609,0x6c7e609,0x6c8e609,0x6c9e609,0x6cae609,0x6cbe609,0x6cce609, |
|
121 |
0x6cde609,0x6cee609,0xba40109,0xba50109,0xba60109,0xba70109,0xba80109,0xba90109, |
|
122 |
0xbaa0109,0xbab0109,0xbac0109,0xbad0109,0xbae0109,0xbaf0109,0xbb00109,0xbb10109, |
|
123 |
0xbb20109,0xbb30109,0xbb40109,0xbb50109,0xbb60109,0xbb70109,0xbb80109,0xbb90109, |
|
124 |
0xbb9b109,0xbba0109,0xbbab109,0xbbb0109,0xbbbb109,0xbbc0109,0xbbd0109,0xbbe0109, |
|
125 |
0xbbf0109,0xbc00109,0xbc0b109,0xbc10109,0xbc20109,0xbc30109,0xbc40109,0xbc50109, |
|
126 |
0xbc5b109,0xbc60109,0xbc6b109,0xbc70109,0xbc80109,0xbc90109,0xbca0109,0xbcb0109, |
|
127 |
0xbcc0109,0xbccb109,0xbcd0109,0xbce0109,0xbceb109,0xbcf0109,0xbd00109,0xbd10109, |
|
128 |
0xbd20109,0xbd2b109,0xbd30109,0xbd3b109,0xbd40109,0xbd50109,0xbd5b109,0xbd60109, |
|
129 |
0xbd70109,0xbd80109,0xbd90109,0xbda0109,0xbdb0109,0xbdc0109,0xbdd0109,0xbde0109, |
|
130 |
0xbdf0109,0xbe00109,0xbe10109,0xbe20109,0xbe30109,0xbe40109,0xbe50109,0xbe60109, |
|
131 |
0xbe70109,0xbe80109,0xbe90109,0xbea0109,0xbeb0109,0xbec0109,0xbed0109, |
|
132 |
}; |
|
133 |
||
134 |
static const TUint32 TheDevanagariIndex[] = |
|
135 |
{ |
|
136 |
0x9010012,0x9020013,0x9030014,0x9050015,0x9060016,0x9070017,0x9080018,0x9090019, |
|
137 |
0x90a001a,0x90b001b,0x90c001d,0x90d001f,0x90e0020,0x90f0021,0x9100022,0x9110023, |
|
138 |
0x9120024,0x9130025,0x9140026,0x9150027,0x9160029,0x917002b,0x918002d,0x919002e, |
|
139 |
0x91a002f,0x91b0030,0x91c0031,0x91d0033,0x91e0034,0x91f0035,0x9200036,0x9210037, |
|
140 |
0x9220039,0x923003b,0x924003c,0x925003d,0x926003e,0x927003f,0x9280040,0x9290041, |
|
141 |
0x92a0042,0x92b0043,0x92c0045,0x92d0046,0x92e0047,0x92f0048,0x930004a,0x931004b, |
|
142 |
0x932004c,0x933004d,0x934004e,0x935004f,0x9360050,0x9370051,0x9380052,0x9390053, |
|
143 |
0x93c0003,0x93d0054,0x93e0055,0x93f0056,0x9400057,0x9410058,0x9420059,0x943005a, |
|
144 |
0x944005b,0x945005e,0x946005f,0x9470060,0x9480061,0x9490062,0x94a0063,0x94b0064, |
|
145 |
0x94c0065,0x94d0066,0x9510004,0x9520005,0x9530006,0x9540007,0x9580028,0x959002a, |
|
146 |
0x95a002c,0x95b0032,0x95c0038,0x95d003a,0x95e0044,0x95f0049,0x960001c,0x961001e, |
|
147 |
0x962005c,0x963005d,0x9640000,0x9650001,0x9660008,0x9670009,0x968000a,0x969000b, |
|
148 |
0x96a000c,0x96b000d,0x96c000e,0x96d000f,0x96e0010,0x96f0011,0x9700002, |
|
149 |
}; |
|
150 |
||
151 |
static const TCollationKeyTable TheDevanagariTable = |
|
152 |
{ TheDevanagariKey, TheDevanagariIndex, 103, 0, 0, 0 }; |
|
153 |
||
154 |
static const TCollationMethod TheDevanagariMethod = |
|
155 |
{ 0, 0, &TheDevanagariTable, 0 }; |
|
156 |
||
157 |
static const TCollationMethod TheDevanagariIgnoreCombiningMethod = |
|
158 |
{ 0, 0, &TheDevanagariTable, TCollationMethod::EIgnoreCombining }; |
|
159 |
||
160 |
static const TUint32 TheSwedishKey[] = |
|
161 |
{ |
|
162 |
0x8f60109,0x8f70109,0x8f80109,0x8f60121,0x8f70121,0x8f80121,0x8dd0109,0x8dd0121, |
|
163 |
0x8c50121,0x8c50109, |
|
164 |
}; |
|
165 |
||
166 |
static const TUint32 TheSwedishIndex[] = |
|
167 |
{ |
|
168 |
0x570008,0x770009, |
|
169 |
}; |
|
170 |
||
171 |
static const TUint16 TheSwedishStringElement[] = |
|
172 |
{ |
|
173 |
0x2,0x61,0x30a,0x2,0x61,0x308,0x2,0x6f, |
|
174 |
0x308,0x2,0x41,0x30a,0x2,0x41,0x308,0x2, |
|
175 |
0x4f,0x308,0x2,0x75,0x308,0x2,0x55,0x308, |
|
176 |
}; |
|
177 |
||
178 |
static const TUint32 TheSwedishStringIndex[] = |
|
179 |
{ |
|
180 |
0xc0004,0x90003,0xf0005,0x150007,0x30001,0x0,0x60002,0x120006, |
|
181 |
}; |
|
182 |
||
183 |
static const TCollationKeyTable TheSwedishTable = |
|
184 |
{ TheSwedishKey, TheSwedishIndex, 2, TheSwedishStringElement, TheSwedishStringIndex, 8 }; |
|
185 |
||
186 |
static const TCollationMethod TheSwedishMethod = |
|
187 |
{ 0, 0, &TheSwedishTable, TCollationMethod::EIgnoreNone }; |
|
188 |
||
189 |
static const TCollationMethod TheIgnoreNoneMethod = |
|
190 |
{ 0, 0, 0, TCollationMethod::EIgnoreNone }; |
|
191 |
||
192 |
void TestPrintCaption(const TDesC& aTestName, const TText16 aStr[], TInt aLen) |
|
193 |
{ |
|
194 |
test.Next(aTestName); |
|
195 |
RDebug::Print(_L("Char seq: ")); |
|
196 |
for(TInt i=0;i<aLen;++i) |
|
197 |
{ |
|
198 |
RDebug::Print(_L("%04X "), aStr[i]); |
|
199 |
} |
|
200 |
RDebug::Print(_L("\nOutput: ")); |
|
201 |
} |
|
202 |
||
203 |
TInt MatchC(const TDesC16& aCandidate, const TDesC16& aSearchTerm, |
|
204 |
const TCollationMethod* aMethod, TInt aLevel) |
|
205 |
{ |
|
206 |
TCollate method(0); |
|
207 |
if (aMethod) |
|
208 |
{ |
|
209 |
TCollate m(*aMethod); |
|
210 |
method = m; |
|
211 |
} |
|
212 |
return method.Match(aCandidate.Ptr(), aCandidate.Length(), |
|
213 |
aSearchTerm.Ptr(), aSearchTerm.Length(), aLevel); |
|
214 |
} |
|
215 |
||
216 |
_LIT(KCand1, "baot"); |
|
217 |
_LIT(KCand2, "ba\x308o\x308t"); |
|
218 |
_LIT(KCand3, "b\xe4\xf6t"); |
|
219 |
_LIT(KSearch1, "BAOT"); |
|
220 |
_LIT(KSearch2, "?AO?"); |
|
221 |
_LIT(KSearch3, "?\xe4o?"); |
|
222 |
_LIT(KSearch4, "*o*"); |
|
223 |
_LIT(KSearch5, "*ao*"); |
|
224 |
_LIT(KSearch6, "*b\x308*"); |
|
225 |
_LIT(KSearch7, "ba\x308*"); |
|
226 |
_LIT(KSearch8, "ba*"); |
|
227 |
||
228 |
void TestMatchC() |
|
229 |
{ |
|
230 |
// MatchC should be working at level 0, let us test that this is so. |
|
231 |
test(0 == KCand1().MatchC(KSearch1)); |
|
232 |
test(0 == KCand1().MatchC(KCand2)); |
|
233 |
test(1 == KCand1().MatchC(KSearch5)); |
|
234 |
test(1 == KCand2().MatchC(KSearch5)); |
|
235 |
test(0 <= KCand1().MatchC(KSearch2)); |
|
236 |
// Test the internals at level 0: It must fail to match Swedish accents |
|
237 |
// with the Swedish collation algorithm. |
|
238 |
test(0 == MatchC(KCand1, KSearch1, &TheIgnoreNoneMethod, 0)); |
|
239 |
test(0 == MatchC(KCand1, KSearch1, &TheSwedishMethod, 0)); |
|
240 |
test(0 == MatchC(KCand2, KSearch1, &TheIgnoreNoneMethod, 0)); |
|
241 |
test(KErrNotFound == MatchC(KCand2, KSearch1, &TheSwedishMethod, 0)); |
|
242 |
test(0 == MatchC(KCand3, KSearch1, &TheIgnoreNoneMethod, 0)); |
|
243 |
test(KErrNotFound == MatchC(KCand3, KSearch1, &TheSwedishMethod, 0)); |
|
244 |
test(0 <= MatchC(KCand1, KSearch2, &TheIgnoreNoneMethod, 0)); |
|
245 |
test(0 <= MatchC(KCand1, KSearch2, &TheSwedishMethod, 0)); |
|
246 |
test(0 <= MatchC(KCand2, KSearch2, &TheIgnoreNoneMethod, 0)); |
|
247 |
test(KErrNotFound == MatchC(KCand2, KSearch2, &TheSwedishMethod, 0)); |
|
248 |
test(0 <= MatchC(KCand3, KSearch2, &TheIgnoreNoneMethod, 0)); |
|
249 |
test(KErrNotFound == MatchC(KCand3, KSearch2, &TheSwedishMethod, 0)); |
|
250 |
test(0 <= MatchC(KCand2, KSearch3, &TheIgnoreNoneMethod, 0)); |
|
251 |
test(KErrNotFound == MatchC(KCand3, KSearch2, &TheSwedishMethod, 0)); |
|
252 |
test(3 == MatchC(KCand2, KSearch4, &TheIgnoreNoneMethod, 0)); |
|
253 |
test(KErrNotFound == MatchC(KCand2, KSearch4, &TheSwedishMethod, 0)); |
|
254 |
test(1 == MatchC(KCand2, KSearch5, &TheIgnoreNoneMethod, 0)); |
|
255 |
test(KErrNotFound == MatchC(KCand2, KSearch5, &TheSwedishMethod, 0)); |
|
256 |
test(0 == MatchC(KCand2, KSearch6, &TheIgnoreNoneMethod, 0)); |
|
257 |
test(0 == MatchC(KCand2, KSearch6, &TheSwedishMethod, 0)); |
|
258 |
test(0 == MatchC(KCand1, KSearch7, &TheIgnoreNoneMethod, 0)); |
|
259 |
test(KErrNotFound == MatchC(KCand1, KSearch7, &TheSwedishMethod, 0)); |
|
260 |
test(0 == MatchC(KCand1, KSearch8, &TheIgnoreNoneMethod, 0)); |
|
261 |
test(0 == MatchC(KCand1, KSearch8, &TheSwedishMethod, 0)); |
|
262 |
test(0 == MatchC(KCand2, KSearch7, &TheIgnoreNoneMethod, 0)); |
|
263 |
test(0 == MatchC(KCand2, KSearch7, &TheSwedishMethod, 0)); |
|
264 |
test(0 == MatchC(KCand2, KSearch8, &TheIgnoreNoneMethod, 0)); |
|
265 |
test(KErrNotFound == MatchC(KCand2, KSearch8, &TheSwedishMethod, 0)); |
|
266 |
test(0 == MatchC(KCand3, KSearch7, &TheIgnoreNoneMethod, 0)); |
|
267 |
test(0 == MatchC(KCand3, KSearch7, &TheSwedishMethod, 0)); |
|
268 |
test(0 == MatchC(KCand3, KSearch8, &TheIgnoreNoneMethod, 0)); |
|
269 |
test(KErrNotFound == MatchC(KCand3, KSearch8, &TheSwedishMethod, 0)); |
|
270 |
_LIT(KCandidate1, "axyz"); |
|
271 |
_LIT(KSearchStr1, "a*z"); |
|
272 |
test(0 == KCandidate1().MatchC(KSearchStr1())); |
|
273 |
_LIT(KCandidate2, "azzz"); |
|
274 |
_LIT(KSearchStr2, "a*z"); |
|
275 |
test(0 == KCandidate2().MatchC(KSearchStr2())); |
|
276 |
||
277 |
// Added tests for INC105311... |
|
278 |
_LIT(KCandJpg1, "jpg_jjg.jpg"); |
|
279 |
_LIT(KCandJpg2, "jpgAjjg.jpg"); |
|
280 |
_LIT(KCandJpg3, "jpg@jjg.jpg"); |
|
281 |
_LIT(KCandJpg4, "hpg&jjg.jpg"); |
|
282 |
_LIT(KCandJpg5, "hpg&jpg.jpg"); |
|
283 |
_LIT(KSearchJpg1, "*jp?"); |
|
284 |
_LIT(KSearchJpg2, "*jpg"); |
|
285 |
_LIT(KSearchJpg3, "*jpg*"); |
|
286 |
_LIT(KSearchJpg4, "*jpg*jpg"); |
|
287 |
test(8 == KCandJpg1().MatchC(KSearchJpg1)); |
|
288 |
test(8 == KCandJpg2().MatchC(KSearchJpg1)); |
|
289 |
test(8 == KCandJpg3().MatchC(KSearchJpg1)); |
|
290 |
test(8 == KCandJpg4().MatchC(KSearchJpg1)); |
|
291 |
test(8 == KCandJpg5().MatchC(KSearchJpg1)); |
|
292 |
test(8 == KCandJpg1().MatchC(KSearchJpg2)); |
|
293 |
test(8 == KCandJpg2().MatchC(KSearchJpg2)); |
|
294 |
test(8 == KCandJpg3().MatchC(KSearchJpg2)); |
|
295 |
test(8 == KCandJpg4().MatchC(KSearchJpg2)); |
|
296 |
test(8 == KCandJpg5().MatchC(KSearchJpg2)); |
|
297 |
test(0 == KCandJpg1().MatchC(KSearchJpg3)); |
|
298 |
test(0 == KCandJpg2().MatchC(KSearchJpg3)); |
|
299 |
test(0 == KCandJpg3().MatchC(KSearchJpg3)); |
|
300 |
test(8 == KCandJpg4().MatchC(KSearchJpg3)); |
|
301 |
test(4 == KCandJpg5().MatchC(KSearchJpg3)); |
|
302 |
test(0 == KCandJpg1().MatchC(KSearchJpg4)); |
|
303 |
test(0 == KCandJpg2().MatchC(KSearchJpg4)); |
|
304 |
test(0 == KCandJpg3().MatchC(KSearchJpg4)); |
|
305 |
test(KErrNotFound == KCandJpg4().MatchC(KSearchJpg4)); |
|
306 |
test(4 == KCandJpg5().MatchC(KSearchJpg4)); |
|
307 |
_LIT(KCand4, "abcxaxaxa"); |
|
308 |
_LIT(KSearch9, "*xaxa"); |
|
309 |
test(5 == KCand4().MatchC(KSearch9)); |
|
310 |
_LIT(KCand6, "abxa"); |
|
311 |
_LIT(KSearch10, "*x?"); |
|
312 |
test(2 == KCand6().MatchC(KSearch10)); |
|
313 |
_LIT(KCand7, "xab"); |
|
314 |
_LIT(KSearch11, "x?"); |
|
315 |
test(KErrNotFound == KCand7().MatchC(KSearch11)); |
|
316 |
_LIT(KCand8, "xa"); |
|
317 |
_LIT(KSearch12, "x?"); |
|
318 |
test(0 == KCand8().MatchC(KSearch12)); |
|
319 |
_LIT(KCand9, "xaxa"); |
|
320 |
_LIT(KSearch13, "*x?"); |
|
321 |
test(2 == KCand9().MatchC(KSearch13)); |
|
322 |
_LIT(KCand10, "abjpgcjig.jpg"); |
|
323 |
_LIT(KSearch14, "*jp?"); |
|
324 |
test(10 == KCand10().MatchC(KSearch14)); |
|
325 |
_LIT(KCand11, "abjpg_jig.jpg"); |
|
326 |
_LIT(KSearch15, "*jp?"); |
|
327 |
test(10 == KCand11().MatchC(KSearch15)); |
|
328 |
_LIT(KCand12, "jpg"); |
|
329 |
_LIT(KSearch16, "*jp?"); |
|
330 |
test(0 == KCand12().MatchC(KSearch16)); |
|
331 |
_LIT(KCand13, "abjpgig.jpg"); |
|
332 |
_LIT(KSearch17, "*jp?"); |
|
333 |
test(8 == KCand13().MatchC(KSearch17)); |
|
334 |
_LIT(KCand14, "abjcgig.jpg"); |
|
335 |
_LIT(KSearch18, "jp?"); |
|
336 |
test(KErrNotFound == KCand14().MatchC(KSearch18)); |
|
337 |
_LIT(KCand15, "xax\xE2"); |
|
338 |
_LIT(KSearch19, "*xa\x302"); |
|
339 |
test(2 == KCand15().MatchC(KSearch19)); |
|
340 |
_LIT(KCand5, "blahblahblah\xE2"); |
|
341 |
_LIT(KSearch20, "*a\x302"); |
|
342 |
test(12 == KCand5().MatchC(KSearch20)); |
|
343 |
_LIT(KCand16, "bl\xE2hblahblaha\x302"); |
|
344 |
_LIT(KSearch21, "*a\x302*\xE2"); |
|
345 |
test(2 == KCand16().MatchC(KSearch21)); |
|
346 |
_LIT(KCand17, "abcxaxaxa"); |
|
347 |
_LIT(KSearch22, "*x?x?"); |
|
348 |
test(5 == KCand17().MatchC(KSearch22)); |
|
349 |
} |
|
350 |
||
351 |
/** |
|
352 |
@SYMTestCaseID SYSLIB-EUSER-CT-1759 |
|
353 |
@SYMTestCaseDesc Various tests for the new TDesC16::MatchC() method. Testing that the new method works with |
|
354 |
different wild card characters and different escape characters. |
|
355 |
@SYMTestPriority High |
|
356 |
@SYMTestActions Test for TDesC16::MatchC(const TDesC16 &aPattern, TInt aMaxLevel, TInt aWildChar, TInt aWildSequenceChar, TInt aEscapeChar, const TCollationMethod* aCollationMethod = NULL). |
|
357 |
@SYMTestExpectedResults The test must not fail. |
|
358 |
@SYMREQ REQ5907 |
|
359 |
*/ |
|
360 |
void TestMatchC2() |
|
361 |
{ |
|
362 |
_LIT(KCandidate1, "ab/cRRRdef__grt"); |
|
363 |
_LIT(KSearchStr1, "ab//c%def/_/_grt"); |
|
364 |
TInt rc = KCandidate1().MatchC(KSearchStr1(), '_', '%', '/', 0); |
|
365 |
test(rc == 0); |
|
366 |
_LIT(KCandidate2, "_*"); |
|
367 |
_LIT(KSearchStr2, "/_/*"); |
|
368 |
rc = KCandidate2().MatchC(KSearchStr2(), '_', '*', '/', 0); |
|
369 |
test(rc == 0); |
|
370 |
_LIT(KCandidate3, "aa"); |
|
371 |
_LIT(KSearchStr3, "aaaa"); |
|
372 |
rc = KCandidate3().MatchC(KSearchStr3(), '_', '%', 'a', 0); |
|
373 |
test(rc == 0); |
|
374 |
_LIT(KCandidate4, "\\4%3=1"); |
|
375 |
_LIT(KSearchStr4, "\\\\4_3%"); |
|
376 |
rc = KCandidate4().MatchC(KSearchStr4(), '_', '%', '\\', 0); |
|
377 |
test(rc == 0); |
|
378 |
_LIT(KCandidate5, "abcd&efgh"); |
|
379 |
_LIT(KSearchStr5, "----!&efgh"); |
|
380 |
rc = KCandidate5().MatchC(KSearchStr5(), '-', '&', '!', 0); |
|
381 |
test(rc == 0); |
|
382 |
_LIT(KCandidate6, "abc#1234:5678#xyz"); |
|
383 |
_LIT(KSearchStr6, "#!#1234!:56::!##z"); |
|
384 |
rc = KCandidate6().MatchC(KSearchStr6(), ':', '#', '!', 0); |
|
385 |
test(rc == 3); |
|
386 |
_LIT(KCandidate7, "abc#1234:5678#zzz"); |
|
387 |
_LIT(KSearchStr7, "#!#1234!:56::!##z"); |
|
388 |
rc = KCandidate7().MatchC(KSearchStr7(), ':', '#', '!', 0); |
|
389 |
test(rc == 3); |
|
390 |
_LIT(KCandidate8, "abc"); |
|
391 |
_LIT(KSearchStr8, "a_c"); |
|
392 |
rc = KCandidate8().MatchC(KSearchStr8(), '_', '%', '7', 0); |
|
393 |
test(rc == 0); |
|
394 |
_LIT(KCandidate9, "abc"); |
|
395 |
_LIT(KSearchStr9, "A_C"); |
|
396 |
rc = KCandidate9().MatchC(KSearchStr9(), '_', '%', '7', 0); |
|
397 |
test(rc == 0); |
|
398 |
_LIT(KCandidate10, "a_c"); |
|
399 |
_LIT(KSearchStr10, "a7_c"); |
|
400 |
rc = KCandidate10().MatchC(KSearchStr10(), '_', '%', '7', 0); |
|
401 |
test(rc == 0); |
|
402 |
_LIT(KCandidate11, "a_c"); |
|
403 |
_LIT(KSearchStr11, "A7_C"); |
|
404 |
rc = KCandidate11().MatchC(KSearchStr11(), '_', '%', '7', 0); |
|
405 |
test(rc == 0); |
|
406 |
_LIT(KCandidate12, "abc"); |
|
407 |
_LIT(KSearchStr12, "a7_c"); |
|
408 |
rc = KCandidate12().MatchC(KSearchStr12(), '_', '%', '7', 0); |
|
409 |
test(rc == KErrNotFound); |
|
410 |
_LIT(KCandidate13, "abc"); |
|
411 |
_LIT(KSearchStr13, "A7_C"); |
|
412 |
rc = KCandidate13().MatchC(KSearchStr13(), '_', '%', '7', 0); |
|
413 |
test(rc == KErrNotFound); |
|
414 |
_LIT(KCandidate14, "a7Xc"); |
|
415 |
_LIT(KSearchStr14, "a7_c"); |
|
416 |
rc = KCandidate14().MatchC(KSearchStr14(), '_', '%', '7', 0); |
|
417 |
test(rc == KErrNotFound); |
|
418 |
_LIT(KCandidate15, "a7Xc"); |
|
419 |
_LIT(KSearchStr15, "A7_C"); |
|
420 |
rc = KCandidate15().MatchC(KSearchStr15(), '_', '%', '7', 0); |
|
421 |
test(rc == KErrNotFound); |
|
422 |
_LIT(KCandidate16, "abcde"); |
|
423 |
_LIT(KSearchStr16, "a%e"); |
|
424 |
rc = KCandidate16().MatchC(KSearchStr16(), '_', '%', '7', 0); |
|
425 |
test(rc == 0); |
|
426 |
_LIT(KCandidate17, "abcde"); |
|
427 |
_LIT(KSearchStr17, "A%E"); |
|
428 |
rc = KCandidate17().MatchC(KSearchStr17(), '_', '%', '7', 0); |
|
429 |
test(rc == 0); |
|
430 |
_LIT(KCandidate18, "abcde"); |
|
431 |
_LIT(KSearchStr18, "a7%e"); |
|
432 |
rc = KCandidate18().MatchC(KSearchStr18(), '_', '%', '7', 0); |
|
433 |
test(rc == KErrNotFound); |
|
434 |
_LIT(KCandidate19, "abcde"); |
|
435 |
_LIT(KSearchStr19, "A7%E"); |
|
436 |
rc = KCandidate19().MatchC(KSearchStr19(), '_', '%', '7', 0); |
|
437 |
test(rc == KErrNotFound); |
|
438 |
_LIT(KCandidate20, "a7cde"); |
|
439 |
_LIT(KSearchStr20, "a7%e"); |
|
440 |
rc = KCandidate20().MatchC(KSearchStr20(), '_', '%', '7', 0); |
|
441 |
test(rc == KErrNotFound); |
|
442 |
_LIT(KCandidate21, "a7cde"); |
|
443 |
_LIT(KSearchStr21, "A7%E"); |
|
444 |
rc = KCandidate21().MatchC(KSearchStr21(), '_', '%', '7', 0); |
|
445 |
test(rc == KErrNotFound); |
|
446 |
_LIT(KCandidate22, "a7cde"); |
|
447 |
_LIT(KSearchStr22, "a77%e"); |
|
448 |
rc = KCandidate22().MatchC(KSearchStr22(), '_', '%', '7', 0); |
|
449 |
test(rc == 0); |
|
450 |
_LIT(KCandidate23, "a7cde"); |
|
451 |
_LIT(KSearchStr23, "A77%E"); |
|
452 |
rc = KCandidate23().MatchC(KSearchStr23(), '_', '%', '7', 0); |
|
453 |
test(rc == 0); |
|
454 |
_LIT(KCandidate24, "abc7"); |
|
455 |
_LIT(KSearchStr24, "a%77"); |
|
456 |
rc = KCandidate24().MatchC(KSearchStr24(), '_', '%', '7', 0); |
|
457 |
test(rc == 0); |
|
458 |
_LIT(KCandidate25, "abc7"); |
|
459 |
_LIT(KSearchStr25, "A%77"); |
|
460 |
rc = KCandidate25().MatchC(KSearchStr25(), '_', '%', '7', 0); |
|
461 |
test(rc == 0); |
|
462 |
_LIT(KCandidate26, "abc_"); |
|
463 |
_LIT(KSearchStr26, "a%7_"); |
|
464 |
rc = KCandidate26().MatchC(KSearchStr26(), '_', '%', '7', 0); |
|
465 |
test(rc == 0); |
|
466 |
_LIT(KCandidate27, "abc_"); |
|
467 |
_LIT(KSearchStr27, "A%7_"); |
|
468 |
rc = KCandidate27().MatchC(KSearchStr27(), '_', '%', '7', 0); |
|
469 |
test(rc == 0); |
|
470 |
_LIT(KCandidate28, "abc7"); |
|
471 |
_LIT(KSearchStr28, "a%7_"); |
|
472 |
rc = KCandidate28().MatchC(KSearchStr28(), '_', '%', '7', 0); |
|
473 |
test(rc == KErrNotFound); |
|
474 |
_LIT(KCandidate29, "abc7"); |
|
475 |
_LIT(KSearchStr29, "A%7_"); |
|
476 |
rc = KCandidate29().MatchC(KSearchStr29(), '_', '%', '7', 0); |
|
477 |
test(rc == KErrNotFound); |
|
478 |
_LIT(KCandidate30, "ba\x308o\x308t"); |
|
479 |
_LIT(KSearchStr30, "-b\x308-"); |
|
480 |
rc = KCandidate30().MatchC(KSearchStr30(), '%', '-', 0, 0); |
|
481 |
test(rc == 0); |
|
482 |
rc = KCandidate30().MatchC(KSearchStr30(), '%', '-', 0, 0, &TheSwedishMethod); |
|
483 |
test(rc == 0); |
|
484 |
_LIT(KSearchStr31, "ba\x308*"); |
|
485 |
rc = KCandidate30().MatchC(KSearchStr31(), '%', '*', 0, 0, &TheSwedishMethod); |
|
486 |
test(rc == 0); |
|
487 |
} |
|
488 |
||
489 |
void DoTestCanonicalDecompositionIterator(const TDesC& aTest, const TDesC& aCanonical) |
|
490 |
{ |
|
491 |
TUTF32Iterator i(aTest.Ptr(), aTest.Ptr() + aTest.Length()); |
|
492 |
TCanonicalDecompositionIterator cci; |
|
493 |
cci.Set(i); |
|
494 |
TInt index = 0; |
|
495 |
while (!cci.AtEnd()) |
|
496 |
{ |
|
497 |
test(index != aCanonical.Length()); |
|
498 |
TChar ch1 = aCanonical[index]; |
|
499 |
TChar ch2 = cci.Current(); |
|
500 |
test(ch1 == ch2); |
|
501 |
++index; |
|
502 |
cci.Next(); |
|
503 |
} |
|
504 |
test(index == aCanonical.Length()); |
|
505 |
} |
|
506 |
||
507 |
// exciting combining characters include: |
|
508 |
// U+0327 cedilla, class = 202 |
|
509 |
// U+031B horn, class = 216 |
|
510 |
// U+0316 grave below, class = 220 |
|
511 |
// U+0300 grave above, class = 230 |
|
512 |
// U+031A left angle above, class = 232 |
|
513 |
// U+0360 double tilde, class = 234 |
|
514 |
// U+0345 ypogegrameni, class = 240 |
|
515 |
||
516 |
_LIT(KAllOnce, "\x327\x31b\x316\x300\x31a\x360\x345xyz"); |
|
517 |
_LIT(KBackwards, "\x345\x360\x31a\x300\x316\x31b\x327xyz"); |
|
518 |
_LIT(KRandom, "\x300\x316\x31b\x327\x31a\x345\x360xyz"); |
|
519 |
_LIT(KAllOnceThenAcute, "\x327\x31b\x316\x300\x301\x31a\x360\x345"); |
|
520 |
_LIT(KBackwardsThenAcute, "\x345\x360\x31a\x300\x301\x316\x31b\x327"); |
|
521 |
_LIT(KRandomThenAcute, "\x300\x316\x31b\x327\x31a\x301\x345\x360"); |
|
522 |
_LIT(KAllSame, "\x300\x301\x302\x303\x304\x306\x307\x308\x30b\x30c\x30f"); |
|
523 |
_LIT(KLotsSameCanonical, "\x327\x31b\x316\x300\x301\x302\x303\x304\x306\x307\x308\x30b\x30c\x30f\x31a\x360\x345xyz"); |
|
524 |
_LIT(KLotsSameNotCanonical, "\x31b\x300\x345\x301\x302\x316\x303\x304\x31a\x306\x307\x327\x308\x30b\x30c\x30f\x360xyz"); |
|
525 |
||
526 |
/** |
|
527 |
@SYMTestCaseID SYSLIB-UNICODE-CT-0106 |
|
528 |
@SYMTestCaseDesc TCanonicalDecompositionIterator test |
|
529 |
@SYMTestPriority High |
|
530 |
@SYMTestActions TCanonicalDecompositionIterator test |
|
531 |
@SYMTestExpectedResults The test must not fail. |
|
532 |
@SYMPREQ814 Optimise folded string comparisons. |
|
533 |
*/ |
|
534 |
void TestCanonicalDecompositionIterator() |
|
535 |
{ |
|
536 |
DoTestCanonicalDecompositionIterator(KAllOnce, KAllOnce); |
|
537 |
DoTestCanonicalDecompositionIterator(KBackwards, KAllOnce); |
|
538 |
DoTestCanonicalDecompositionIterator(KRandom, KAllOnce); |
|
539 |
DoTestCanonicalDecompositionIterator(KBackwardsThenAcute, KAllOnceThenAcute); |
|
540 |
DoTestCanonicalDecompositionIterator(KRandomThenAcute, KAllOnceThenAcute); |
|
541 |
DoTestCanonicalDecompositionIterator(KAllSame, KAllSame); |
|
542 |
DoTestCanonicalDecompositionIterator(KLotsSameCanonical, KLotsSameCanonical); |
|
543 |
DoTestCanonicalDecompositionIterator(KLotsSameNotCanonical, KLotsSameCanonical); |
|
544 |
} |
|
545 |
||
546 |
/** |
|
547 |
@SYMTestCaseID SYSLIB-UNICODE-CT-3337 |
|
548 |
@SYMTestCaseDesc Test latest MatchC override that has the advanced TCollationMethod flag input |
|
549 |
@SYMTestPriority High |
|
550 |
@SYMTestActions Test matching of combined characters with simple character. |
|
551 |
Note- this action only applies to certain classes of combining characters |
|
552 |
@SYMTestExpectedResults Old MatchC character against character + combining character |
|
553 |
will not match but new MatchC with same characters and flag set will match. |
|
554 |
@SYMINC092513: RR S60: Variant testing: Searching does not work properly in contacts |
|
555 |
*/ |
|
556 |
void TestDisableCombiningCharacterCheckFlag(const TDesC16 &aLeft, const TDesC16 &aRight) |
|
557 |
{ |
|
558 |
//Without flag, characters combine to make new character not matched by search |
|
559 |
test(KErrNotFound ==aLeft.MatchC(aRight,&TheDevanagariMethod)); |
|
560 |
//With flag, combining character check is disabled so that search is matched |
|
561 |
test(KErrNone ==aLeft.MatchC(aRight,&TheDevanagariIgnoreCombiningMethod)); |
|
562 |
} |
|
563 |
void TestDisableCombiningCharacterCheck() |
|
564 |
{ |
|
565 |
test.Next(_L("INC092513")); |
|
566 |
TBuf<2> search, target; |
|
567 |
//All Devanagari dependant vowels are in the following range |
|
568 |
for(TInt dependantVowel=0x93e; dependantVowel<=0x94c; dependantVowel++) |
|
569 |
{ |
|
570 |
//Most of the Devanagari consonants are in the following range |
|
571 |
for(TInt consonant=0x915; consonant<=0x939; consonant++) |
|
572 |
{ |
|
573 |
target.Format(_L("%c%c"),consonant,dependantVowel); |
|
574 |
search.Format(_L("%c*"),consonant); |
|
575 |
TestDisableCombiningCharacterCheckFlag(target, search); |
|
576 |
} |
|
577 |
} |
|
578 |
//Test same situation but where consonants decompose to consonant + dependant vowel |
|
579 |
TestDisableCombiningCharacterCheckFlag(_L("\x929"), _L("\x928*")); |
|
580 |
TestDisableCombiningCharacterCheckFlag(_L("\x931"), _L("\x930*")); |
|
581 |
TestDisableCombiningCharacterCheckFlag(_L("\x934"), _L("\x933*")); |
|
582 |
TestDisableCombiningCharacterCheckFlag(_L("\x958"), _L("\x915*")); |
|
583 |
TestDisableCombiningCharacterCheckFlag(_L("\x959"), _L("\x916*")); |
|
584 |
TestDisableCombiningCharacterCheckFlag(_L("\x95a"), _L("\x917*")); |
|
585 |
TestDisableCombiningCharacterCheckFlag(_L("\x95b"), _L("\x91c*")); |
|
586 |
TestDisableCombiningCharacterCheckFlag(_L("\x95c"), _L("\x921*")); |
|
587 |
TestDisableCombiningCharacterCheckFlag(_L("\x95d"), _L("\x922*")); |
|
588 |
TestDisableCombiningCharacterCheckFlag(_L("\x95e"), _L("\x92b*")); |
|
589 |
TestDisableCombiningCharacterCheckFlag(_L("\x95f"), _L("\x92f*")); |
|
590 |
} |
|
591 |
||
592 |
_LIT(KHelloT, "Hello"); |
|
593 |
_LIT(KLatin1AccentsC, "\xE0\xD2p\xE2\xEB\xED\xF1\xC7"); |
|
594 |
_LIT(KLatin1AccentsD, "a\x300O\x300pa\x302\x65\x308i\x301n\x303\x43\x327"); |
|
595 |
// four alpha + psili + varia + ypogegrameni |
|
596 |
_LIT(KGreekAccentsC, "\x1f82\x1f82\x1f82\x1f82"); |
|
597 |
// decomposed in four different ways |
|
598 |
_LIT(KGreekAccentsS, "\x1f82\x1f02\x345\x1f00\x300\x345\x3b1\x313\x300\x345"); |
|
599 |
// completely decomposed |
|
600 |
_LIT(KGreekAccentsD, "\x3b1\x313\x300\x345\x3b1\x313\x300\x345\x3b1\x313\x300\x345\x3b1\x313\x300\x345"); |
|
601 |
// full-width variants |
|
602 |
_LIT(KFullWidth, "\xFF21\xFF42\xFF43"); |
|
603 |
// surrogate pair, unpaired low surrogate, unpaired high surrogate, unpaired |
|
604 |
// high surrogate at end of string |
|
605 |
_LIT(KSurrogates, "\xD965\xDEF0\xDF12\xDB10\xDA4E"); |
|
606 |
_LIT(KSurrogatesTest, "\xD965\xDEF0"); |
|
607 |
||
608 |
void TestIteratorOutput(TDecompositionIterator& aIt, const TDesC& aCheck) |
|
609 |
{ |
|
610 |
TBool unpairedHighSurrogate = EFalse; |
|
611 |
for(TInt i = 0; i != aCheck.Length(); aIt.Next()) |
|
612 |
{ |
|
613 |
if (aIt.AtEnd()) |
|
614 |
{ |
|
615 |
test(0); |
|
616 |
return; |
|
617 |
} |
|
618 |
TInt c = aIt.Current(); |
|
619 |
// test that we are not looking at an unpaired low surrogate that |
|
620 |
// follows an unpaired high surrogate: this is not possible. |
|
621 |
test((c & 0xFC00) != 0xDC00 || !unpairedHighSurrogate); |
|
622 |
unpairedHighSurrogate = (c & 0xFC00) == 0xD800? (TBool)ETrue : (TBool)EFalse; |
|
623 |
if (c < 0x10000) |
|
624 |
{ |
|
625 |
test(c == aCheck[i]); |
|
626 |
++i; |
|
627 |
} |
|
628 |
else |
|
629 |
{ |
|
630 |
TInt sp = ((aCheck[i] - 0xD7F7) << 10) + aCheck[i + 1]; |
|
631 |
test(c == sp); |
|
632 |
i += 2; |
|
633 |
} |
|
634 |
} |
|
635 |
test(aIt.AtEnd()); |
|
636 |
} |
|
637 |
||
638 |
/** |
|
639 |
@SYMTestCaseID SYSLIB-UNICODE-CT-0097 |
|
640 |
@SYMTestCaseDesc TUTF32Iterator functionality tested on 2 character sequences: |
|
641 |
(1) single character |
|
642 |
(2) surrogate pair |
|
643 |
@SYMTestPriority High |
|
644 |
@SYMTestActions TUTF32Iterator test. |
|
645 |
@SYMTestExpectedResults The test must not fail. |
|
646 |
@SYMPREQ814 Optimise folded string comparisons. |
|
647 |
*/ |
|
648 |
void TestUTF32Iterator() |
|
649 |
{ |
|
650 |
//Single character |
|
651 |
const TText16 KStr[] = {0x01D5}; |
|
652 |
::TestPrintCaption(_L("TUTF32Iterator"), KStr, ARRAY_SIZE(KStr)); |
|
653 |
TUTF32Iterator it(KStr, KStr + ARRAY_SIZE(KStr)); |
|
654 |
TInt itCount = 0; |
|
655 |
for(;!it.AtEnd();++itCount, it.Next()) |
|
656 |
{ |
|
657 |
TChar ch = it.Current(); |
|
658 |
test(ch == static_cast <TUint> (KStr[0])); |
|
659 |
RDebug::Print(_L("%04X "), (TUint)ch); |
|
660 |
} |
|
661 |
test(itCount == 1); |
|
662 |
RDebug::Print(_L("\n")); |
|
663 |
||
664 |
//Surrogate pair |
|
665 |
::TestPrintCaption(_L("TUTF32Iterator-surrogates"), KSurrogatesTest().Ptr(), KSurrogatesTest().Length()); |
|
666 |
it = TUTF32Iterator(KSurrogatesTest().Ptr(), KSurrogatesTest().Ptr() + KSurrogatesTest().Length()); |
|
667 |
for(itCount=0;!it.AtEnd();++itCount, it.Next()) |
|
668 |
{ |
|
669 |
TChar ch = it.Current(); |
|
670 |
test(ch == 0x696F0); |
|
671 |
RDebug::Print(_L("%06X "), (TUint)ch); |
|
672 |
} |
|
673 |
test(itCount == 1); |
|
674 |
RDebug::Print(_L("\n")); |
|
675 |
||
676 |
// surrogate 0x10000 |
|
677 |
_LIT( KSurrogatesTest2, "\xd800\xdc00" ); |
|
678 |
::TestPrintCaption(_L("TUTF32Iterator-surrogates2"), KSurrogatesTest2().Ptr(), KSurrogatesTest2().Length()); |
|
679 |
it = TUTF32Iterator(KSurrogatesTest2().Ptr(), KSurrogatesTest2().Ptr() + KSurrogatesTest2().Length()); |
|
680 |
for(itCount=0;!it.AtEnd();++itCount, it.Next()) |
|
681 |
{ |
|
682 |
TChar ch = it.Current(); |
|
683 |
test(ch == 0x10000); |
|
684 |
RDebug::Print(_L("%06X "), (TUint)ch); |
|
685 |
} |
|
686 |
test(itCount == 1); |
|
687 |
RDebug::Print(_L("\n")); |
|
688 |
||
689 |
// surrogate 0x20000 |
|
690 |
_LIT( KSurrogatesTest3, "\xd840\xdc00" ); |
|
691 |
::TestPrintCaption(_L("TUTF32Iterator-surrogates3"), KSurrogatesTest3().Ptr(), KSurrogatesTest3().Length()); |
|
692 |
it = TUTF32Iterator(KSurrogatesTest3().Ptr(), KSurrogatesTest3().Ptr() + KSurrogatesTest3().Length()); |
|
693 |
for(itCount=0;!it.AtEnd();++itCount, it.Next()) |
|
694 |
{ |
|
695 |
TChar ch = it.Current(); |
|
696 |
test(ch == 0x20000); |
|
697 |
RDebug::Print(_L("%06X "), (TUint)ch); |
|
698 |
} |
|
699 |
test(itCount == 1); |
|
700 |
RDebug::Print(_L("\n")); |
|
701 |
||
702 |
// surrogate 0x2ffff |
|
703 |
_LIT( KSurrogatesTest4, "\xD87F\xDFFF" ); |
|
704 |
::TestPrintCaption(_L("TUTF32Iterator-surrogates4"), KSurrogatesTest4().Ptr(), KSurrogatesTest4().Length()); |
|
705 |
it = TUTF32Iterator(KSurrogatesTest4().Ptr(), KSurrogatesTest4().Ptr() + KSurrogatesTest4().Length()); |
|
706 |
for(itCount=0;!it.AtEnd();++itCount, it.Next()) |
|
707 |
{ |
|
708 |
TChar ch = it.Current(); |
|
709 |
test(ch == 0x2ffff); |
|
710 |
RDebug::Print(_L("%06X "), (TUint)ch); |
|
711 |
} |
|
712 |
//test(itCount == 1); |
|
713 |
RDebug::Print(_L("\n")); |
|
714 |
||
715 |
// surrogate 0xd800 |
|
716 |
_LIT( KSurrogatesTest5, "\xD800" ); |
|
717 |
::TestPrintCaption(_L("TUTF32Iterator-surrogates5"), KSurrogatesTest5().Ptr(), KSurrogatesTest5().Length()); |
|
718 |
it = TUTF32Iterator(KSurrogatesTest5().Ptr(), KSurrogatesTest5().Ptr() + KSurrogatesTest5().Length()); |
|
719 |
for(itCount=0;!it.AtEnd();++itCount, it.Next()) |
|
720 |
{ |
|
721 |
TChar ch = it.Current(); |
|
722 |
RDebug::Print(_L("%06X "), (TUint)ch); |
|
723 |
} |
|
724 |
test(itCount == 0); |
|
725 |
RDebug::Print(_L("\n")); |
|
726 |
||
727 |
// surrogate 0xdc00 |
|
728 |
_LIT( KSurrogatesTest6, "\xDc00" ); |
|
729 |
::TestPrintCaption(_L("TUTF32Iterator-surrogates6"), KSurrogatesTest6().Ptr(), KSurrogatesTest6().Length()); |
|
730 |
it = TUTF32Iterator(KSurrogatesTest6().Ptr(), KSurrogatesTest6().Ptr() + KSurrogatesTest6().Length()); |
|
731 |
for(itCount=0;!it.AtEnd();++itCount, it.Next()) |
|
732 |
{ |
|
733 |
TChar ch = it.Current(); |
|
734 |
RDebug::Print(_L("%06X "), (TUint)ch); |
|
735 |
} |
|
736 |
test(itCount == 0); |
|
737 |
RDebug::Print(_L("\n")); |
|
738 |
||
739 |
// surrogate 0xdfff |
|
740 |
_LIT( KSurrogatesTest7, "\xDfff" ); |
|
741 |
::TestPrintCaption(_L("TUTF32Iterator-surrogates7"), KSurrogatesTest7().Ptr(), KSurrogatesTest7().Length()); |
|
742 |
it = TUTF32Iterator(KSurrogatesTest7().Ptr(), KSurrogatesTest7().Ptr() + KSurrogatesTest7().Length()); |
|
743 |
for(itCount=0;!it.AtEnd();++itCount, it.Next()) |
|
744 |
{ |
|
745 |
TChar ch = it.Current(); |
|
746 |
RDebug::Print(_L("%06X "), (TUint)ch); |
|
747 |
} |
|
748 |
test(itCount == 0); |
|
749 |
RDebug::Print(_L("\n")); |
|
750 |
} |
|
751 |
||
752 |
/** |
|
753 |
@SYMTestCaseID SYSLIB-UNICODE-CT-0098 |
|
754 |
@SYMTestCaseDesc TFoldedDecompIterator functionality tested on 2 character sequences. |
|
755 |
@SYMTestPriority High |
|
756 |
@SYMTestActions TFoldedDecompIterator test. |
|
757 |
@SYMTestExpectedResults The test must not fail. |
|
758 |
@SYMPREQ814 Optimise folded string comparisons. |
|
759 |
*/ |
|
760 |
void TestFoldedDecompIterator() |
|
761 |
{ |
|
762 |
//Character sequence 1: |
|
763 |
//(1) DEVANAGARI LETTER FA - 0x095E |
|
764 |
//(2) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5 |
|
765 |
//Decompositions: |
|
766 |
//(1) 0x095E decomposed to: 0x092B 0x093C |
|
767 |
//(2) 0x01D5 decomposed to: 0x00DC 0x0304 |
|
768 |
// 0x00DC decomposed to: 0x0055 0x0308 |
|
769 |
// 0x0055 decomposed to: 0x0075 |
|
770 |
const TText16 KStr[] = {0x095E, 0x01D5}; |
|
771 |
const TText16 KStrOut[] = {0x092B, 0x093C, 0x0075, 0x0308, 0x0304}; |
|
772 |
::TestPrintCaption(_L("TFoldedDecompIterator-1"), KStr, ARRAY_SIZE(KStr)); |
|
773 |
TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); |
|
774 |
TFoldedDecompIterator it(itSrc); |
|
775 |
TInt itCount = 0; |
|
776 |
for(;!it.AtEnd();++itCount, it.Next()) |
|
777 |
{ |
|
778 |
if(!it.IsInFoldedSequence()) |
|
779 |
{ |
|
780 |
it.EnterFoldedSequence(); |
|
781 |
} |
|
782 |
TChar ch = it.Current(); |
|
783 |
test(ch == static_cast <TUint> (KStrOut[itCount])); |
|
784 |
RDebug::Print(_L("%04X "), (TUint)ch); |
|
785 |
} |
|
786 |
test(itCount == ARRAY_SIZE(KStrOut)); |
|
787 |
RDebug::Print(_L("\n")); |
|
788 |
||
789 |
//Character sequence 2: |
|
790 |
//(1) GREEK CAPITAL LETTER BETA - 0x0392 |
|
791 |
//(2) COMBINING GRAVE ACCENT - 0x0300 |
|
792 |
//(3) COMBINING GRAVE ACCENT BELOW - 0x0316 |
|
793 |
//(4) GREEK CAPITAL LETTER GAMMA - 0x0393 |
|
794 |
//(5) HEBREW POINT TSERE - 0x05B5 |
|
795 |
//(6) TIBETAN MARK HALANTA - 0x0F84 |
|
796 |
//Decompositions: |
|
797 |
//(1) 0x0392 decomposed to: 0x03B2 |
|
798 |
//(2) 0x0300 decomposed to: 0x0300 |
|
799 |
//(3) 0x0316 decomposed to: 0x0316 |
|
800 |
//(4) 0x0393 decomposed to: 0x03B3 |
|
801 |
//(5) 0x05B5 decomposed to: 0x05B5 |
|
802 |
//(6) 0x0F84 decomposed to: 0x0F84 |
|
803 |
const TText16 KStr2[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0x0F84}; |
|
804 |
const TText16 KStrOut2[] = {0x03B2, 0x0300, 0x0316, 0x03B3, 0x05B5, 0x0F84}; |
|
805 |
::TestPrintCaption(_L("TFoldedDecompIterator-2"), KStr2, ARRAY_SIZE(KStr2)); |
|
806 |
itSrc = TUTF32Iterator(KStr2, KStr2 + ARRAY_SIZE(KStr2)); |
|
807 |
it = TFoldedDecompIterator(itSrc); |
|
808 |
for(itCount=0;!it.AtEnd();++itCount, it.Next()) |
|
809 |
{ |
|
810 |
if(!it.IsInFoldedSequence()) |
|
811 |
{ |
|
812 |
it.EnterFoldedSequence(); |
|
813 |
} |
|
814 |
TChar ch = it.Current(); |
|
815 |
test(ch == static_cast <TUint> (KStrOut2[itCount])); |
|
816 |
RDebug::Print(_L("%04X "), (TUint)ch); |
|
817 |
} |
|
818 |
test(itCount == ARRAY_SIZE(KStrOut2)); |
|
819 |
RDebug::Print(_L("\n")); |
|
820 |
||
821 |
//Character sequence 3: |
|
822 |
//(1) MUSICAL SYMBOL EIGHTH NOTE - 0x1D161 (D834, DD61) |
|
823 |
//Decompositions: |
|
824 |
//(1) 0x1D161 decomposed to: 0x1D15F 0x1D16F |
|
825 |
// 0x1D15F decomposed to: 0x1D158 0x1D165 |
|
826 |
const TText16 KStr3[] = {0xD834, 0xDD61}; |
|
827 |
const TUint32 KStrOut3[] = {0x1D158, 0x1D165, 0x1D16F}; |
|
828 |
::TestPrintCaption(_L("TFoldedDecompIterator-3"), KStr3, ARRAY_SIZE(KStr3)); |
|
829 |
itSrc = TUTF32Iterator(KStr3, KStr3 + ARRAY_SIZE(KStr3)); |
|
830 |
it = TFoldedDecompIterator(itSrc); |
|
831 |
for(itCount=0;!it.AtEnd();++itCount, it.Next()) |
|
832 |
{ |
|
833 |
if(!it.IsInFoldedSequence()) |
|
834 |
{ |
|
835 |
it.EnterFoldedSequence(); |
|
836 |
} |
|
837 |
TChar ch = it.Current(); |
|
838 |
test(ch == static_cast <TUint> (KStrOut3[itCount])); |
|
839 |
RDebug::Print(_L("%04X "), (TUint)ch); |
|
840 |
} |
|
841 |
test(itCount == ARRAY_SIZE(KStrOut3)); |
|
842 |
RDebug::Print(_L("\n")); |
|
843 |
} |
|
844 |
||
845 |
/** |
|
846 |
@SYMTestCaseID SYSLIB-UNICODE-CT-0099 |
|
847 |
@SYMTestCaseDesc TFoldedSortedDecompIterator functionality tested on 1 character sequence. |
|
848 |
@SYMTestPriority High |
|
849 |
@SYMTestActions TFoldedSortedDecompIterator test. |
|
850 |
@SYMTestExpectedResults The test must not fail. |
|
851 |
@SYMPREQ814 Optimise folded string comparisons. |
|
852 |
*/ |
|
853 |
void TestFoldedSortedDecompIterator() |
|
854 |
{ |
|
855 |
//Character sequence 1: |
|
856 |
//(1) GREEK CAPITAL LETTER BETA - 0x0392 (fold: 0x3B2, ccc=0) |
|
857 |
//(2) COMBINING GRAVE ACCENT - 0x0300 (no fold, ccc=230) |
|
858 |
//(3) COMBINING GRAVE ACCENT BELOW - 0x0316 (no fold, ccc=220) |
|
859 |
//(4) GREEK CAPITAL LETTER GAMMA - 0x0393 (fold: 0x3B3, ccc=0) |
|
860 |
//(5) HEBREW POINT TSERE - 0x05B5 (no fold, ccc=15) |
|
861 |
//(6) 0x10A39 (no fold, ccc=1) |
|
862 |
//(7) TIBETAN MARK HALANTA - 0x0F84 (no fold, ccc=9) |
|
863 |
//(8) 0x10400 (fold: 0x10428, ccc=0) |
|
864 |
//(9) 0x10A38 (no fold, ccc=230) |
|
865 |
//(10) 0xFB1E (no fold, ccc=26) |
|
866 |
//Decompositions: |
|
867 |
//0x03B2 Class 0 |
|
868 |
//0x0316 Class 220 |
|
869 |
//0x0300 Class 230 |
|
870 |
//0x03B3 Class 0 |
|
871 |
//0x10A39 Class 1 |
|
872 |
//0x0F84 Class 9 |
|
873 |
//0x05B5 Class 15 |
|
874 |
//0x10428 Class 0 |
|
875 |
//0xFB1E Class 26 |
|
876 |
//0x10A38 Class 230 |
|
877 |
//const TText16 KStr[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0x0F84}; |
|
878 |
//const TText16 KStrOut[] = {0x03B2, 0x0316, 0x0300, 0x03B3, 0x0F84, 0x05B5}; |
|
879 |
//const TInt KClass[] = {0, 220, 230, 0, 9, 15}; |
|
880 |
const TText16 KStr[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0xD802, 0xDE39, 0x0F84, 0xD801, 0xDC00, 0xD802, 0xDE38, 0xFB1E}; |
|
881 |
const TUint32 KStrOut[] = {0x03B2, 0x0316, 0x0300, 0x03B3, 0x10A39, 0x0F84, 0x05B5, 0x10428, 0xFB1E, 0x10A38}; |
|
882 |
const TInt KClass[] = {0, 220, 230, 0, 1, 9, 15, 0, 26, 230}; |
|
883 |
::TestPrintCaption(_L("TFoldedSortedDecompIterator"), KStr, ARRAY_SIZE(KStr)); |
|
884 |
RDebug::Print(_L("\n")); |
|
885 |
TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); |
|
886 |
TFoldedDecompIterator itDecomp(itSrc); |
|
887 |
TInt itCount = 0; |
|
888 |
while(!itDecomp.AtEnd()) |
|
889 |
{ |
|
890 |
if(!itDecomp.IsInFoldedSequence()) |
|
891 |
{ |
|
892 |
itDecomp.EnterFoldedSequence(); |
|
893 |
} |
|
894 |
if(itDecomp.Current().GetCombiningClass() == 0) |
|
895 |
{ |
|
896 |
TChar ch = itDecomp.Current(); |
|
897 |
TInt clss = itDecomp.Current().GetCombiningClass(); |
|
898 |
RDebug::Print(_L("BaseCh %04X Class %d\n"), (TUint)ch, clss); |
|
899 |
test(ch == static_cast <TUint> (KStrOut[itCount])); |
|
900 |
test(clss == KClass[itCount]); |
|
901 |
itDecomp.Next(); |
|
902 |
++itCount; |
|
903 |
} |
|
904 |
else |
|
905 |
{ |
|
906 |
TFoldedSortedDecompIterator it; |
|
907 |
it.Set(itDecomp); |
|
908 |
while(!it.AtEnd()) |
|
909 |
{ |
|
910 |
TChar ch = it.Current(); |
|
911 |
TInt clss = it.Current().GetCombiningClass(); |
|
912 |
RDebug::Print(_L("CombCh %08X Class %d\n"), (TUint)ch, clss); |
|
913 |
test(ch == static_cast <TUint> (KStrOut[itCount])); |
|
914 |
test(clss == KClass[itCount]); |
|
915 |
it.Next(); |
|
916 |
++itCount; |
|
917 |
} |
|
918 |
} |
|
919 |
} |
|
920 |
test(itCount == ARRAY_SIZE(KStrOut)); |
|
921 |
} |
|
922 |
||
923 |
/** |
|
924 |
@SYMTestCaseID SYSLIB-UNICODE-CT-0100 |
|
925 |
@SYMTestCaseDesc TFoldedCanonicalIterator functionality tested on 1 character sequence. |
|
926 |
@SYMTestPriority High |
|
927 |
@SYMTestActions TFoldedCanonicalIterator test. |
|
928 |
@SYMTestExpectedResults The test must not fail. |
|
929 |
@SYMPREQ814 Optimise folded string comparisons. |
|
930 |
*/ |
|
931 |
void TestFoldedCanonicalIterator() |
|
932 |
{ |
|
933 |
//Character sequence 1: |
|
934 |
//(1) GREEK CAPITAL LETTER BETA - 0x0392 |
|
935 |
//(2) COMBINING GRAVE ACCENT - 0x0300 |
|
936 |
//(3) COMBINING GRAVE ACCENT BELOW - 0x0316 |
|
937 |
//(4) GREEK CAPITAL LETTER GAMMA - 0x0393 |
|
938 |
//(5) HEBREW POINT TSERE - 0x05B5 |
|
939 |
//(6) TIBETAN MARK HALANTA - 0x0F84 |
|
940 |
//(7) MUSICAL SYMBOL EIGHTH NOTE - 0x1D161 (D834, DD61) |
|
941 |
//(8) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5 |
|
942 |
//Decompositions: |
|
943 |
//0x0392 to 0x03B2 |
|
944 |
//0x0316 to 0x0316 |
|
945 |
//0x0300 to 0x0300 |
|
946 |
//0x0393 to 0x03B3 |
|
947 |
//0x0F84 to 0x0F84 |
|
948 |
//0x05B5 to 0x05B5 |
|
949 |
//0x1D161 to 0x1D158 0x1D165 0x1D16F |
|
950 |
//0x01D5 to 0x0075 0x0308 0x0304 |
|
951 |
const TText16 KStr[] = {0x0392, 0x0300, 0x0316, 0x0393, 0x05B5, 0x0F84, 0xD834, 0xDD61, 0x01D5}; |
|
952 |
const TUint32 KStrOut[] = {0x03B2, 0x0316, 0x0300, 0x03B3, 0x0F84, 0x05B5, 0x1D158, 0x1D165, 0x1D16F, 0x0075, 0x0308, 0x0304}; |
|
953 |
TestPrintCaption(_L("TFoldedCanonicalIterator"), KStr, ARRAY_SIZE(KStr)); |
|
954 |
TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); |
|
955 |
TFoldedCanonicalIterator it(itSrc); |
|
956 |
TInt itCount = 0; |
|
957 |
||
958 |
const TUnicodeDataSet* charDataSet = GetLocaleCharSet()->iCharDataSet; |
|
959 |
||
960 |
for(;!it.AtEnd();++itCount, it.Next(charDataSet)) |
|
961 |
{ |
|
962 |
TChar ch = it.Current(); |
|
963 |
test(ch == static_cast <TUint> (KStrOut[itCount])); |
|
964 |
RDebug::Print(_L("%04X "), (TUint)ch); |
|
965 |
} |
|
966 |
test(itCount == ARRAY_SIZE(KStrOut)); |
|
967 |
RDebug::Print(_L("\n")); |
|
968 |
||
969 |
//10400 |
|
970 |
//103ff |
|
971 |
} |
|
972 |
||
973 |
/** |
|
974 |
@SYMTestCaseID SYSLIB-UNICODE-CT-0101 |
|
975 |
@SYMTestCaseDesc TDecompositionIterator functionality tested on 1 character sequence |
|
976 |
@SYMTestPriority High |
|
977 |
@SYMTestActions TDecompositionIterator test. |
|
978 |
@SYMTestExpectedResults The test must not fail. |
|
979 |
@SYMPREQ814 Optimise folded string comparisons. |
|
980 |
*/ |
|
981 |
void TestDecompositionIterator2() |
|
982 |
{ |
|
983 |
//Character sequence 1 |
|
984 |
//LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5 |
|
985 |
//Decomposition: |
|
986 |
//0x01D5 to: 0x0055 0x0308 0x0304 |
|
987 |
const TText16 KStr[] = {0x01D5}; |
|
988 |
const TText16 KStrOut[] = {0x0055, 0x0308, 0x0304}; |
|
989 |
TestPrintCaption(_L("TDecompositionIterator"), KStr, ARRAY_SIZE(KStr)); |
|
990 |
TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); |
|
991 |
TDecompositionIterator it; |
|
992 |
it.Set(itSrc); |
|
993 |
TInt itCount = 0; |
|
994 |
for(;!it.AtEnd(); ++itCount, it.Next()) |
|
995 |
{ |
|
996 |
TChar ch = it.Current(); |
|
997 |
test(ch == static_cast <TUint> (KStrOut[itCount])); |
|
998 |
RDebug::Print(_L("%04X "), (TUint)ch); |
|
999 |
} |
|
1000 |
test(itCount == ARRAY_SIZE(KStrOut)); |
|
1001 |
RDebug::Print(_L("\n")); |
|
1002 |
||
1003 |
// Character sequence 2 |
|
1004 |
// MUSICAL SYMBOL THIRTY-SECOND NOTE - 0x1D162 (D834, DD62) |
|
1005 |
// Decomposition: |
|
1006 |
// 0x1D162 to: 0x1D15F 0x1D170, then to: 0x1D158 0x1D165 0x1D170 |
|
1007 |
const TText16 KStr2[] = {0xD834, 0xDD62}; |
|
1008 |
const TUint32 KStrOut2[] = {0x1D158, 0x1D165, 0x1D170}; |
|
1009 |
TestPrintCaption(_L("TDecompositionIterator"), KStr2, ARRAY_SIZE(KStr2)); |
|
1010 |
TUTF32Iterator itSrc2(KStr2, KStr2 + ARRAY_SIZE(KStr2)); |
|
1011 |
TDecompositionIterator it2; |
|
1012 |
it2.Set(itSrc2); |
|
1013 |
TInt itCount2 = 0; |
|
1014 |
for(;!it2.AtEnd(); ++itCount2, it2.Next()) |
|
1015 |
{ |
|
1016 |
TChar ch = it2.Current(); |
|
1017 |
//test.Printf(_L(" expect = %08X, result = %08X\n"), KStrOut2[itCount2], ch); |
|
1018 |
test(ch == KStrOut2[itCount2]); |
|
1019 |
RDebug::Print(_L("%04X "), (TUint)ch); |
|
1020 |
} |
|
1021 |
test(itCount2 == ARRAY_SIZE(KStrOut2)); |
|
1022 |
RDebug::Print(_L("\n")); |
|
1023 |
} |
|
1024 |
||
1025 |
/** |
|
1026 |
@SYMTestCaseID SYSLIB-UNICODE-CT-0102 |
|
1027 |
@SYMTestCaseDesc TCanonicalDecompositionIterator functionality tested on 1 character sequence |
|
1028 |
@SYMTestPriority High |
|
1029 |
@SYMTestActions TCanonicalDecompositionIterator test. |
|
1030 |
@SYMTestExpectedResults The test must not fail. |
|
1031 |
@SYMPREQ814 Optimise folded string comparisons. |
|
1032 |
*/ |
|
1033 |
void TestCanonicalDecompositionIterator2() |
|
1034 |
{ |
|
1035 |
//Character sequence 1 |
|
1036 |
//(1) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5 |
|
1037 |
//(2) MUSICAL SYMBOL THIRTY-SECOND NOTE - 0x1D162 (D834, DD62) |
|
1038 |
//Decomposition: |
|
1039 |
//0x01D5 to: 0x0055 0x0308 0x0304 |
|
1040 |
//0x1D162 to: 0x1D15F 0x1D170, then to: 0x1D158 0x1D165 0x1D170 |
|
1041 |
const TText16 KStr[] = {0x01D5, 0xD834, 0xDD62}; |
|
1042 |
const TUint32 KStrOut[] = {0x0055, 0x0308, 0x0304, 0x1D158, 0x1D165, 0x1D170}; |
|
1043 |
TestPrintCaption(_L("TCanonicalDecompositionIterator"), KStr, ARRAY_SIZE(KStr)); |
|
1044 |
TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); |
|
1045 |
TCanonicalDecompositionIterator it; |
|
1046 |
it.Set(itSrc); |
|
1047 |
TInt itCount = 0; |
|
1048 |
for(;!it.AtEnd();++itCount, it.Next()) |
|
1049 |
{ |
|
1050 |
TChar ch = it.Current(); |
|
1051 |
test(ch == static_cast <TUint> (KStrOut[itCount])); |
|
1052 |
RDebug::Print(_L("%04X "), (TUint)ch); |
|
1053 |
} |
|
1054 |
test(itCount == ARRAY_SIZE(KStrOut)); |
|
1055 |
RDebug::Print(_L("\n")); |
|
1056 |
} |
|
1057 |
||
1058 |
/** |
|
1059 |
@SYMTestCaseID SYSLIB-UNICODE-CT-0103 |
|
1060 |
@SYMTestCaseDesc TCanonicalDecompositionIteratorCached functionality tested on 1 character sequence |
|
1061 |
@SYMTestPriority High |
|
1062 |
@SYMTestActions TCanonicalDecompositionIteratorCached test. |
|
1063 |
@SYMTestExpectedResults The test must not fail. |
|
1064 |
@SYMPREQ814 Optimise folded string comparisons. |
|
1065 |
*/ |
|
1066 |
void TestCanonicalDecompositionIteratorCached() |
|
1067 |
{ |
|
1068 |
//Character sequence 1 |
|
1069 |
//(1) LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON - 0x01D5 |
|
1070 |
//(2) MUSICAL SYMBOL THIRTY-SECOND NOTE - 0x1D162 (D834, DD62) |
|
1071 |
//Decomposition: |
|
1072 |
//0x01D5 to: 0x0055 0x0308 0x0304 |
|
1073 |
//0x1D162 to: 0x1D15F 0x1D170, then to: 0x1D158 0x1D165 0x1D170 |
|
1074 |
const TText16 KStr[] = {0x01D5, 0xD834, 0xDD62}; |
|
1075 |
const TUint32 KStrOut[] = {0x0055, 0x0308, 0x0304, 0x1D158, 0x1D165, 0x1D170}; |
|
1076 |
TestPrintCaption(_L("TCanonicalDecompositionIteratorCached"), KStr, ARRAY_SIZE(KStr)); |
|
1077 |
TUTF32Iterator itSrc(KStr, KStr + ARRAY_SIZE(KStr)); |
|
1078 |
TCanonicalDecompositionIteratorCached it; |
|
1079 |
it.Set(itSrc); |
|
1080 |
TInt itCount = 0; |
|
1081 |
for(;!it.AtEnd();++itCount, it.Next(1)) |
|
1082 |
{ |
|
1083 |
TChar ch = it.Get(0); |
|
1084 |
test(ch == static_cast <TUint> (KStrOut[itCount])); |
|
1085 |
RDebug::Print(_L("%04X "), (TUint)ch); |
|
1086 |
} |
|
1087 |
test(itCount == ARRAY_SIZE(KStrOut)); |
|
1088 |
RDebug::Print(_L("\n")); |
|
1089 |
} |
|
1090 |
||
1091 |
/** |
|
1092 |
@SYMTestCaseID SYSLIB-UNICODE-CT-0104 |
|
1093 |
@SYMTestCaseDesc TDecompositionIterator test |
|
1094 |
@SYMTestPriority High |
|
1095 |
@SYMTestActions TDecompositionIterator test. |
|
1096 |
@SYMTestExpectedResults The test must not fail. |
|
1097 |
@SYMPREQ814 Optimise folded string comparisons. |
|
1098 |
*/ |
|
1099 |
void TestDecompositionIterator() |
|
1100 |
{ |
|
1101 |
TDecompositionIterator i; |
|
1102 |
||
1103 |
// test basic character handling |
|
1104 |
TUTF32Iterator i1(KHelloT().Ptr(), KHelloT().Ptr() + KHelloT().Length()); |
|
1105 |
i.Set(i1); |
|
1106 |
TestIteratorOutput(i, KHelloT); |
|
1107 |
||
1108 |
TUTF32Iterator i2(KHelloT().Ptr() + 3, KHelloT().Ptr() + KHelloT().Length()); |
|
1109 |
i.Set(i2); |
|
1110 |
TestIteratorOutput(i, KHelloT().Mid(3)); |
|
1111 |
||
1112 |
// test combining characters |
|
1113 |
TUTF32Iterator i3(KLatin1AccentsC().Ptr(), KLatin1AccentsC().Ptr() + KLatin1AccentsC().Length()); |
|
1114 |
i.Set(i3); |
|
1115 |
TestIteratorOutput(i, KLatin1AccentsD); |
|
1116 |
||
1117 |
TUTF32Iterator i4(KGreekAccentsC().Ptr(), KGreekAccentsC().Ptr() + KGreekAccentsC().Length()); |
|
1118 |
i.Set(i4); |
|
1119 |
TestIteratorOutput(i, KGreekAccentsD); |
|
1120 |
||
1121 |
TUTF32Iterator i5(KGreekAccentsS().Ptr(), KGreekAccentsS().Ptr() + KGreekAccentsS().Length()); |
|
1122 |
i.Set(i5); |
|
1123 |
TestIteratorOutput(i, KGreekAccentsD); |
|
1124 |
||
1125 |
// test that full-width variants are not fiddled with |
|
1126 |
TUTF32Iterator i6(KFullWidth().Ptr(), KFullWidth().Ptr() + KFullWidth().Length()); |
|
1127 |
i.Set(i6); |
|
1128 |
TestIteratorOutput(i, KFullWidth); |
|
1129 |
||
1130 |
TUTF32Iterator i7(KSurrogates().Ptr(), KSurrogates().Ptr() + KSurrogates().Length()); |
|
1131 |
i.Set(i7); |
|
1132 |
TestIteratorOutput(i, KSurrogatesTest); |
|
1133 |
} |
|
1134 |
||
1135 |
//The function collects collation keys at the specified level aLevel from aIt iterator |
|
1136 |
//and stores them in aBuf output parameter. |
|
1137 |
//aExpectedNumKeys value specifies the count of expected collation keys. |
|
1138 |
void GetKeys(TCollationValueIterator& aIt, TUint32* aBuf, TInt aLevel, TInt aExpectedNumKeys) |
|
1139 |
{ |
|
1140 |
//Zero the output parameter |
|
1141 |
Mem::FillZ(aBuf, sizeof(TUint32) * aExpectedNumKeys); |
|
1142 |
//Get the keys |
|
1143 |
TInt i = 0; |
|
1144 |
for(;i!=aExpectedNumKeys;++i) |
|
1145 |
{ |
|
1146 |
for (;;) |
|
1147 |
{ |
|
1148 |
(void)aIt.GetCurrentKey(aLevel, aBuf[i]); |
|
1149 |
test(aIt.Increment()); |
|
1150 |
if(aBuf[i] != 0) |
|
1151 |
{ |
|
1152 |
break; |
|
1153 |
} |
|
1154 |
} |
|
1155 |
} |
|
1156 |
//The rest of the keys at that level should have 0 value. |
|
1157 |
for(;aIt.Increment();) |
|
1158 |
{ |
|
1159 |
TUint32 key = 0; |
|
1160 |
(void)aIt.GetCurrentKey(aLevel, key); |
|
1161 |
test(key == 0); |
|
1162 |
} |
|
1163 |
} |
|
1164 |
||
1165 |
//The function collects the raw keys from aIt iterator and stores them in aBuf output parameter. |
|
1166 |
//aExpectedNumKeys value specifies the count of expected raw collation keys. |
|
1167 |
void GetRawKeys(TCollationValueIterator& aIt, TCollationKey* aBuf, TInt aExpectedNumKeys) |
|
1168 |
{ |
|
1169 |
//Zero the output parameter |
|
1170 |
Mem::FillZ(aBuf, sizeof(TCollationKey) * aExpectedNumKeys); |
|
1171 |
//Get the keys |
|
1172 |
for(TInt i=0;i!=aExpectedNumKeys;++i) |
|
1173 |
{ |
|
1174 |
test(aIt.GetCurrentKey(aBuf[i])); |
|
1175 |
aIt.Increment(); |
|
1176 |
} |
|
1177 |
//One additional GetCurrentKey() call. Because there shouldn't be more raw keys than |
|
1178 |
//aExpectedNumKeys, the call should fail returning EFalse. |
|
1179 |
TCollationKey dummy; |
|
1180 |
test(!aIt.GetCurrentKey(dummy)); |
|
1181 |
} |
|
1182 |
||
1183 |
//The function gets a sequence of raw collation keys in aBuf parameter and a character number |
|
1184 |
//aCharNo in the original string. |
|
1185 |
//It returns the position in aBuf where raw collation key sequence for aCharNo starts. |
|
1186 |
TInt CharNo2CollKeyPos(const TCollationKey* aBuf, TInt aBufLen, TInt aCharNo) |
|
1187 |
{ |
|
1188 |
TInt starterCnt = 0; |
|
1189 |
TInt pos = 0; |
|
1190 |
do |
|
1191 |
{ |
|
1192 |
if(aBuf[pos].IsStarter()) |
|
1193 |
{ |
|
1194 |
++starterCnt; |
|
1195 |
} |
|
1196 |
} while(starterCnt!=(aCharNo+1) && ++pos!=aBufLen); |
|
1197 |
test(pos != aBufLen); |
|
1198 |
return pos; |
|
1199 |
} |
|
1200 |
||
1201 |
//The function compares aBuf1 and aBuf2 and returns how many elements in aBuf1 differ |
|
1202 |
//from the elements in aBuf2 at the same position. |
|
1203 |
TInt CountDiscrepancies(TUint32* aBuf1, TUint32* aBuf2, TInt aCount) |
|
1204 |
{ |
|
1205 |
TInt discrepancies = 0; |
|
1206 |
for (; aCount; --aCount) |
|
1207 |
{ |
|
1208 |
if (*aBuf1++ != *aBuf2++) |
|
1209 |
++discrepancies; |
|
1210 |
} |
|
1211 |
return discrepancies; |
|
1212 |
} |
|
1213 |
||
1214 |
TInt CountDiscrepancies(TCollationKey* aBuf1, TCollationKey* aBuf2, TInt aCount) |
|
1215 |
{ |
|
1216 |
TInt discrepancies = 0; |
|
1217 |
for (; aCount; --aCount) |
|
1218 |
{ |
|
1219 |
if (aBuf1->iHigh != aBuf2->iHigh || aBuf1->iLow != aBuf2->iLow) |
|
1220 |
++discrepancies; |
|
1221 |
++aBuf1; |
|
1222 |
++aBuf2; |
|
1223 |
} |
|
1224 |
return discrepancies; |
|
1225 |
} |
|
1226 |
||
1227 |
_LIT(KAYZAccentsAbove, "\xE0\x301y\x302z\x303\x304"); |
|
1228 |
_LIT(KCapitalAYZAccentsAbove, "A\x300\x301Y\x302Z\x303\x304"); |
|
1229 |
_LIT(KCapitalYAYZAccentsAbove, "a\x300\x301Y\x302z\x303\x304"); |
|
1230 |
_LIT(KABCRuleTest, "abcwabkakb"); |
|
1231 |
_LIT(KABCRuleExpected, "eeabkakb"); |
|
1232 |
//_LIT(KExhaustCaches, "0123456789ABCDEFexhausted"); |
|
1233 |
_LIT(KGreekOPVY1, "\x1f82"); |
|
1234 |
_LIT(KGreekOPVY2, "\x1f02\x345"); |
|
1235 |
_LIT(KGreekOPVY3, "\x1f00\x300\x345"); |
|
1236 |
_LIT(KGreekOPVY4, "\x3b1\x313\x300\x345"); |
|
1237 |
_LIT(KGreekOPVY5, "\x3b1\x313\x345\x300"); |
|
1238 |
_LIT(KGreekOPVY6, "\x3b1\x345\x313\x300"); |
|
1239 |
||
1240 |
/** |
|
1241 |
@SYMTestCaseID SYSLIB-UNICODE-CT-0105 |
|
1242 |
@SYMTestCaseDesc TCollationValueIterator test |
|
1243 |
@SYMTestPriority High |
|
1244 |
@SYMTestActions TCollationValueIterator tests |
|
1245 |
@SYMTestExpectedResults The test must not fail. |
|
1246 |
@SYMPREQ814 Optimise folded string comparisons. |
|
1247 |
*/ |
|
1248 |
void TestCollationValueIterator() |
|
1249 |
{ |
|
1250 |
// a funny pair of extra collation rules: w and abc both collate as e. |
|
1251 |
TUint32 abcWTLKey[] = {0/* key for 'e' will go here */, |
|
1252 |
0x8ff00101, 0x8ff10101, 0x8ff20101, 0x8ff30101, |
|
1253 |
0x8ff40101, 0x8ff50101, 0x8ff60101}; |
|
1254 |
const TUint32 overrideIndex[] = {0x00770000, 0x0E010001, 0x0E400002, 0x0E440003, |
|
1255 |
0x0E810004, 0x0EC10005, 0x0EC20006, 0xEC30007}; |
|
1256 |
const TUint16 abcString[4] = {0x0003, 0x0061, 0x0062, 0x0063}; |
|
1257 |
const TUint32 abcStringIndex = 0; |
|
1258 |
TCollationMethod method; |
|
1259 |
method.iId = 0; |
|
1260 |
method.iMainTable = StandardCollationMethod(); |
|
1261 |
method.iFlags = TCollationMethod::EIgnoreNone; |
|
1262 |
TInt charindex; |
|
1263 |
for (charindex = 0; method.iMainTable->iIndex[charindex] >> 16 != 'e'; ++charindex) |
|
1264 |
{ |
|
1265 |
} |
|
1266 |
abcWTLKey[0] = method.iMainTable->iKey[method.iMainTable->iIndex[charindex] & 0xFFFF]; |
|
1267 |
TCollationKeyTable overrideTable = {abcWTLKey, overrideIndex, sizeof(abcWTLKey)/4, abcString, &abcStringIndex, 1}; |
|
1268 |
method.iOverrideTable = &overrideTable; |
|
1269 |
||
1270 |
TCollationValueIterator v(method); |
|
1271 |
TCollationValueIterator rv(method); |
|
1272 |
||
1273 |
TUint32 buf1[32]; |
|
1274 |
TUint32 buf2[32]; |
|
1275 |
||
1276 |
TCollationKey raw1[32]; |
|
1277 |
TCollationKey raw2[32]; |
|
1278 |
const TInt KRawKeyCnt = 8;//Raw collation key count produced from KAYZAccentsAbove string. |
|
1279 |
||
1280 |
//Get the raw key sequence for the whole KAYZAccentsAbove string. |
|
1281 |
TUTF32Iterator it(KAYZAccentsAbove().Ptr(), KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); |
|
1282 |
rv.SetSourceIt(it); |
|
1283 |
::GetRawKeys(rv, raw1, KRawKeyCnt); |
|
1284 |
||
1285 |
//KAYZAccentsAbove related constants |
|
1286 |
const TInt KBaseCharCnt = 3;//The number of base characters (A, y, z) in KAYZAccentsAbove string. |
|
1287 |
const TInt KOrgPosA = 0;//A position in KAYZAccentsAbove |
|
1288 |
const TInt KOrgPosY = 2;//y position in KAYZAccentsAbove |
|
1289 |
const TInt KOrgPosZ = 4;//z position in KAYZAccentsAbove |
|
1290 |
//Find where the collation key sequences start for A, y, z characters in KAYZAccentsAbove string. |
|
1291 |
const TInt KCollKeyPosA = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 0); |
|
1292 |
const TInt KCollKeyPosY = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 1); |
|
1293 |
const TInt KCollKeyPosZ = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 2); |
|
1294 |
||
1295 |
//Get the raw key sequence for character A in KAYZAccentsAbove string. |
|
1296 |
it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosA, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); |
|
1297 |
rv.SetSourceIt(it); |
|
1298 |
::GetRawKeys(rv, raw2 + KCollKeyPosA, KRawKeyCnt - KCollKeyPosA); |
|
1299 |
// |
|
1300 |
test(0 == ::CountDiscrepancies(raw1, raw2, KRawKeyCnt)); |
|
1301 |
||
1302 |
//Get the raw key sequence for character Y in KAYZAccentsAbove string. |
|
1303 |
it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosY, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); |
|
1304 |
rv.SetSourceIt(it); |
|
1305 |
::GetRawKeys(rv, raw2 + KCollKeyPosY, KRawKeyCnt - KCollKeyPosY); |
|
1306 |
// |
|
1307 |
test(0 == ::CountDiscrepancies(raw1, raw2, KRawKeyCnt)); |
|
1308 |
||
1309 |
//Get the raw key sequence for character Z in KAYZAccentsAbove string. |
|
1310 |
it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosZ, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); |
|
1311 |
rv.SetSourceIt(it); |
|
1312 |
::GetRawKeys(rv, raw2 + KCollKeyPosZ, KRawKeyCnt - KCollKeyPosZ); |
|
1313 |
// |
|
1314 |
test(0 == ::CountDiscrepancies(raw1, raw2, KRawKeyCnt)); |
|
1315 |
||
1316 |
//Test starting at different points in the iteration |
|
1317 |
||
1318 |
//Level 0 |
|
1319 |
//The whole string |
|
1320 |
it = TUTF32Iterator(KAYZAccentsAbove().Ptr(), KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); |
|
1321 |
v.SetSourceIt(it); |
|
1322 |
::GetKeys(v, buf1, 0, KBaseCharCnt); |
|
1323 |
//String from Y pos. |
|
1324 |
it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosY, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); |
|
1325 |
v.SetSourceIt(it); |
|
1326 |
::GetKeys(v, buf2, 0, KBaseCharCnt - 1); |
|
1327 |
// |
|
1328 |
test(0 == ::CountDiscrepancies(buf1 + 1, buf2, KBaseCharCnt - 1)); |
|
1329 |
//String from Z pos. |
|
1330 |
it = TUTF32Iterator(KAYZAccentsAbove().Ptr() + KOrgPosZ, KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); |
|
1331 |
v.SetSourceIt(it); |
|
1332 |
::GetKeys(v, buf2, 0, KBaseCharCnt - 2); |
|
1333 |
// |
|
1334 |
test(0 == ::CountDiscrepancies(buf1 + 2, buf2, KBaseCharCnt - 2)); |
|
1335 |
||
1336 |
//Level 1 |
|
1337 |
//KCapitalAYZAccentsAbove is used in this test. |
|
1338 |
it = TUTF32Iterator(KCapitalAYZAccentsAbove().Ptr(), KCapitalAYZAccentsAbove().Ptr() + KCapitalAYZAccentsAbove().Length()); |
|
1339 |
v.SetSourceIt(it); |
|
1340 |
::GetRawKeys(v, raw1, 8); |
|
1341 |
const TInt KOrgPosY2 = 3;//Y position in KCapitalAYZAccentsAbove |
|
1342 |
const TInt KCollKeyPosY2 = ::CharNo2CollKeyPos(raw1, KRawKeyCnt, 1); |
|
1343 |
//The whole string |
|
1344 |
it = TUTF32Iterator(KCapitalAYZAccentsAbove().Ptr(), KCapitalAYZAccentsAbove().Ptr() + KCapitalAYZAccentsAbove().Length()); |
|
1345 |
v.SetSourceIt(it); |
|
1346 |
::GetKeys(v, buf1, 1, 8); |
|
1347 |
//String from Y pos. |
|
1348 |
it = TUTF32Iterator(KCapitalAYZAccentsAbove().Ptr() + KOrgPosY2, KCapitalAYZAccentsAbove().Ptr() + KCapitalAYZAccentsAbove().Length()); |
|
1349 |
v.SetSourceIt(it); |
|
1350 |
::GetKeys(v, buf2, 1, 8 - KCollKeyPosY2); |
|
1351 |
// |
|
1352 |
test(0 == ::CountDiscrepancies(buf1 + KCollKeyPosY2, buf2, 8 - KCollKeyPosY2)); |
|
1353 |
||
1354 |
//Level 2 |
|
1355 |
//Capitals do not match at level 2 |
|
1356 |
it = TUTF32Iterator(KAYZAccentsAbove().Ptr(), KAYZAccentsAbove().Ptr() + KAYZAccentsAbove().Length()); |
|
1357 |
v.SetSourceIt(it); |
|
1358 |
::GetKeys(v, buf1, 2, 8); |
|
1359 |
it = TUTF32Iterator(KCapitalYAYZAccentsAbove().Ptr(), KCapitalYAYZAccentsAbove().Ptr() + KCapitalYAYZAccentsAbove().Length()); |
|
1360 |
v.SetSourceIt(it); |
|
1361 |
::GetKeys(v, buf2, 2, 8); |
|
1362 |
// |
|
1363 |
test(1 == CountDiscrepancies(buf1, buf2, 8)); |
|
1364 |
test(buf1[3] != buf2[3]); |
|
1365 |
||
1366 |
//Test funny collation keys, when they succeed and when they fail half way. |
|
1367 |
it = TUTF32Iterator(KABCRuleTest().Ptr(), KABCRuleTest().Ptr() + KABCRuleTest().Length()); |
|
1368 |
v.SetSourceIt(it); |
|
1369 |
::GetKeys(v, buf1, 0, 8); |
|
1370 |
it = TUTF32Iterator(KABCRuleExpected().Ptr(), KABCRuleExpected().Ptr() + KABCRuleExpected().Length()); |
|
1371 |
v.SetSourceIt(it); |
|
1372 |
::GetKeys(v, buf2, 0, 8); |
|
1373 |
// |
|
1374 |
test(0 == ::CountDiscrepancies(buf1, buf2, 8)); |
|
1375 |
||
1376 |
//Test different decompositions at level 3 |
|
1377 |
it = TUTF32Iterator(KGreekOPVY1().Ptr(), KGreekOPVY1().Ptr() + KGreekOPVY1().Length()); |
|
1378 |
v.SetSourceIt(it); |
|
1379 |
::GetKeys(v, buf1, 3, 4); |
|
1380 |
// |
|
1381 |
it = TUTF32Iterator(KGreekOPVY2().Ptr(), KGreekOPVY2().Ptr() + KGreekOPVY2().Length()); |
|
1382 |
v.SetSourceIt(it); |
|
1383 |
::GetKeys(v, buf2, 3, 4); |
|
1384 |
// |
|
1385 |
test(0 == ::CountDiscrepancies(buf1, buf2, 4)); |
|
1386 |
// |
|
1387 |
it = TUTF32Iterator(KGreekOPVY3().Ptr(), KGreekOPVY3().Ptr() + KGreekOPVY3().Length()); |
|
1388 |
v.SetSourceIt(it); |
|
1389 |
::GetKeys(v, buf2, 3, 4); |
|
1390 |
// |
|
1391 |
test(0 == ::CountDiscrepancies(buf1, buf2, 4)); |
|
1392 |
// |
|
1393 |
it = TUTF32Iterator(KGreekOPVY4().Ptr(), KGreekOPVY4().Ptr() + KGreekOPVY4().Length()); |
|
1394 |
v.SetSourceIt(it); |
|
1395 |
::GetKeys(v, buf2, 3, 4); |
|
1396 |
// |
|
1397 |
test(0 == ::CountDiscrepancies(buf1, buf2, 4)); |
|
1398 |
// |
|
1399 |
it = TUTF32Iterator(KGreekOPVY5().Ptr(), KGreekOPVY5().Ptr() + KGreekOPVY5().Length()); |
|
1400 |
v.SetSourceIt(it); |
|
1401 |
::GetKeys(v, buf2, 3, 4); |
|
1402 |
// |
|
1403 |
test(0 == ::CountDiscrepancies(buf1, buf2, 4)); |
|
1404 |
// |
|
1405 |
it = TUTF32Iterator(KGreekOPVY6().Ptr(), KGreekOPVY6().Ptr() + KGreekOPVY6().Length()); |
|
1406 |
v.SetSourceIt(it); |
|
1407 |
::GetKeys(v, buf2, 3, 4); |
|
1408 |
// |
|
1409 |
test(0 == ::CountDiscrepancies(buf1, buf2, 4)); |
|
1410 |
} |
|
1411 |
||
1412 |
// folding tests |
|
1413 |
||
1414 |
// equivalence classes: all codes that fold to the same letter (which must be present |
|
1415 |
// in the list). The lists are separated by -1. The end is marked with two -1s. |
|
1416 |
// Each list must be in increasing order. |
|
1417 |
TInt FoldingEquivalenceClasses[] = |
|
1418 |
{ |
|
1419 |
'A', 'a', -1, 'Z', 'z', -1, '@', -1, '[', -1, '{', -1, 127, -1, 'I', 'i', 0x131, -1, 0, -1, |
|
1420 |
' ', 0xA0, -1, |
|
1421 |
0x300, -1, 0x301, -1, |
|
1422 |
0x141, 0x142, -1, |
|
1423 |
0x1c4, 0x1c5, 0x1c6, -1, 0x1c7, 0x1c8, 0x1c9, -1, 0x1ca, 0x1cb, 0x1cc, -1, |
|
1424 |
0x1f1, 0x1f2, 0x1f3, -1, 0x3a3, 0x3c2, 0x3c3, 0x3f2, -1, |
|
1425 |
0x402, 0x452, -1, 0x40F, 0x45F, -1, 0x460, 0x461, -1, 0x480, 0x481, -1, 0x482, -1, |
|
1426 |
0x410, 0x430, -1, 0x42F, 0x44f, -1, 0x48C, 0x48D, -1, 0x4e8, 0x4e9, -1, |
|
1427 |
0x531, 0x561, -1, 0x556, 0x586, -1, 0x559, -1, 0x55f, -1, -1 |
|
1428 |
}; |
|
1429 |
||
1430 |
//_LIT(KMatchLeadingCandidate1, "\xE1\x65\x300\x301\x302\x303pqa\x301"); |
|
1431 |
//_LIT(KNoQMs, "a???"); |
|
1432 |
//_LIT(KOneQM, "?a"); |
|
1433 |
//_LIT(KTwoQMs, "??"); |
|
1434 |
//_LIT(KThreeQMs, "???*?"); |
|
1435 |
||
1436 |
//Constructs TUTF32Iterator iterator from aStr |
|
1437 |
TUTF32Iterator UTF32It(const TDesC16& aStr) |
|
1438 |
{ |
|
1439 |
return TUTF32Iterator(aStr.Ptr(), aStr.Ptr() + aStr.Length()); |
|
1440 |
} |
|
1441 |
||
1442 |
/** |
|
1443 |
@SYMTestCaseID SYSLIB-UNICODE-CT-0107 |
|
1444 |
@SYMTestCaseDesc MatchSectionFolded test |
|
1445 |
@SYMTestPriority High |
|
1446 |
@SYMTestActions MatchSectionFolded test |
|
1447 |
@SYMTestExpectedResults The test must not fail. |
|
1448 |
@SYMPREQ814 Optimise folded string comparisons. |
|
1449 |
*/ |
|
1450 |
void MatchSectionFoldedTest() |
|
1451 |
{ |
|
1452 |
TUTF32Iterator candidateIt, searchTermIt; |
|
1453 |
||
1454 |
candidateIt = UTF32It(_L16("\xE1")); |
|
1455 |
searchTermIt = UTF32It(_L16("a")); |
|
1456 |
test(!MatchSectionFolded(candidateIt, searchTermIt)); |
|
1457 |
||
1458 |
candidateIt = UTF32It(_L16("a")); |
|
1459 |
searchTermIt = UTF32It(_L16("\xE1")); |
|
1460 |
test(!MatchSectionFolded(candidateIt, searchTermIt)); |
|
1461 |
||
1462 |
candidateIt = UTF32It(_L16("abca\xE1\x62\x62\x61\x61\x61\x62\x63\x62\x61")); |
|
1463 |
searchTermIt = UTF32It(_L16("aBc")); |
|
1464 |
test(MatchSectionFolded(candidateIt, searchTermIt)); |
|
1465 |
test(searchTermIt.AtEnd()); |
|
1466 |
TPtrC16 p1(_L16("a\xE1\x62\x62\x61\x61\x61\x62\x63\x62\x61")); |
|
1467 |
TPtrC16 p2(candidateIt.CurrentPosition(), 11); |
|
1468 |
test(p1 == p2); |
|
1469 |
||
1470 |
candidateIt = UTF32It(_L16("aaaacdeiooo")); |
|
1471 |
searchTermIt = UTF32It(_L16("acde")); |
|
1472 |
test(!MatchSectionFolded(candidateIt, searchTermIt)); |
|
1473 |
} |
|
1474 |
||
1475 |
//FindMatchSectionFolded test |
|
1476 |
void DoFindMatchSectionFoldedTest(const TDesC16& aCandidate, const TDesC16& aSearchTerm, TInt aPos) |
|
1477 |
{ |
|
1478 |
TUTF32Iterator candidateIt, searchTermIt; |
|
1479 |
candidateIt = UTF32It(aCandidate); |
|
1480 |
searchTermIt = UTF32It(aSearchTerm); |
|
1481 |
if(aPos >= 0) |
|
1482 |
{ |
|
1483 |
test(FindMatchSectionFolded(candidateIt, searchTermIt)); |
|
1484 |
test(searchTermIt.AtEnd()); |
|
1485 |
} |
|
1486 |
else |
|
1487 |
{ |
|
1488 |
test(!FindMatchSectionFolded(candidateIt, searchTermIt)); |
|
1489 |
} |
|
1490 |
} |
|
1491 |
||
1492 |
//This class is used for reading lines from the unicode data file. |
|
1493 |
class RUnicodeTestDataFile |
|
1494 |
{ |
|
1495 |
public: |
|
1496 |
RUnicodeTestDataFile(); |
|
1497 |
void OpenLC(); |
|
1498 |
void Close(); |
|
1499 |
TBool NextStmt(TPtrC8& aStmt); |
|
1500 |
private: |
|
1501 |
HBufC8* iFileData; |
|
1502 |
TInt iStartPos; |
|
1503 |
}; |
|
1504 |
||
1505 |
RUnicodeTestDataFile::RUnicodeTestDataFile() : |
|
1506 |
iFileData(NULL), |
|
1507 |
iStartPos(0) |
|
1508 |
{ |
|
1509 |
} |
|
1510 |
||
1511 |
void RUnicodeTestDataFile::OpenLC() |
|
1512 |
{ |
|
1513 |
__ASSERT_ALWAYS(!iFileData && !iStartPos, User::Invariant()); |
|
1514 |
iFileData = NULL; |
|
1515 |
iStartPos = 0; |
|
1516 |
CleanupClosePushL(*this); |
|
1517 |
||
1518 |
RFs fileSess; |
|
1519 |
CleanupClosePushL(fileSess); |
|
1520 |
User::LeaveIfError(fileSess.Connect()); |
|
1521 |
||
1522 |
RFile file; |
|
1523 |
CleanupClosePushL(file); |
|
1524 |
User::LeaveIfError(file.Open(fileSess, KUnicodeTestDataFile, EFileRead)); |
|
1525 |
||
1526 |
TInt fileSize; |
|
1527 |
User::LeaveIfError(file.Size(fileSize)); |
|
1528 |
__ASSERT_ALWAYS(fileSize > 0, User::Invariant()); |
|
1529 |
||
1530 |
iFileData = HBufC8::NewL(fileSize + 1); |
|
1531 |
||
1532 |
TPtr8 p = iFileData->Des(); |
|
1533 |
User::LeaveIfError(file.Read(p)); |
|
1534 |
||
1535 |
CleanupStack::PopAndDestroy(2, &fileSess); |
|
1536 |
} |
|
1537 |
||
1538 |
void RUnicodeTestDataFile::Close() |
|
1539 |
{ |
|
1540 |
delete iFileData; |
|
1541 |
iFileData = NULL; |
|
1542 |
iStartPos = 0; |
|
1543 |
} |
|
1544 |
||
1545 |
TBool RUnicodeTestDataFile::NextStmt(TPtrC8& aStmt) |
|
1546 |
{ |
|
1547 |
aStmt.Set(NULL, 0); |
|
1548 |
if(iStartPos < iFileData->Length()) |
|
1549 |
{ |
|
1550 |
const TUint8* pStart = iFileData->Des().Ptr() + iStartPos; |
|
1551 |
const TUint8* pEnd = pStart; |
|
1552 |
while(*pEnd++ != 0x0A) |
|
1553 |
{ |
|
1554 |
} |
|
1555 |
iStartPos += pEnd - pStart; |
|
1556 |
aStmt.Set(pStart, pEnd - pStart - 1); |
|
1557 |
return ETrue; |
|
1558 |
} |
|
1559 |
return EFalse; |
|
1560 |
} |
|
1561 |
||
1562 |
//Get a field "aFieldNo" from "aStr" statement containing encoded unicode character data |
|
1563 |
TPtrC8 GetUnicodeDataField(const TPtrC8& aStr, TInt aFieldNo) |
|
1564 |
{ |
|
1565 |
const TUint8* pStart = aStr.Ptr(); |
|
1566 |
//Find the beginning of the field |
|
1567 |
TInt count = 0; |
|
1568 |
while(count < aFieldNo) |
|
1569 |
{ |
|
1570 |
if(*pStart++ == ';') |
|
1571 |
{ |
|
1572 |
++count; |
|
1573 |
} |
|
1574 |
} |
|
1575 |
//Find the end of the field |
|
1576 |
const TUint8* pEnd = pStart; |
|
1577 |
while(*pEnd++ != ';') |
|
1578 |
{ |
|
1579 |
} |
|
1580 |
//Construct a string from the field data |
|
1581 |
TPtrC8 ptr(pStart, pEnd - pStart - 1); |
|
1582 |
return ptr; |
|
1583 |
} |
|
1584 |
||
1585 |
//Construct a string "aStr" with the extracted hex codes from "aUnicodeData" |
|
1586 |
//The extracted unicodes are placed not from position 0, because some of |
|
1587 |
//the decomposable unicode characters are combining characters. If "aStr" is a search |
|
1588 |
//string, then the searching algorithm will not work. |
|
1589 |
void FillStringL(TDes16& aStr, const TDesC8& aUnicodeData) |
|
1590 |
{ |
|
1591 |
aStr.SetLength(aStr.MaxLength()); |
|
1592 |
TLex8 lex(aUnicodeData); |
|
1593 |
TInt len = 0; |
|
1594 |
for(len=0;!lex.Eos();++len) |
|
1595 |
{ |
|
1596 |
TUint32 code; |
|
1597 |
User::LeaveIfError(lex.Val(code, EHex)); |
|
1598 |
lex.Assign(lex.NextToken()); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1599 |
if (!TChar::IsSupplementary(code)) |
0 | 1600 |
{ |
1601 |
aStr[1+len] = (TUint16)code; |
|
1602 |
} |
|
1603 |
else |
|
1604 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1605 |
aStr[1+len] = TChar::GetHighSurrogate(code); |
0 | 1606 |
++len; |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1607 |
aStr[1+len] = TChar::GetLowSurrogate(code); |
0 | 1608 |
} |
1609 |
} |
|
1610 |
__ASSERT_ALWAYS(len > 0, User::Invariant()); |
|
1611 |
aStr.SetLength(1 + len); |
|
1612 |
} |
|
1613 |
||
1614 |
//Get the character unicode, which is at position 0 |
|
1615 |
TUint32 GetChCodeL(const TDesC8& aStr) |
|
1616 |
{ |
|
1617 |
TLex8 lex(aStr); |
|
1618 |
TUint32 chCode; |
|
1619 |
User::LeaveIfError(lex.Val(chCode, EHex)); |
|
1620 |
return chCode; |
|
1621 |
} |
|
1622 |
||
1623 |
//Simple unicode folding tests |
|
1624 |
void FindMatchSectionFoldedTestSimple() |
|
1625 |
{ |
|
1626 |
_LIT16(KCandidate, "abca\xE1\x62\x62\x61\x61\x61\x62\x63\x62\x61"); |
|
1627 |
DoFindMatchSectionFoldedTest(KCandidate, _L("abc"), 0); |
|
1628 |
DoFindMatchSectionFoldedTest(KCandidate, _L("abb"), -1); |
|
1629 |
DoFindMatchSectionFoldedTest(KCandidate, _L("caa"), -1); |
|
1630 |
DoFindMatchSectionFoldedTest(KCandidate, _L("abcb"), 9); |
|
1631 |
DoFindMatchSectionFoldedTest(KCandidate, _L("\xE1"), 4); |
|
1632 |
DoFindMatchSectionFoldedTest(KCandidate, _L("a\x301"), 4); |
|
1633 |
DoFindMatchSectionFoldedTest(KCandidate, _L("A\xC1\x42\x42"), 3); |
|
1634 |
DoFindMatchSectionFoldedTest(KCandidate, _L("a\x301\x42\x42"), 4); |
|
1635 |
DoFindMatchSectionFoldedTest(KCandidate, _L("a?BB"), 3); |
|
1636 |
DoFindMatchSectionFoldedTest(KCandidate, _L(""), 0); |
|
1637 |
DoFindMatchSectionFoldedTest(KCandidate, _L("?"), 0); |
|
1638 |
DoFindMatchSectionFoldedTest(KCandidate, _L("??????????????"), 0); |
|
1639 |
DoFindMatchSectionFoldedTest(KCandidate, _L("???????????????"), -1); |
|
1640 |
DoFindMatchSectionFoldedTest(KCandidate, _L("????a?????????"), -1); |
|
1641 |
DoFindMatchSectionFoldedTest(KCandidate, _L("???a??????????"), 0); |
|
1642 |
DoFindMatchSectionFoldedTest(KCandidate, _L("caa?"), -1); |
|
1643 |
DoFindMatchSectionFoldedTest(KCandidate, _L("abcb?"), 9); |
|
1644 |
DoFindMatchSectionFoldedTest(KCandidate, _L("abcb??"), -1); |
|
1645 |
DoFindMatchSectionFoldedTest(KCandidate, _L("b?aa"), 5); |
|
1646 |
} |
|
1647 |
||
1648 |
//Extended tests - all characters, having non-zero "character decomposition mapping" field |
|
1649 |
//or non-zero "upper case mapping" field |
|
1650 |
void FindMatchSectionFoldedTestComplexL() |
|
1651 |
{ |
|
1652 |
TBuf16<10> candidate; |
|
1653 |
candidate.Copy(_L16("abcdefghij")); |
|
1654 |
TBuf16<10> searchTerm; |
|
1655 |
searchTerm.Copy(_L16("eeeeefghij")); |
|
1656 |
const TInt KChPos = 5; |
|
1657 |
//Read and parse each line from the unicode data file. |
|
1658 |
RUnicodeTestDataFile unicodeTestDataFile; |
|
1659 |
unicodeTestDataFile.OpenLC(); |
|
1660 |
TPtrC8 stmt; |
|
1661 |
while(unicodeTestDataFile.NextStmt(stmt) && stmt.Length() > 0) |
|
1662 |
{ |
|
1663 |
//Get the character code |
|
1664 |
TUint32 chCode = GetChCodeL(stmt); |
|
1665 |
//"LATIN CAPITAL LETTER I WITH DOT ABOVE" - the searching algorithm does not work with it. |
|
1666 |
if(chCode == (TUint32)0x0130) |
|
1667 |
{ |
|
1668 |
continue; |
|
1669 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1670 |
if (!TChar::IsSupplementary(chCode)) |
0 | 1671 |
{ |
1672 |
candidate[KChPos] = (TUint16)chCode; |
|
1673 |
} |
|
1674 |
else |
|
1675 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1676 |
candidate[KChPos] = TChar::GetHighSurrogate(chCode); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1677 |
candidate[KChPos+1] = TChar::GetLowSurrogate(chCode); |
0 | 1678 |
} |
1679 |
//"Character decomposition mapping" is the 5th field, starting from 0. |
|
1680 |
TPtrC8 decomp(GetUnicodeDataField(stmt, 5)); |
|
1681 |
if(decomp.Length() > 1 && decomp[0] != '<') |
|
1682 |
{ |
|
1683 |
//This character has valid decomposition mapping - test it. |
|
1684 |
//Construct the search string |
|
1685 |
FillStringL(searchTerm, decomp); |
|
1686 |
//Test |
|
1687 |
DoFindMatchSectionFoldedTest(candidate, searchTerm, KChPos); |
|
1688 |
} |
|
1689 |
//"Uppercase mapping" is the 12th field, starting from 0. |
|
1690 |
TPtrC8 upperc(GetUnicodeDataField(stmt, 12)); |
|
1691 |
if(upperc.Length() > 1) |
|
1692 |
{ |
|
1693 |
//This character has valid uppercase mapping - test it. |
|
1694 |
//Construct the search string |
|
1695 |
FillStringL(searchTerm, upperc); |
|
1696 |
//Test |
|
1697 |
DoFindMatchSectionFoldedTest(candidate, searchTerm, KChPos); |
|
1698 |
} |
|
1699 |
}//end of "while" - for each file statement |
|
1700 |
CleanupStack::PopAndDestroy(&unicodeTestDataFile); |
|
1701 |
} |
|
1702 |
||
1703 |
//MatchStringFolded test |
|
1704 |
void MatchStringFoldedTestL() |
|
1705 |
{ |
|
1706 |
TBuf16<3> candidate; |
|
1707 |
candidate.Copy(_L16("aa")); |
|
1708 |
TBuf16<10> searchTerm; |
|
1709 |
searchTerm.Copy(_L16("aaaaaaaaaa")); |
|
1710 |
const TInt KChPos = 1; |
|
1711 |
//Read and parse each line from the unicode data file. |
|
1712 |
RUnicodeTestDataFile unicodeTestDataFile; |
|
1713 |
unicodeTestDataFile.OpenLC(); |
|
1714 |
TPtrC8 stmt; |
|
1715 |
while(unicodeTestDataFile.NextStmt(stmt) && stmt.Length() > 0) |
|
1716 |
{ |
|
1717 |
//Get the character code |
|
1718 |
TUint32 chCode = GetChCodeL(stmt); |
|
1719 |
//"LATIN CAPITAL LETTER I WITH DOT ABOVE" - the searching algorithm does not work with it. |
|
1720 |
if(chCode == (TUint32)0x0130) |
|
1721 |
{ |
|
1722 |
continue; |
|
1723 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1724 |
if (!TChar::IsSupplementary(chCode)) |
0 | 1725 |
{ |
1726 |
candidate[KChPos] = (TUint16)chCode; |
|
1727 |
candidate.SetLength(2); |
|
1728 |
} |
|
1729 |
else |
|
1730 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1731 |
candidate[KChPos] = TChar::GetHighSurrogate(chCode); |
0 | 1732 |
candidate.SetLength(3); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1733 |
candidate[KChPos+1] = TChar::GetLowSurrogate(chCode); |
0 | 1734 |
} |
1735 |
//"Character decomposition mapping" is the 5th field, starting from 0. |
|
1736 |
TPtrC8 decomp(GetUnicodeDataField(stmt, 5)); |
|
1737 |
if(decomp.Length() > 1 && decomp[0] != '<') |
|
1738 |
{ |
|
1739 |
//This character has valid decomposition mapping - test it. |
|
1740 |
//Construct the search string |
|
1741 |
FillStringL(searchTerm, decomp); |
|
1742 |
//Test |
|
1743 |
test(MatchStringFolded(candidate.Ptr(), candidate.Ptr() + candidate.Length(), |
|
1744 |
searchTerm.Ptr(), searchTerm.Ptr() + searchTerm.Length())); |
|
1745 |
} |
|
1746 |
//"Uppercase mapping" is the 12th field, starting from 0. |
|
1747 |
TPtrC8 upperc(GetUnicodeDataField(stmt, 12)); |
|
1748 |
if(upperc.Length() > 1) |
|
1749 |
{ |
|
1750 |
//This character has valid uppercase mapping - test it. |
|
1751 |
//Construct the search string |
|
1752 |
FillStringL(searchTerm, upperc); |
|
1753 |
//Test |
|
1754 |
test(MatchStringFolded(candidate.Ptr(), candidate.Ptr() + candidate.Length(), |
|
1755 |
searchTerm.Ptr(), searchTerm.Ptr() + searchTerm.Length())); |
|
1756 |
} |
|
1757 |
}//end of "while" - for each file statement |
|
1758 |
CleanupStack::PopAndDestroy(&unicodeTestDataFile); |
|
1759 |
} |
|
1760 |
||
1761 |
void FindMatchSectionFoldedTestL() |
|
1762 |
{ |
|
1763 |
FindMatchSectionFoldedTestSimple(); |
|
1764 |
FindMatchSectionFoldedTestComplexL(); |
|
1765 |
} |
|
1766 |
||
1767 |
void TestFindMatchFoldedL() |
|
1768 |
{ |
|
1769 |
MatchSectionFoldedTest(); |
|
1770 |
FindMatchSectionFoldedTestL(); |
|
1771 |
MatchStringFoldedTestL(); |
|
1772 |
} |
|
1773 |
||
1774 |
void TestCompareFoldedEqual(const TDesC& a, const TDesC& b) |
|
1775 |
{ |
|
1776 |
test(a.CompareF(b) == 0); |
|
1777 |
test(b.CompareF(a) == 0); |
|
1778 |
} |
|
1779 |
||
1780 |
void TestCompareFolded() |
|
1781 |
{ |
|
1782 |
// Latin Extended A |
|
1783 |
TestCompareFoldedEqual(_L("\x100"), _L("\x101")); |
|
1784 |
TestCompareFoldedEqual(_L("\x100"), _L("A\x304")); |
|
1785 |
TestCompareFoldedEqual(_L("\x100"), _L("a\x304")); |
|
1786 |
TestCompareFoldedEqual(_L("\x104"), _L("\x105")); |
|
1787 |
TestCompareFoldedEqual(_L("\x104"), _L("a\x328")); |
|
1788 |
TestCompareFoldedEqual(_L("\x107"), _L("C\x301")); |
|
1789 |
TestCompareFoldedEqual(_L("\x10F"), _L("\x10E")); |
|
1790 |
TestCompareFoldedEqual(_L("\x10F"), _L("D\x30C")); |
|
1791 |
TestCompareFoldedEqual(_L("\x110"), _L("\x111")); |
|
1792 |
TestCompareFoldedEqual(_L("\x123"), _L("G\x327")); |
|
1793 |
TestCompareFoldedEqual(_L("\x132"), _L("\x133")); |
|
1794 |
TestCompareFoldedEqual(_L("\x131"), _L("i")); |
|
1795 |
TestCompareFoldedEqual(_L("\x131"), _L("I")); |
|
1796 |
TestCompareFoldedEqual(_L("i"), _L("I")); |
|
1797 |
TestCompareFoldedEqual(_L("\x13F"), _L("\x140")); |
|
1798 |
TestCompareFoldedEqual(_L("\x141"), _L("\x142")); |
|
1799 |
TestCompareFoldedEqual(_L("\x14A"), _L("\x14B")); |
|
1800 |
TestCompareFoldedEqual(_L("\x150"), _L("\x151")); |
|
1801 |
TestCompareFoldedEqual(_L("\x150"), _L("o\x30B")); |
|
1802 |
TestCompareFoldedEqual(_L("\x152"), _L("\x153")); |
|
1803 |
TestCompareFoldedEqual(_L("\x17D"), _L("\x17E")); |
|
1804 |
TestCompareFoldedEqual(_L("\x17D"), _L("z\x30C")); |
|
1805 |
// Latin Extended B |
|
1806 |
TestCompareFoldedEqual(_L("\x182"), _L("\x183")); |
|
1807 |
TestCompareFoldedEqual(_L("\x184"), _L("\x185")); |
|
1808 |
TestCompareFoldedEqual(_L("\x187"), _L("\x188")); |
|
1809 |
TestCompareFoldedEqual(_L("\x18A"), _L("\x257")); |
|
1810 |
TestCompareFoldedEqual(_L("\x194"), _L("\x263")); |
|
1811 |
TestCompareFoldedEqual(_L("\x195"), _L("\x1F6")); |
|
1812 |
TestCompareFoldedEqual(_L("\x196"), _L("\x269")); |
|
1813 |
TestCompareFoldedEqual(_L("\x1A2"), _L("\x1A3")); |
|
1814 |
TestCompareFoldedEqual(_L("\x1A6"), _L("\x280")); |
|
1815 |
TestCompareFoldedEqual(_L("\x1BF"), _L("\x1F7")); |
|
1816 |
TestCompareFoldedEqual(_L("\x1DC"), _L("\x1DB")); |
|
1817 |
TestCompareFoldedEqual(_L("\x1DC"), _L("u\x308\x300")); |
|
1818 |
TestCompareFoldedEqual(_L("\x1DD"), _L("\x18E")); |
|
1819 |
TestCompareFoldedEqual(_L("\x1EC"), _L("\x1ED")); |
|
1820 |
TestCompareFoldedEqual(_L("\x1FC"), _L("\x1FD")); |
|
1821 |
TestCompareFoldedEqual(_L("\x200"), _L("\x201")); |
|
1822 |
TestCompareFoldedEqual(_L("\x216"), _L("u\x311")); |
|
1823 |
TestCompareFoldedEqual(_L("\x21B"), _L("T\x326")); |
|
1824 |
TestCompareFoldedEqual(_L("\x21C"), _L("\x21D")); |
|
1825 |
TestCompareFoldedEqual(_L("\x229"), _L("E\x327")); |
|
1826 |
TestCompareFoldedEqual(_L("\x22A"), _L("\x22B")); |
|
1827 |
TestCompareFoldedEqual(_L("\x22A"), _L("O\x308\x304")); |
|
1828 |
TestCompareFoldedEqual(_L("\x22A"), _L("\xF6\x304")); |
|
1829 |
TestCompareFoldedEqual(_L("\x233"), _L("y\x304")); |
|
1830 |
TestCompareFoldedEqual(_L("\x233"), _L("\x232")); |
|
1831 |
} |
|
1832 |
||
1833 |
void TestCompareFoldedNotEqual(TDesC& a, TDesC& b, TInt aValue) |
|
1834 |
{ |
|
1835 |
test(a.CompareF(b) == aValue); |
|
1836 |
} |
|
1837 |
||
1838 |
static void TestCompareFoldedAdditional() |
|
1839 |
{ |
|
1840 |
const TText16 UnicodeTextOne16[] = {'a', 0}; |
|
1841 |
const TText16 ErrUnicodeTextOne16[] = {'[', 0}; |
|
1842 |
||
1843 |
const TText16 UnicodeTextTwo16[] = {0x00EA, 0x0323, 0}; |
|
1844 |
const TText16 ErrUnicodeTextTwo16[] = {0x00EA, 't', 0}; |
|
1845 |
||
1846 |
const TText16 UnicodeTextThree16[] = {0x00EA, 0x03B1, 0}; |
|
1847 |
const TText16 ErrUnicodeTextThree16[] = {0x00EA, 0x0323, 0}; |
|
1848 |
||
1849 |
TBufC16<ARRAY_SIZE(UnicodeTextOne16) - 1> oriUnicodeSmallTextOne(UnicodeTextOne16); |
|
1850 |
TBufC16<ARRAY_SIZE(ErrUnicodeTextOne16) - 1> nonMatchUnicodeSmallTextOne(ErrUnicodeTextOne16); |
|
1851 |
||
1852 |
TBufC16<ARRAY_SIZE(UnicodeTextTwo16) - 1> oriUnicodeSmallTextTwo(UnicodeTextTwo16); |
|
1853 |
TBufC16<ARRAY_SIZE(ErrUnicodeTextTwo16) - 1> nonMatchUnicodeSmallTextTwo(ErrUnicodeTextTwo16); |
|
1854 |
||
1855 |
TBufC16<ARRAY_SIZE(UnicodeTextThree16) - 1> oriUnicodeSmallTextThree(UnicodeTextThree16); |
|
1856 |
TBufC16<ARRAY_SIZE(ErrUnicodeTextThree16) - 1> nonMatchUnicodeSmallTextThree(ErrUnicodeTextThree16); |
|
1857 |
||
1858 |
const TText16 AsciiText16[] = {'A', 'B', 'C', 'D', 'E', 0}; |
|
1859 |
||
1860 |
TBufC16<5> oriAsciiSmallText(_L("ABCDE")); |
|
1861 |
||
1862 |
// Check that characters are non matching with return value as stated |
|
1863 |
||
1864 |
TestCompareFoldedNotEqual(oriUnicodeSmallTextOne, nonMatchUnicodeSmallTextOne, 6); |
|
1865 |
TestCompareFoldedNotEqual(oriUnicodeSmallTextTwo, nonMatchUnicodeSmallTextTwo, 33); |
|
1866 |
TestCompareFoldedNotEqual(oriUnicodeSmallTextThree, nonMatchUnicodeSmallTextThree, -33); |
|
1867 |
||
1868 |
// Try other way around... |
|
1869 |
||
1870 |
TestCompareFoldedNotEqual(nonMatchUnicodeSmallTextOne, oriUnicodeSmallTextOne, -6); |
|
1871 |
TestCompareFoldedNotEqual(nonMatchUnicodeSmallTextTwo, oriUnicodeSmallTextTwo, -33); |
|
1872 |
TestCompareFoldedNotEqual(nonMatchUnicodeSmallTextThree, oriUnicodeSmallTextThree, 33); |
|
1873 |
||
1874 |
// Declare a TPtrC16 which is base from AsciiText16... |
|
1875 |
||
1876 |
TPtrC16 AsciiSmallText; |
|
1877 |
||
1878 |
AsciiSmallText.Set(AsciiText16, 4); |
|
1879 |
||
1880 |
// Check the boundary case |
|
1881 |
||
1882 |
TestCompareFoldedNotEqual(oriAsciiSmallText, AsciiSmallText, 1); |
|
1883 |
||
1884 |
// Try other way around... |
|
1885 |
||
1886 |
TestCompareFoldedNotEqual(AsciiSmallText, oriAsciiSmallText, -1); |
|
1887 |
||
1888 |
} |
|
1889 |
||
1890 |
void TestFoldingL() |
|
1891 |
{ |
|
1892 |
TestFindMatchFoldedL(); |
|
1893 |
TestCompareFolded(); |
|
1894 |
TestCompareFoldedAdditional(); |
|
1895 |
} |
|
1896 |
||
1897 |
// collation tests |
|
1898 |
_LIT(KCandidateString1, "abcdefg"); |
|
1899 |
_LIT(KCandidateString2, "\x1f82\x1f02\x345\x1f00\x300\x345\x3b1\x313\x300\x345"); |
|
1900 |
_LIT(KCandidateString3, "abcabcdababc"); |
|
1901 |
_LIT(KCandidateString4, "xyzxyxyzxyxyyxyzxyy"); |
|
1902 |
||
1903 |
_LIT(KMatch1, "abc"); |
|
1904 |
_LIT(KMatch2, "abc*"); |
|
1905 |
_LIT(KMatch3, "*abc*"); |
|
1906 |
_LIT(KMatch4, "abc*def"); |
|
1907 |
_LIT(KMatch5, "abc*def*g*"); |
|
1908 |
_LIT(KMatch6, "*def"); |
|
1909 |
_LIT(KMatch7, "**d?f?"); |
|
1910 |
_LIT(KMatch8, "*d?f??"); |
|
1911 |
_LIT(KMatch9, "***d?f??*"); |
|
1912 |
_LIT(KMatch10, "a*c*g"); |
|
1913 |
_LIT(KMatch11, "*c*g"); |
|
1914 |
||
1915 |
_LIT(KMatch12, "*\x1f82"); |
|
1916 |
_LIT(KMatch13, "*\x1f82*"); |
|
1917 |
//_LIT(KMatch14, "*\x3b1*"); |
|
1918 |
_LIT(KMatch15, "*\x313*"); |
|
1919 |
_LIT(KMatch16, "*\x300*"); |
|
1920 |
//_LIT(KMatch17, "*\x345*"); |
|
1921 |
//_LIT(KMatch18, "*\x3b1\x313*"); |
|
1922 |
//_LIT(KMatch19, "*\x3b1\x313\x300*"); |
|
1923 |
_LIT(KMatch20, "*\x1f82*\x1f82*\x1f82\x1f82"); |
|
1924 |
_LIT(KMatch21, "*\x1f82*\x1f82*\x1f82\x1f82*\x1f82*"); |
|
1925 |
||
1926 |
_LIT(KMatch22, "*aba*"); |
|
1927 |
_LIT(KMatch23, "*abc"); |
|
1928 |
_LIT(KMatch24, "a*abc"); |
|
1929 |
_LIT(KMatch25, "a*ab"); |
|
1930 |
_LIT(KMatch26, "*ca*abc"); |
|
1931 |
_LIT(KMatch27, "*ca*??c"); |
|
1932 |
_LIT(KMatch28, "*??c"); |
|
1933 |
_LIT(KMatch29, "a*babc"); |
|
1934 |
_LIT(KMatch30, "*xyy"); |
|
1935 |
||
1936 |
_LIT(KFoo1, "foo"); |
|
1937 |
_LIT(KPeach, "pe\x302\x63he"); |
|
1938 |
_LIT(KFooMatch1, "fo*"); |
|
1939 |
_LIT(KFooMatch2, "*Fo*"); |
|
1940 |
_LIT(KFooMatch3, "*f*O*o"); |
|
1941 |
_LIT(KFooMatch4, "*f*o*o*"); |
|
1942 |
_LIT(KFooMatch5, "*o"); |
|
1943 |
_LIT(KFooMatch6, "???"); |
|
1944 |
_LIT(KFooMatch7, "*?o?*"); |
|
1945 |
_LIT(KFooMatch8, "*?"); |
|
1946 |
_LIT(KFooNonMatch1, "oo*"); |
|
1947 |
_LIT(KFooNonMatch2, "??"); |
|
1948 |
_LIT(KFooNonMatch3, "????"); |
|
1949 |
_LIT(KFooNonMatch4, "*?f*"); |
|
1950 |
_LIT(KFooNonMatch5, "*f*f*"); |
|
1951 |
_LIT(KFooNonMatch6, "*?*f*"); |
|
1952 |
_LIT(KPeachMatch1, "p?che"); |
|
1953 |
_LIT(KPeachNonMatch1, "peche"); |
|
1954 |
_LIT(KPeachNonMatch2, "pe?che"); |
|
1955 |
_LIT(KPeachNonMatch3, "pe?he"); |
|
1956 |
_LIT(KPeachNonMatch4, "pe*"); |
|
1957 |
||
1958 |
void TestMatchIdentifiersTDesC(const TDesC& aCandidate, const TDesC& aSearchTerm, TInt aExpectedResult) |
|
1959 |
{ |
|
1960 |
const TText16* candidateStart = aCandidate.Ptr(); |
|
1961 |
const TText16* candidateEnd = candidateStart + aCandidate.Length(); |
|
1962 |
const TText16* searchTermStart = aSearchTerm.Ptr(); |
|
1963 |
const TText16* searchTermEnd = searchTermStart + aSearchTerm.Length(); |
|
1964 |
TInt pos = ::LocateMatchStringFolded(candidateStart, candidateEnd, searchTermStart, searchTermEnd); |
|
1965 |
test(aExpectedResult == pos); |
|
1966 |
} |
|
1967 |
||
1968 |
void TestMatchIdentifiers() |
|
1969 |
{ |
|
1970 |
TestMatchIdentifiersTDesC(KCandidateString1, KMatch1, KErrNotFound); |
|
1971 |
TestMatchIdentifiersTDesC(KCandidateString1, KMatch2, 0); |
|
1972 |
TestMatchIdentifiersTDesC(KCandidateString1, KMatch3, 0); |
|
1973 |
TestMatchIdentifiersTDesC(KCandidateString1, KMatch4, KErrNotFound); |
|
1974 |
TestMatchIdentifiersTDesC(KCandidateString1, KMatch5, 0); |
|
1975 |
TestMatchIdentifiersTDesC(KCandidateString1, KMatch6, KErrNotFound); |
|
1976 |
TestMatchIdentifiersTDesC(KCandidateString1, KMatch7, 3); |
|
1977 |
TestMatchIdentifiersTDesC(KCandidateString1, KMatch8, KErrNotFound); |
|
1978 |
TestMatchIdentifiersTDesC(KCandidateString1, KMatch9, KErrNotFound); |
|
1979 |
TestMatchIdentifiersTDesC(KCandidateString1, KMatch10, 0); |
|
1980 |
TestMatchIdentifiersTDesC(KCandidateString1, KMatch11, 2); |
|
1981 |
TestMatchIdentifiersTDesC(KCandidateString2, KMatch12, 6); |
|
1982 |
TestMatchIdentifiersTDesC(KCandidateString2, KMatch13, 0); |
|
1983 |
//The next test does not pass with the new optimised methods |
|
1984 |
//TestMatchIdentifiersTDesC(KCandidateString2, KMatch14, KErrNotFound); |
|
1985 |
TestMatchIdentifiersTDesC(KCandidateString2, KMatch15, KErrNotFound); |
|
1986 |
TestMatchIdentifiersTDesC(KCandidateString2, KMatch16, KErrNotFound); |
|
1987 |
// I have taken this test out: it tests that combining ypogegrammeni is not |
|
1988 |
// found on its own: but with case folding it can become a non-combining |
|
1989 |
// character (iota), so this test is not relevant. |
|
1990 |
// TestMatchIdentifiersTDesC(KCandidateString2, KMatch17, KErrNotFound); |
|
1991 |
//The next tests do not pass with the new optimised methods |
|
1992 |
//TestMatchIdentifiersTDesC(KCandidateString2, KMatch18, KErrNotFound); |
|
1993 |
//TestMatchIdentifiersTDesC(KCandidateString2, KMatch19, KErrNotFound); |
|
1994 |
TestMatchIdentifiersTDesC(KCandidateString2, KMatch20, 0); |
|
1995 |
TestMatchIdentifiersTDesC(KCandidateString2, KMatch21, KErrNotFound); |
|
1996 |
TestMatchIdentifiersTDesC(KCandidateString3, KMatch22, 7); |
|
1997 |
TestMatchIdentifiersTDesC(KCandidateString3, KMatch23, 9); |
|
1998 |
TestMatchIdentifiersTDesC(KCandidateString3, KMatch24, 0); |
|
1999 |
TestMatchIdentifiersTDesC(KCandidateString3, KMatch25, KErrNotFound); |
|
2000 |
TestMatchIdentifiersTDesC(KCandidateString3, KMatch26, 2); |
|
2001 |
TestMatchIdentifiersTDesC(KCandidateString3, KMatch27, 2); |
|
2002 |
TestMatchIdentifiersTDesC(KCandidateString3, KMatch28, 9); |
|
2003 |
TestMatchIdentifiersTDesC(KCandidateString3, KMatch29, 0); |
|
2004 |
TestMatchIdentifiersTDesC(KCandidateString4, KMatch30, 16); |
|
2005 |
||
2006 |
TestMatchIdentifiersTDesC(KFoo1, KFoo1, 0); |
|
2007 |
TestMatchIdentifiersTDesC(KFoo1, KFooMatch1, 0); |
|
2008 |
TestMatchIdentifiersTDesC(KFoo1, KFooMatch2, 0); |
|
2009 |
TestMatchIdentifiersTDesC(KFoo1, KFooMatch3, 0); |
|
2010 |
TestMatchIdentifiersTDesC(KFoo1, KFooMatch4, 0); |
|
2011 |
TestMatchIdentifiersTDesC(KFoo1, KFooMatch5, 2); |
|
2012 |
TestMatchIdentifiersTDesC(KFoo1, KFooMatch6, 0); |
|
2013 |
TestMatchIdentifiersTDesC(KFoo1, KFooMatch7, 0); |
|
2014 |
TestMatchIdentifiersTDesC(KFoo1, KFooMatch8, 2); |
|
2015 |
TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch1, KErrNotFound); |
|
2016 |
TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch2, KErrNotFound); |
|
2017 |
TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch3, KErrNotFound); |
|
2018 |
TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch4, KErrNotFound); |
|
2019 |
TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch5, KErrNotFound); |
|
2020 |
TestMatchIdentifiersTDesC(KFoo1, KFooNonMatch6, KErrNotFound); |
|
2021 |
TestMatchIdentifiersTDesC(KPeach, KPeachMatch1, 0); |
|
2022 |
TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch1, KErrNotFound); |
|
2023 |
TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch2, KErrNotFound); |
|
2024 |
TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch3, KErrNotFound); |
|
2025 |
TestMatchIdentifiersTDesC(KPeach, KPeachNonMatch4, KErrNotFound); |
|
2026 |
||
2027 |
TestMatchIdentifiersTDesC(_L(""), _L(""), 0); |
|
2028 |
TestMatchIdentifiersTDesC(_L("a"), _L(""), KErrNotFound); |
|
2029 |
TestMatchIdentifiersTDesC(_L(""), _L("*"), 0); |
|
2030 |
} |
|
2031 |
||
2032 |
void TestFindIdentifierTDesC(const TDesC& aCandidateString, const TDesC& aSearchTerm, TInt /*aExpectedResult*/) |
|
2033 |
{ |
|
2034 |
TUTF32Iterator candidateIt(aCandidateString.Ptr(), aCandidateString.Ptr() + aCandidateString.Length()); |
|
2035 |
TUTF32Iterator searchIt(aSearchTerm.Ptr(), aSearchTerm.Ptr() + aSearchTerm.Length()); |
|
2036 |
/*aExpectedResult = */::FindFolded(candidateIt, searchIt); |
|
2037 |
} |
|
2038 |
||
2039 |
//INC057641 - NTT Functional BC break in 8.1a: string comparison changed |
|
2040 |
static void INC057641L() |
|
2041 |
{ |
|
2042 |
_LIT16(KEmptyText, ""); |
|
2043 |
HBufC16* str = HBufC16::NewLC(4); |
|
2044 |
str->Des().Copy(_L("****")); |
|
2045 |
TInt res = str->CompareC(KEmptyText); |
|
2046 |
CleanupStack::PopAndDestroy(str); |
|
2047 |
test(res == 1); |
|
2048 |
} |
|
2049 |
||
2050 |
_LIT(KFind1, "abc"); |
|
2051 |
_LIT(KFind2, "def"); |
|
2052 |
_LIT(KFind3, "efg"); |
|
2053 |
_LIT(KFind4, "fga"); |
|
2054 |
_LIT(KFind5, "acd"); |
|
2055 |
_LIT(KFind6, "\x1f82"); |
|
2056 |
_LIT(KFind7, "\x3b1\x313\x300\x345"); |
|
2057 |
_LIT(KFind8, "\x3b1"); |
|
2058 |
_LIT(KFind9, "aba"); |
|
2059 |
_LIT(KFind10, "abc"); |
|
2060 |
||
2061 |
void TestFindIdentifier() |
|
2062 |
{ |
|
2063 |
TestFindIdentifierTDesC(KCandidateString1, TPtrC(), 0); |
|
2064 |
TestFindIdentifierTDesC(KCandidateString1, KFind1, 0); |
|
2065 |
TestFindIdentifierTDesC(KCandidateString1, KFind2, 3); |
|
2066 |
TestFindIdentifierTDesC(KCandidateString1, KFind3, 4); |
|
2067 |
TestFindIdentifierTDesC(KCandidateString1, KFind4, KErrNotFound); |
|
2068 |
TestFindIdentifierTDesC(KCandidateString1, KFind5, KErrNotFound); |
|
2069 |
TestFindIdentifierTDesC(KCandidateString2, KFind6, 0); |
|
2070 |
TestFindIdentifierTDesC(KCandidateString2, KFind7, 0); |
|
2071 |
TestFindIdentifierTDesC(KCandidateString2, KFind8, KErrNotFound); |
|
2072 |
TestFindIdentifierTDesC(KCandidateString3, KFind9, 7); |
|
2073 |
TestFindIdentifierTDesC(KCandidateString3, KFind10, 0); |
|
2074 |
} |
|
2075 |
||
2076 |
struct TestMatch8 |
|
2077 |
{ |
|
2078 |
TText8 const* iLeft; |
|
2079 |
TText8 const* iRight; |
|
2080 |
TInt iResult; |
|
2081 |
}; |
|
2082 |
||
2083 |
TestMatch8 const Tests8[]= |
|
2084 |
{ |
|
2085 |
{_S8(""),_S8(""),0}, |
|
2086 |
{_S8(""),_S8("?"),KErrNotFound}, |
|
2087 |
{_S8(""),_S8("*"),0}, |
|
2088 |
{_S8(""),_S8("**"),0}, |
|
2089 |
{_S8(""),_S8("*x*"),KErrNotFound}, |
|
2090 |
{_S8("x"),_S8(""),KErrNotFound}, |
|
2091 |
{_S8("x"),_S8("?"),0}, |
|
2092 |
{_S8("x"),_S8("*"),0}, |
|
2093 |
{_S8("x"),_S8("**"),0}, |
|
2094 |
{_S8("x"),_S8("**?"),0}, |
|
2095 |
{_S8("x"),_S8("?**"),0}, |
|
2096 |
{_S8("x"),_S8("**?*"),0}, |
|
2097 |
{_S8("x"),_S8("x"),0}, |
|
2098 |
{_S8("x"),_S8("a"),KErrNotFound}, |
|
2099 |
{_S8("x"),_S8("xx"),KErrNotFound}, |
|
2100 |
{_S8("x"),_S8("?x"),KErrNotFound}, |
|
2101 |
{_S8("x"),_S8("x*"),0}, |
|
2102 |
{_S8("x"),_S8("*x"),0}, |
|
2103 |
{_S8("x"),_S8("*x*"),0}, |
|
2104 |
{_S8("x"),_S8("**x*"),0}, |
|
2105 |
{_S8("abc"),_S8(""),KErrNotFound}, |
|
2106 |
{_S8("abc"),_S8("?*"),0}, |
|
2107 |
{_S8("abc"),_S8("*?"),2}, |
|
2108 |
{_S8("abc"),_S8("*?*?"),0}, |
|
2109 |
{_S8("abc"),_S8("*a*"),0}, |
|
2110 |
{_S8("abc"),_S8("*b*"),1}, |
|
2111 |
{_S8("abc"),_S8("*c*"),2}, |
|
2112 |
{_S8("abc"),_S8("*a"),KErrNotFound}, |
|
2113 |
{_S8("abc"),_S8("*c"),2}, |
|
2114 |
{_S8("abc"),_S8("*?c"),1}, |
|
2115 |
{_S8("abc"),_S8("??c"),0}, |
|
2116 |
{_S8("abc"),_S8("*b?"),1}, |
|
2117 |
}; |
|
2118 |
||
2119 |
struct TestMatch16 |
|
2120 |
{ |
|
2121 |
TText16 const* iLeft; |
|
2122 |
TText16 const* iRight; |
|
2123 |
TInt iResult; |
|
2124 |
}; |
|
2125 |
||
2126 |
TestMatch16 const Tests16[]= |
|
2127 |
{ |
|
2128 |
{_S16(""),_S16(""),0}, |
|
2129 |
{_S16(""),_S16("?"),KErrNotFound}, |
|
2130 |
{_S16(""),_S16("*"),0}, |
|
2131 |
{_S16(""),_S16("**"),0}, |
|
2132 |
{_S16(""),_S16("*x*"),KErrNotFound}, |
|
2133 |
{_S16("x"),_S16(""),KErrNotFound}, |
|
2134 |
{_S16("x"),_S16("?"),0}, |
|
2135 |
{_S16("x"),_S16("*"),0}, |
|
2136 |
{_S16("x"),_S16("**"),0}, |
|
2137 |
{_S16("x"),_S16("**?"),0}, |
|
2138 |
{_S16("x"),_S16("?**"),0}, |
|
2139 |
{_S16("x"),_S16("**?*"),0}, |
|
2140 |
{_S16("x"),_S16("x"),0}, |
|
2141 |
{_S16("x"),_S16("a"),KErrNotFound}, |
|
2142 |
{_S16("x"),_S16("xx"),KErrNotFound}, |
|
2143 |
{_S16("x"),_S16("?x"),KErrNotFound}, |
|
2144 |
{_S16("x"),_S16("x*"),0}, |
|
2145 |
{_S16("x"),_S16("*x"),0}, |
|
2146 |
{_S16("x"),_S16("*x*"),0}, |
|
2147 |
{_S16("x"),_S16("**x*"),0}, |
|
2148 |
{_S16("abc"),_S16(""),KErrNotFound}, |
|
2149 |
{_S16("abc"),_S16("?*"),0}, |
|
2150 |
{_S16("abc"),_S16("*?"),2}, |
|
2151 |
{_S16("abc"),_S16("*?*?"),0}, |
|
2152 |
{_S16("abc"),_S16("*a*"),0}, |
|
2153 |
{_S16("abc"),_S16("*b*"),1}, |
|
2154 |
{_S16("abc"),_S16("*c*"),2}, |
|
2155 |
{_S16("abc"),_S16("*a"),KErrNotFound}, |
|
2156 |
{_S16("abc"),_S16("*c"),2}, |
|
2157 |
{_S16("abc"),_S16("*?c"),1}, |
|
2158 |
{_S16("abc"),_S16("??c"),0}, |
|
2159 |
{_S16("abc"),_S16("*b?"),1}, |
|
2160 |
{_S16("\x0100"),_S16("\x0100"),0}, |
|
2161 |
{_S16("\x0100"),_S16("*"),0}, |
|
2162 |
{_S16("\x0100"),_S16("?"),0}, |
|
2163 |
{_S16("\x0100"),_S16("*\x0100"),0}, |
|
2164 |
{_S16("\x0100"),_S16("*\x0100?"),KErrNotFound}, |
|
2165 |
{_S16("\x0101"),_S16("\x0101"),0}, |
|
2166 |
{_S16("\x0101"),_S16("*"),0}, |
|
2167 |
{_S16("\x0101"),_S16("?"),0}, |
|
2168 |
{_S16("\x0101"),_S16("*\x0101"),0}, |
|
2169 |
{_S16("\x0101"),_S16("*\x0101?"),KErrNotFound}, |
|
2170 |
{_S16("\x0ffe"),_S16("\x0ffe"),0}, |
|
2171 |
{_S16("\x0ffe"),_S16("*"),0}, |
|
2172 |
{_S16("\x0ffe"),_S16("?"),0}, |
|
2173 |
{_S16("\x0ffe"),_S16("*\x0ffe"),0}, |
|
2174 |
{_S16("\x0ffe"),_S16("*\x0ffe?"),KErrNotFound}, |
|
2175 |
{_S16("\x0fff"),_S16("\x0fff"),0}, |
|
2176 |
{_S16("\x0fff"),_S16("*"),0}, |
|
2177 |
{_S16("\x0fff"),_S16("?"),0}, |
|
2178 |
{_S16("\x0fff"),_S16("*\x0fff"),0}, |
|
2179 |
{_S16("\x0fff"),_S16("*\x0fff?"),KErrNotFound}, |
|
2180 |
{_S16("\x1000"),_S16("\x1000"),0}, |
|
2181 |
{_S16("\x1000"),_S16("*"),0}, |
|
2182 |
{_S16("\x1000"),_S16("?"),0}, |
|
2183 |
{_S16("\x1000"),_S16("*\x1000"),0}, |
|
2184 |
{_S16("\x1000"),_S16("*\x1000?"),KErrNotFound}, |
|
2185 |
{_S16("\x1001"),_S16("\x1001"),0}, |
|
2186 |
{_S16("\x1001"),_S16("*"),0}, |
|
2187 |
{_S16("\x1001"),_S16("?"),0}, |
|
2188 |
{_S16("\x1001"),_S16("*\x1001"),0}, |
|
2189 |
{_S16("\x1001"),_S16("*\x1001?"),KErrNotFound}, |
|
2190 |
// fffe, ffff is special |
|
2191 |
//{_S16("\xfffe"),_S16("\xfffe"),0}, |
|
2192 |
//{_S16("\xfffe"),_S16("*"),0}, |
|
2193 |
//{_S16("\xfffe"),_S16("?"),0}, |
|
2194 |
//{_S16("\xfffe"),_S16("*\xfffe"),0}, //reserved |
|
2195 |
//{_S16("\xfffe"),_S16("*\xfffe?"),KErrNotFound}, |
|
2196 |
//{_S16("\xffff"),_S16("\xffff"),0}, |
|
2197 |
//{_S16("\xffff"),_S16("*"),0}, |
|
2198 |
//{_S16("\xffff"),_S16("?"),0}, |
|
2199 |
//{_S16("\xffff"),_S16("*\xffff?"),KErrNotFound}, |
|
2200 |
//{_S16("\x0101\xffff\x0ffe"),_S16("*\xffff"),0}, |
|
2201 |
//{_S16("\x0101\xffff\x0ffe"),_S16("*\xffff"),0}, |
|
2202 |
//{_S16("\x0101\xfffe\x0ffe"),_S16("\xffff?"),0}, |
|
2203 |
//{_S16("\x0101\xfffe\x0ffe"),_S16("*\xffff?"),0}, |
|
2204 |
{_S16("\x04fa"),_S16("*"),0}, |
|
2205 |
}; |
|
2206 |
||
2207 |
TInt KTests=sizeof(Tests8)/sizeof(Tests8[0]); |
|
2208 |
TInt KTests16=sizeof(Tests16)/sizeof(Tests16[0]); |
|
2209 |
||
2210 |
TestMatch16 const TestsSurrogate[]= |
|
2211 |
{ |
|
2212 |
// not duplicate, test MatchSurrogate here |
|
2213 |
{_S16(""),_S16(""),0}, |
|
2214 |
{_S16(""),_S16("?"),KErrNotFound}, |
|
2215 |
{_S16(""),_S16("*"),0}, |
|
2216 |
{_S16(""),_S16("**"),0}, |
|
2217 |
{_S16(""),_S16("*x*"),KErrNotFound}, |
|
2218 |
{_S16("x"),_S16(""),KErrNotFound}, |
|
2219 |
{_S16("x"),_S16("?"),0}, |
|
2220 |
{_S16("x"),_S16("*"),0}, |
|
2221 |
{_S16("x"),_S16("**"),0}, |
|
2222 |
{_S16("x"),_S16("**?"),0}, |
|
2223 |
{_S16("x"),_S16("?**"),0}, // 10 |
|
2224 |
{_S16("x"),_S16("**?*"),0}, |
|
2225 |
{_S16("x"),_S16("x"),0}, |
|
2226 |
{_S16("x"),_S16("a"),KErrNotFound}, |
|
2227 |
{_S16("x"),_S16("xx"),KErrNotFound}, |
|
2228 |
{_S16("x"),_S16("?x"),KErrNotFound}, |
|
2229 |
{_S16("x"),_S16("x*"),0}, |
|
2230 |
{_S16("x"),_S16("*x"),0}, |
|
2231 |
{_S16("x"),_S16("*x*"),0}, |
|
2232 |
{_S16("x"),_S16("**x*"),0}, |
|
2233 |
{_S16("abc"),_S16(""),KErrNotFound}, // 20 |
|
2234 |
{_S16("abc"),_S16("?*"),0}, |
|
2235 |
{_S16("abc"),_S16("*?"),2}, |
|
2236 |
{_S16("abc"),_S16("*?*?"),0}, |
|
2237 |
{_S16("abc"),_S16("*a*"),0}, |
|
2238 |
{_S16("abc"),_S16("*b*"),1}, |
|
2239 |
{_S16("abc"),_S16("*c*"),2}, |
|
2240 |
{_S16("abc"),_S16("*a"),KErrNotFound}, |
|
2241 |
{_S16("abc"),_S16("*c"),2}, |
|
2242 |
{_S16("abc"),_S16("*?c"),1}, |
|
2243 |
{_S16("abc"),_S16("??c"),0}, // 30 |
|
2244 |
{_S16("abc"),_S16("*b?"),1}, |
|
2245 |
||
2246 |
// ones containing supplementary characters |
|
2247 |
{_S16("ab\xD840\xDDAD"),_S16("*b*"),1}, |
|
2248 |
{_S16("ab\xD840\xDDAD"),_S16("*b?"),1}, |
|
2249 |
{_S16("a\xD840\xDDAD\x0063"),_S16("*c*"),3}, |
|
2250 |
{_S16("a\xD840\xDDAD\x0063"),_S16("*\xD840\xDDAD*"),1}, |
|
2251 |
{_S16("a\xD840\xDDAB\xD830\xDDAC\xD840\xDDAC\x0063"),_S16("*\xD840\xDDAC*"),5}, |
|
2252 |
{_S16("\xD840\xDDAB\xD840\xDDAC\x0063"),_S16("?\xD840\xDDAC*"),0}, |
|
2253 |
{_S16("\xD840\xDDAB\xD840\xDDAC\x0063"),_S16("\xD840\xDDAB*"),0}, |
|
2254 |
{_S16("\xD840\xDDAB\xD840\xDDAC\x0063"),_S16("*?\xD840\xDDAC*"),0}, |
|
2255 |
{_S16("\xD840\xDDAB\xD840\xDDAC\xD840\xDDAD\x0063"),_S16("*?\xD840\xDDAD*"),2}, // 40 |
|
2256 |
}; |
|
2257 |
||
2258 |
TInt KTestsSurrogate=sizeof(TestsSurrogate)/sizeof(TestsSurrogate[0]); |
|
2259 |
||
2260 |
||
2261 |
/** |
|
2262 |
@SYMTestCaseID SYSLIB-UNICODE-CT-1770 |
|
2263 |
@SYMTestCaseDesc TDes16 Collation conversion function test |
|
2264 |
@SYMTestPriority High |
|
2265 |
@SYMTestActions Testing the three collation conversion function |
|
2266 |
in TDesC16::GetNormalizedDecomposedFormL, |
|
2267 |
TDesC16::GetFoldedDecomposedFormL, |
|
2268 |
TDesC16::GetCollationKeysL |
|
2269 |
@SYMTestExpectedResults The test must not fail. |
|
2270 |
@SYMREQ 6178 Add several new Unicode utility functions |
|
2271 |
*/ |
|
2272 |
static void TestDes16CollationFunctionL() |
|
2273 |
{ |
|
2274 |
/**----------------Test TDesC16::GetNormalizedDecomposedFormL------------------*/ |
|
2275 |
||
2276 |
HBufC16* outputBuffer=NULL; |
|
2277 |
_LIT16(KTestString1,"abc") ; |
|
2278 |
//LATIN CAPITAL LETTER W WITH DIAERESIS(\x0057\x0308) |
|
2279 |
//LATIN SMALL LETTER A(\x0061) |
|
2280 |
//LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE(\x006F\x0302\x0303) |
|
2281 |
//GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI(\x03B1\x0313\x0342\x0345) |
|
2282 |
_LIT16(KTestString2,"\x1E84\x0061\x1ED7\x1F86"); |
|
2283 |
_LIT16(KTestStringNDF2,"\x0057\x0308\x0061\x006F\x0302\x0303\x03B1\x0313\x0342\x0345"); |
|
2284 |
||
2285 |
outputBuffer=KTestString1().GetNormalizedDecomposedFormL(); |
|
2286 |
test(outputBuffer->Compare(KTestString1())==0); |
|
2287 |
delete outputBuffer; |
|
2288 |
||
2289 |
outputBuffer=KTestString2().GetNormalizedDecomposedFormL(); |
|
2290 |
test(outputBuffer->Compare(KTestStringNDF2())==0); |
|
2291 |
delete outputBuffer; |
|
2292 |
||
2293 |
/**----------------Test TDesC16::GetFoldedDecomposedFormL------------------*/ |
|
2294 |
_LIT16(KTestString6,"AbC"); |
|
2295 |
_LIT16(KTestStringFolded6,"abc"); |
|
2296 |
//GREEK CAPITAL LETTER OMICRON WITH PSILI =>\x03BF\x0313 |
|
2297 |
//LATIN SMALL LETTER M WITH ACUTE =>\x006D\x0301 |
|
2298 |
//LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE => \x006F\x0302\x0309 |
|
2299 |
_LIT16(KTestString7,"\x1F48\x1E3F\x1ED4"); |
|
2300 |
_LIT16(KTestStringFolded7,"\x03BF\x0313\x006D\x0301\x006F\x0302\x0309"); |
|
2301 |
||
2302 |
outputBuffer=KTestString6().GetFoldedDecomposedFormL(); |
|
2303 |
test(outputBuffer->Compare(KTestStringFolded6())==0); |
|
2304 |
delete outputBuffer; |
|
2305 |
||
2306 |
outputBuffer=KTestString7().GetFoldedDecomposedFormL(); |
|
2307 |
test(outputBuffer->Compare(KTestStringFolded7())==0); |
|
2308 |
delete outputBuffer; |
|
2309 |
||
2310 |
/**----------------Test TDesC16::GetCollationKeysL------------------*/ |
|
2311 |
TCollationMethod method; |
|
2312 |
method.iId = 0; |
|
2313 |
//purposely set the maintable to NULL, this will result in the DefaultTable being used |
|
2314 |
method.iMainTable = 0; |
|
2315 |
method.iOverrideTable = 0; |
|
2316 |
method.iFlags = TCollationMethod::EIgnoreNone; |
|
2317 |
||
2318 |
//---------------Test key generation functionality---------------- |
|
2319 |
/** |
|
2320 |
Collation keys for |
|
2321 |
x=08b90108-00000078 |
|
2322 |
y=08bd0108-00000079 |
|
2323 |
z=08c90108-0000007a |
|
2324 |
*/ |
|
2325 |
_LIT(KInputString1,"xyz"); |
|
2326 |
HBufC8* outbuf=NULL; |
|
2327 |
//Max Level 0 keys |
|
2328 |
_LIT8(KMaxLevel0Key,"\x08\xb9\x08\xbd\x08\xc9"); |
|
2329 |
outbuf=KInputString1().GetCollationKeysL(0,&method); |
|
2330 |
test(outbuf->Compare(KMaxLevel0Key())==0); |
|
2331 |
delete outbuf; |
|
2332 |
//Max Level 1 keys |
|
2333 |
_LIT8(KMaxLevel1Key,"\x08\xb9\x08\xbd\x08\xc9\x00\x00\x01\x01\x01"); |
|
2334 |
outbuf=KInputString1().GetCollationKeysL(1,&method); |
|
2335 |
test(outbuf->Compare(KMaxLevel1Key())==0); |
|
2336 |
delete outbuf; |
|
2337 |
//Max Level 2 keys |
|
2338 |
_LIT8(KMaxLevel2Key,"\x08\xb9\x08\xbd\x08\xc9\x00\x00\x01\x01\x01\x00\x08\x08\x08"); |
|
2339 |
outbuf=KInputString1().GetCollationKeysL(2,&method); |
|
2340 |
test(outbuf->Compare(KMaxLevel2Key())==0); |
|
2341 |
delete outbuf; |
|
2342 |
//Max Level 3 keys |
|
2343 |
_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"); |
|
2344 |
outbuf=KInputString1().GetCollationKeysL(3,&method); |
|
2345 |
test(outbuf->Compare(KMaxLevel3Key())==0); |
|
2346 |
delete outbuf; |
|
2347 |
||
2348 |
/** |
|
2349 |
Decomposition for 1F70 |
|
2350 |
1F70=03B1 0300 |
|
2351 |
Collation keys for |
|
2352 |
\x03B1 =09360108-000003B1 |
|
2353 |
\x0300 =00001609-00000300 |
|
2354 |
y =08bd0108-00000079 |
|
2355 |
*/ |
|
2356 |
_LIT(KInputString2,"\x1F70y"); |
|
2357 |
//Max Level 2 keys |
|
2358 |
_LIT8(KCollationString22,"\x09\x36\x08\xBD\x00\x00\x01\x16\x01\x00\x08\x08\x08"); |
|
2359 |
outbuf=KInputString2().GetCollationKeysL(2,&method); |
|
2360 |
test(outbuf->Compare(KCollationString22())==0); |
|
2361 |
delete outbuf; |
|
2362 |
||
2363 |
//Max Level 3 keys |
|
2364 |
_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"); |
|
2365 |
outbuf=KInputString2().GetCollationKeysL(3,&method); |
|
2366 |
test(outbuf->Compare(KCollationString23())==0); |
|
2367 |
delete outbuf; |
|
2368 |
||
2369 |
/** |
|
2370 |
Decomposition for 1EAC |
|
2371 |
1EAC= 1EA0 0302 = 0041 0323 0302 |
|
2372 |
Collation keys for |
|
2373 |
\x0041 =06CF0121-00000041 |
|
2374 |
\x0323 =FF800104-00000001,83230105-00000000(2 keys for one character) |
|
2375 |
\x0302 =00001D09-00000302 |
|
2376 |
*/ |
|
2377 |
_LIT(KInputString3,"\x1EAC"); |
|
2378 |
//Max Level 0 keys |
|
2379 |
_LIT8(KCollationString30,"\x06\xCF\xFF\x80\x83\x23"); |
|
2380 |
//Max Level 1 keys |
|
2381 |
_LIT8(KCollationString31,"\x06\xCF\xFF\x80\x83\x23\x00\x00\x01\x01\x01\x1d"); |
|
2382 |
outbuf=KInputString3().GetCollationKeysL(1,&method); |
|
2383 |
test(outbuf->Compare(KCollationString31())==0); |
|
2384 |
delete outbuf; |
|
2385 |
||
2386 |
//Max Level 3 keys |
|
2387 |
_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"); |
|
2388 |
outbuf=KInputString3().GetCollationKeysL(3,&method); |
|
2389 |
test(outbuf->Compare(KCollationString33())==0); |
|
2390 |
delete outbuf; |
|
2391 |
||
2392 |
//--------------Test using NULL collationMethod----------------------- |
|
2393 |
outbuf=KInputString3().GetCollationKeysL(3,NULL); |
|
2394 |
test(outbuf->Compare(KCollationString33())==0); |
|
2395 |
delete outbuf; |
|
2396 |
||
2397 |
//--------------Test using out of limit level------------------------- |
|
2398 |
outbuf=KInputString3().GetCollationKeysL(6,NULL); |
|
2399 |
test(outbuf->Compare(KCollationString33())==0); |
|
2400 |
delete outbuf; |
|
2401 |
||
2402 |
outbuf=KInputString3().GetCollationKeysL(-1,NULL); |
|
2403 |
test(outbuf->Compare(KCollationString30())==0); |
|
2404 |
delete outbuf; |
|
2405 |
||
2406 |
} |
|
2407 |
||
2408 |
/** |
|
2409 |
@SYMTestCaseID SYSLIB-UNICODE-CT-1771 |
|
2410 |
@SYMTestCaseDesc TDes16 Collation conversion function OOM test |
|
2411 |
@SYMTestPriority High |
|
2412 |
@SYMTestActions OOM Testing the three collation conversion function |
|
2413 |
in TDesC16::GetNormalizedDecomposedFormL, |
|
2414 |
TDesC16::GetFoldedDecomposedFormL, |
|
2415 |
TDesC16::GetCollationKeysL |
|
2416 |
@SYMTestExpectedResults The test must not fail. |
|
2417 |
@SYMREQ 6178 Add several new Unicode utility functions |
|
2418 |
*/ |
|
2419 |
static void TestDes16CollationFunctionOOM() |
|
2420 |
{ |
|
2421 |
test.Next(_L("TestDes16CollationFunctionOOM")); |
|
2422 |
||
2423 |
TInt err, tryCount = 0; |
|
2424 |
do |
|
2425 |
{ |
|
2426 |
__UHEAP_MARK; |
|
2427 |
// find out the number of open handles |
|
2428 |
TInt startProcessHandleCount; |
|
2429 |
TInt startThreadHandleCount; |
|
2430 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
2431 |
||
2432 |
// Setting Heap failure for OOM test |
|
2433 |
__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount); |
|
2434 |
TRAP(err,TestDes16CollationFunctionL() ); |
|
2435 |
__UHEAP_SETFAIL(RHeap::ENone, 0); |
|
2436 |
||
2437 |
// check that no handles have leaked |
|
2438 |
TInt endProcessHandleCount; |
|
2439 |
TInt endThreadHandleCount; |
|
2440 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
2441 |
||
2442 |
test(startProcessHandleCount == endProcessHandleCount); |
|
2443 |
test(startThreadHandleCount == endThreadHandleCount); |
|
2444 |
||
2445 |
__UHEAP_MARKEND; |
|
2446 |
} while(err == KErrNoMemory); |
|
2447 |
||
2448 |
test(err == KErrNone); |
|
2449 |
test.Printf(_L("- TestDes16CollationFunctionOOM succeeded at heap failure rate of %i\n"), tryCount); |
|
2450 |
} |
|
2451 |
||
2452 |
GLDEF_C TInt E32Main() |
|
2453 |
// |
|
2454 |
// entry point |
|
2455 |
// |
|
2456 |
{ |
|
2457 |
CTrapCleanup* trapCleanup = CTrapCleanup::New(); |
|
2458 |
test(trapCleanup != NULL); |
|
2459 |
||
2460 |
test.Title(); |
|
2461 |
// |
|
2462 |
||
2463 |
test.Start(_L("Match8")); |
|
2464 |
TInt ii; |
|
2465 |
for (ii=0;ii<KTests;++ii) |
|
2466 |
{ |
|
2467 |
TInt r=TPtrC8(Tests8[ii].iLeft).Match(TPtrC8(Tests8[ii].iRight)); |
|
2468 |
test (r==Tests8[ii].iResult); |
|
2469 |
r=TPtrC8(Tests8[ii].iLeft).MatchF(TPtrC8(Tests8[ii].iRight)); |
|
2470 |
test (r==Tests8[ii].iResult); |
|
2471 |
} |
|
2472 |
test.Next(_L("Match16")); |
|
2473 |
for (ii=0;ii<KTests16;++ii) |
|
2474 |
{ |
|
2475 |
TInt r=TPtrC16(Tests16[ii].iLeft).Match(TPtrC16(Tests16[ii].iRight)); |
|
2476 |
test (r==Tests16[ii].iResult); |
|
2477 |
r=TPtrC16(Tests16[ii].iLeft).MatchF(TPtrC16(Tests16[ii].iRight)); |
|
2478 |
test (r==Tests16[ii].iResult); |
|
2479 |
} |
|
2480 |
// check code points with upper case |
|
2481 |
test.Next( _L("Check characters with upper case") ); |
|
2482 |
//039c: lower 03bc, folded 03bc |
|
2483 |
//00b5: upper 039c, folded 03bc |
|
2484 |
_LIT( K00b5, "\x00b5" ); |
|
2485 |
_LIT( K039c, "\x039c" ); |
|
2486 |
_LIT( K03bc, "\x03bc" ); |
|
2487 |
test( 0 == TPtrC16( K00b5() ).MatchF( TPtrC16( K039c() ) ) ); |
|
2488 |
test( 0 == TPtrC16( K00b5() ).MatchF( TPtrC16( K00b5() ) ) ); |
|
2489 |
test( 0 == TPtrC16( K00b5() ).MatchF( TPtrC16( K039c() ) ) ); |
|
2490 |
test( 0 == TPtrC16( K00b5() ).MatchF( TPtrC16( K03bc() ) ) ); |
|
2491 |
TBuf<20> buf00b5; |
|
2492 |
buf00b5.Copy( K00b5() ); |
|
2493 |
buf00b5.UpperCase(); |
|
2494 |
test( 0 == buf00b5.Find( K039c() ) ); |
|
2495 |
test( 0 == buf00b5.MatchF( K039c() ) ); |
|
2496 |
||
2497 |
// check code points with both upper and lower cases |
|
2498 |
test.Next( _L("Check characters with upper and lower cases") ); |
|
2499 |
// 01C5: upper 01C4, folded 01C6 |
|
2500 |
_LIT( K01c5, "\x01c5" ); |
|
2501 |
_LIT( K01c4, "\x01c4" ); |
|
2502 |
_LIT( K01c6, "\x01c6" ); |
|
2503 |
test( 0 == TPtrC16( K01c5() ).MatchF( TPtrC16( K01c6() ) ) ); |
|
2504 |
test( 0 == TPtrC16( K01c5() ).MatchF( TPtrC16( K01c4() ) ) ); |
|
2505 |
test( 0 == TPtrC16( K01c4() ).MatchF( TPtrC16( K01c5() ) ) ); |
|
2506 |
test( 0 == TPtrC16( K01c4() ).MatchF( TPtrC16( K01c6() ) ) ); |
|
2507 |
TBuf<20> buf01c5; |
|
2508 |
buf01c5.Copy( K01c5() ); |
|
2509 |
buf01c5.UpperCase(); |
|
2510 |
test( 0 == buf01c5.Find( K01c4() ) ); |
|
2511 |
test( 0 == buf01c5.MatchF( K01c6() ) ); |
|
2512 |
||
2513 |
test.Next(_L("MatchSurrogate")); |
|
2514 |
for (ii=0;ii<KTestsSurrogate;++ii) |
|
2515 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2516 |
TInt r=TPtrC16(TestsSurrogate[ii].iLeft).Match2(TPtrC16(TestsSurrogate[ii].iRight)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2517 |
RDebug::Printf(" ii=%d, expect=%d, result=%d", ii, TestsSurrogate[ii].iResult, r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2518 |
test (r==TestsSurrogate[ii].iResult); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2519 |
r=TPtrC16(TestsSurrogate[ii].iLeft).MatchF(TPtrC16(TestsSurrogate[ii].iRight)); |
0 | 2520 |
test (r==TestsSurrogate[ii].iResult); |
2521 |
} |
|
2522 |
||
2523 |
_LIT( KD800, "\xd800" ); |
|
2524 |
_LIT( KQuestion, "?" ); |
|
2525 |
_LIT( KDC00, "\xdc00" ); |
|
2526 |
_LIT( KDFFF, "\xdfff" ); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2527 |
test( KErrCorruptSurrogateFound == TPtrC16( KD800() ).Match2( TPtrC16( KQuestion() ) ) ); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2528 |
test( KErrCorruptSurrogateFound == TPtrC16( KD800() ).Match2( TPtrC16( KD800() ) ) ); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2529 |
test( KErrCorruptSurrogateFound == TPtrC16( KDC00() ).Match2( TPtrC16( KQuestion() ) ) ); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2530 |
test( KErrCorruptSurrogateFound == TPtrC16( KDFFF() ).Match2( TPtrC16( KQuestion() ) ) ); |
0 | 2531 |
|
2532 |
test( KErrNotFound == TPtrC16( KD800() ).MatchF( TPtrC16( KQuestion() ) ) ); |
|
2533 |
test( 0 == TPtrC16( KD800() ).MatchF( TPtrC16( KD800() ) ) ); |
|
2534 |
test( KErrNotFound == TPtrC16( KDC00() ).MatchF( TPtrC16( KQuestion() ) ) ); |
|
2535 |
test( KErrNotFound == TPtrC16( KDFFF() ).MatchF( TPtrC16( KQuestion() ) ) ); |
|
2536 |
||
2537 |
test.Next(_L("Iterator tests")); |
|
2538 |
||
2539 |
::TestUTF32Iterator(); |
|
2540 |
::TestFoldedDecompIterator(); |
|
2541 |
::TestFoldedSortedDecompIterator(); |
|
2542 |
::TestFoldedCanonicalIterator(); |
|
2543 |
::TestDecompositionIterator2(); |
|
2544 |
::TestCanonicalDecompositionIterator2(); |
|
2545 |
::TestCanonicalDecompositionIteratorCached(); |
|
2546 |
||
2547 |
test.Next(_L("Unit tests")); |
|
2548 |
||
2549 |
TestDecompositionIterator(); |
|
2550 |
TestCanonicalDecompositionIterator(); |
|
2551 |
TestCollationValueIterator(); |
|
2552 |
TestMatchIdentifiers(); |
|
2553 |
TestFindIdentifier(); |
|
2554 |
||
2555 |
TRAPD(err, TestFoldingL()); |
|
2556 |
test(err == KErrNone); |
|
2557 |
||
2558 |
test.Next(_L("INC057641")); |
|
2559 |
TRAP(err, INC057641L()); |
|
2560 |
test(err == KErrNone); |
|
2561 |
||
2562 |
TestMatchC(); |
|
2563 |
TestMatchC2(); |
|
2564 |
||
2565 |
test.Next(_L("TestDes16CollationFunctionL")); |
|
2566 |
TRAP(err,TestDes16CollationFunctionL()); |
|
2567 |
test(err==KErrNone); |
|
2568 |
::TestDes16CollationFunctionOOM(); |
|
2569 |
||
2570 |
TestDisableCombiningCharacterCheck(); |
|
2571 |
||
2572 |
test.End(); |
|
2573 |
test.Close(); |
|
2574 |
||
2575 |
delete trapCleanup; |
|
2576 |
||
2577 |
return 0; |
|
2578 |
} |