1 /* |
|
2 * Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32base.h> |
|
21 #include <e32test.h> |
|
22 #include <f32file.h> |
|
23 #include <charconv.h> |
|
24 |
|
25 /////////////////////////////////////////////////////////////////////////////////////// |
|
26 |
|
27 RTest TheTest(_L("THZ")); |
|
28 |
|
29 /////////////////////////////////////////////////////////////////////////////////////// |
|
30 /////////////////////////////////////////////////////////////////////////////////////// |
|
31 //Tests macroses and functions. |
|
32 //If (!aValue) then the test will be panicked, the test data files will be deleted. |
|
33 static void Check(TInt aValue, TInt aLine) |
|
34 { |
|
35 if(!aValue) |
|
36 { |
|
37 TheTest(EFalse, aLine); |
|
38 } |
|
39 } |
|
40 //If (aValue != aExpected) then the test will be panicked, the test data files will be deleted. |
|
41 static void Check(TInt aValue, TInt aExpected, TInt aLine) |
|
42 { |
|
43 if(aValue != aExpected) |
|
44 { |
|
45 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
46 TheTest(EFalse, aLine); |
|
47 } |
|
48 } |
|
49 //Use these to test conditions. |
|
50 #define TEST(arg) ::Check((arg), __LINE__) |
|
51 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
52 |
|
53 /////////////////////////////////////////////////////////////////////////////////////// |
|
54 /////////////////////////////////////////////////////////////////////////////////////// |
|
55 |
|
56 const TInt KBufferLength=100; |
|
57 /** |
|
58 @SYMTestCaseID SYSLIB-CHARCONV-CT-0503 |
|
59 @SYMTestCaseDesc Tests for truncated conversion from Unicode to HZ character set |
|
60 @SYMTestPriority Medium |
|
61 @SYMTestActions Tests for generated Unicode with the original Unicode |
|
62 @SYMTestExpectedResults Test must not fail |
|
63 @SYMREQ REQ0000 |
|
64 */ |
|
65 LOCAL_C void TestTruncatedConversionFromUnicodeToHz(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aOriginalUnicode) |
|
66 { |
|
67 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0503 ")); |
|
68 for (TInt i=aOriginalUnicode.Length(); i>=0; --i) |
|
69 { |
|
70 TBuf8<KBufferLength> generatedHz; |
|
71 const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedHz, aOriginalUnicode.Left(i)); |
|
72 TEST(returnValue>=0); |
|
73 TBuf8<KBufferLength> generatedsecondPartOfHz; |
|
74 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedsecondPartOfHz, aOriginalUnicode.Mid(i-returnValue))==0); |
|
75 generatedHz.Append(generatedsecondPartOfHz); |
|
76 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
77 TBuf16<KBufferLength> generatedUnicode; |
|
78 TEST(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedHz, state)==0); |
|
79 TEST(generatedUnicode==aOriginalUnicode); |
|
80 } |
|
81 } |
|
82 /** |
|
83 @SYMTestCaseID SYSLIB-CHARCONV-CT-0504 |
|
84 @SYMTestCaseDesc Splitting and converting from Unicode to HZ test |
|
85 @SYMTestPriority Medium |
|
86 @SYMTestActions Tests for conversion after splitting from Unicode to Hz and back to Unicode |
|
87 @SYMTestExpectedResults Test must not fail |
|
88 @SYMREQ REQ0000 |
|
89 */ |
|
90 LOCAL_C void TestSplittingConvertingFromUnicodeToHz(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit, const TDesC8& aExpectedFirstPartOfHz, const TDesC8& aExpectedSecondPartOfHz, const TDesC16& aOriginalUnicode) |
|
91 { |
|
92 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0504 ")); |
|
93 TEST(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit); |
|
94 TEST(aMaximumLengthUpperLimit<=KBufferLength); |
|
95 TUint8 hzBuffer[KBufferLength]; |
|
96 for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i) |
|
97 { |
|
98 TPtr8 generatedFirstPartOfHz(hzBuffer, i); |
|
99 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfHz, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit); |
|
100 TEST(generatedFirstPartOfHz==aExpectedFirstPartOfHz); |
|
101 TBuf8<KBufferLength> generatedSecondPartOfHz; |
|
102 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfHz, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0); |
|
103 TEST(generatedSecondPartOfHz==aExpectedSecondPartOfHz); |
|
104 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
105 TBuf16<KBufferLength> generatedUnicode; |
|
106 TEST(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfHz, state)==0); |
|
107 TEST(state==CCnvCharacterSetConverter::KStateDefault); |
|
108 TBuf16<KBufferLength> generatedSecondPartOfUnicode; |
|
109 TEST(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfHz, state)==0); |
|
110 TEST(state==CCnvCharacterSetConverter::KStateDefault); |
|
111 generatedUnicode.Append(generatedSecondPartOfUnicode); |
|
112 TEST(generatedUnicode==aOriginalUnicode); |
|
113 } |
|
114 } |
|
115 /** |
|
116 @SYMTestCaseID SYSLIB-CHARCONV-CT-0505 |
|
117 @SYMTestCaseDesc Tests for truncated conversion from HZ to Unicode |
|
118 @SYMTestPriority Medium |
|
119 @SYMTestActions Tests for conversion after truncation from HZ to Unicode and back to HZ |
|
120 @SYMTestExpectedResults Test must not fail |
|
121 @SYMREQ REQ0000 |
|
122 */ |
|
123 LOCAL_C void TestTruncatedConversionToUnicodeFromHz(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalHz) |
|
124 { |
|
125 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0505 ")); |
|
126 for (TInt i=aOriginalHz.Length(); i>=2; --i) // 2 is the length of HZ's "tilde" sequences |
|
127 { |
|
128 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
129 TBuf16<KBufferLength> generatedUnicode; |
|
130 const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalHz.Left(i), state); |
|
131 TEST(returnValue>=0); |
|
132 TBuf16<KBufferLength> generatedsecondPartOfUnicode; |
|
133 TEST(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalHz.Mid(i-returnValue), state)==0); |
|
134 generatedUnicode.Append(generatedsecondPartOfUnicode); |
|
135 TEST(generatedUnicode==aExpectedUnicode); |
|
136 } |
|
137 } |
|
138 /** |
|
139 @SYMTestCaseID SYSLIB-CHARCONV-CT-0506 |
|
140 @SYMTestCaseDesc Splitting and converting to Unicode from HZ test |
|
141 @SYMTestPriority Medium |
|
142 @SYMTestActions Tests for conversion after splitting from Hz to Unicode and back to Hz |
|
143 @SYMTestExpectedResults Test must not fail |
|
144 @SYMREQ REQ0000 |
|
145 */ |
|
146 LOCAL_C void TestSplittingConvertingToUnicodeFromHz(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfHzBytesNotConvertedAtSplit, TInt aExpectedStateAtSplit, TInt aExpectedLengthOfFirstPartOfUnicode, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalHz) |
|
147 { |
|
148 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0506 ")); |
|
149 TEST(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit); |
|
150 TEST(aMaximumLengthUpperLimit<=KBufferLength); |
|
151 TUint16 unicodeBuffer[KBufferLength]; |
|
152 for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i) |
|
153 { |
|
154 TPtr16 generatedFirstPartOfUnicode(unicodeBuffer, i); |
|
155 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
156 const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedFirstPartOfUnicode, aOriginalHz, state); |
|
157 TEST(generatedFirstPartOfUnicode==aExpectedUnicode.Left(aExpectedLengthOfFirstPartOfUnicode)); |
|
158 TEST((returnValue==aExpectedNumberOfHzBytesNotConvertedAtSplit) && (state==aExpectedStateAtSplit)); |
|
159 { |
|
160 TBuf16<KBufferLength> generatedSecondPartOfUnicode; |
|
161 state=aExpectedStateAtSplit; |
|
162 TEST(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, aOriginalHz.Right(aExpectedNumberOfHzBytesNotConvertedAtSplit), state)==0); |
|
163 TEST(generatedSecondPartOfUnicode==aExpectedUnicode.Mid(aExpectedLengthOfFirstPartOfUnicode)); |
|
164 TEST(state==CCnvCharacterSetConverter::KStateDefault); |
|
165 TBuf8<KBufferLength> generatedHz; |
|
166 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedHz, generatedFirstPartOfUnicode)==0); |
|
167 TBuf8<KBufferLength> generatedSecondPartOfHz; |
|
168 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfHz, generatedSecondPartOfUnicode)==0); |
|
169 generatedHz.Append(generatedSecondPartOfHz); |
|
170 TBuf16<KBufferLength> regeneratedUnicode; |
|
171 state=CCnvCharacterSetConverter::KStateDefault; |
|
172 TEST(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, generatedHz, state)==0); |
|
173 TEST(regeneratedUnicode==aExpectedUnicode); |
|
174 TEST(state==CCnvCharacterSetConverter::KStateDefault); |
|
175 TEST(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, aOriginalHz, state)==0); |
|
176 TEST(regeneratedUnicode==aExpectedUnicode); |
|
177 TEST(state==CCnvCharacterSetConverter::KStateDefault); |
|
178 } |
|
179 { |
|
180 TBuf16<KBufferLength> generatedSecondPartOfUnicode; |
|
181 state=aExpectedStateAtSplit; |
|
182 TEST(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, aOriginalHz.Right(aExpectedNumberOfHzBytesNotConvertedAtSplit), state)==0); |
|
183 TEST(generatedSecondPartOfUnicode==aExpectedUnicode.Mid(aExpectedLengthOfFirstPartOfUnicode)); |
|
184 TEST(state==CCnvCharacterSetConverter::KStateDefault); |
|
185 TBuf8<KBufferLength> generatedHz; |
|
186 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedHz, generatedFirstPartOfUnicode)==0); |
|
187 TBuf8<KBufferLength> generatedSecondPartOfHz; |
|
188 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfHz, generatedSecondPartOfUnicode)==0); |
|
189 generatedHz.Append(generatedSecondPartOfHz); |
|
190 TBuf16<KBufferLength> regeneratedUnicode; |
|
191 state=CCnvCharacterSetConverter::KStateDefault; |
|
192 TEST(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, generatedHz, state)==0); |
|
193 TEST(regeneratedUnicode==aExpectedUnicode); |
|
194 TEST(state==CCnvCharacterSetConverter::KStateDefault); |
|
195 TEST(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, aOriginalHz, state)==0); |
|
196 TEST(regeneratedUnicode==aExpectedUnicode); |
|
197 TEST(state==CCnvCharacterSetConverter::KStateDefault); |
|
198 } |
|
199 } |
|
200 } |
|
201 /** |
|
202 @SYMTestCaseID SYSLIB-CHARCONV-CT-0507 |
|
203 @SYMTestCaseDesc Conversion of bad HZ format to Unicode test |
|
204 @SYMTestPriority Medium |
|
205 @SYMTestActions Tests to convert bad Hz format to Unicode. |
|
206 Check the status of CCnvCharacterSetConverter::EErrorIllFormedInput error flag |
|
207 @SYMTestExpectedResults Test must not fail |
|
208 @SYMREQ REQ0000 |
|
209 */ |
|
210 LOCAL_C void TestIsIllFormedHz(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC8& aHz) |
|
211 { |
|
212 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0507 ")); |
|
213 TBuf16<50> generatedUnicode; |
|
214 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
215 TPtrC8 remainderOfHz(aHz); |
|
216 TInt lastReturnValue=KMaxTInt; |
|
217 FOREVER |
|
218 { |
|
219 const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, remainderOfHz, state); |
|
220 if (returnValue==CCnvCharacterSetConverter::EErrorIllFormedInput) |
|
221 { |
|
222 break; |
|
223 } |
|
224 TEST(returnValue>0); |
|
225 TEST(returnValue<lastReturnValue); |
|
226 lastReturnValue=returnValue; |
|
227 remainderOfHz.Set(remainderOfHz.Right(returnValue)); |
|
228 } |
|
229 } |
|
230 /** |
|
231 @SYMTestCaseID SYSLIB-CHARCONV-CT-0508 |
|
232 @SYMTestCaseDesc HZ to Unicode and Unicode to HZ conversion tests |
|
233 @SYMTestPriority Medium |
|
234 @SYMTestActions Wrapper function to call HZ conversion test functions |
|
235 @SYMTestExpectedResults Test must not fail |
|
236 @SYMREQ REQ0000 |
|
237 */ |
|
238 LOCAL_C void DoE32MainL() |
|
239 { |
|
240 TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0508 ")); |
|
241 RFs fileServerSession; |
|
242 CleanupClosePushL(fileServerSession); |
|
243 User::LeaveIfError(fileServerSession.Connect()); |
|
244 CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC(); |
|
245 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession); |
|
246 TheTest.Printf(_L("Available:\n")); |
|
247 for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i) |
|
248 { |
|
249 const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i]; |
|
250 characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession); |
|
251 TPtrC charactersSetName(charactersSet.Name()); |
|
252 if (charactersSet.NameIsFileName()) |
|
253 { |
|
254 charactersSetName.Set(TParsePtrC(charactersSetName).Name()); |
|
255 } |
|
256 TheTest.Printf(_L(" %S\n"), &charactersSetName); |
|
257 } |
|
258 TheTest.Next(_L("Testing HZ conversions")); |
|
259 characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierHz, *arrayOfCharacterSetsAvailable, fileServerSession); |
|
260 // |
|
261 TheTest.Next(_L("Empty descriptor")); |
|
262 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 0, 10, 0, KNullDesC8, KNullDesC8, KNullDesC16); |
|
263 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 0, 10, 0, CCnvCharacterSetConverter::KStateDefault, 0, KNullDesC16, KNullDesC8); |
|
264 TheTest.Next(_L("Testing converting to HZ")); |
|
265 TBuf16<50> originalUnicode; |
|
266 originalUnicode.Format(_L16("%c%cxyz%c%c~%c~~%ce~a%c"), 0x4e2d, 0x56fd, 0x5979, 0x4ed6, 0x4eba, 0x4e09, 0x7259); |
|
267 TestTruncatedConversionFromUnicodeToHz(*characterSetConverter, originalUnicode); |
|
268 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 0, 5, 16, KNullDesC8, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
269 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 6, 7, 15, _L8("~{VP~}"), _L8("~{9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
270 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 8, 8, 14, _L8("~{VP9z~}"), _L8("xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
271 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 9, 9, 13, _L8("~{VP9z~}x"), _L8("yz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
272 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 10, 10, 12, _L8("~{VP9z~}xy"), _L8("z~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
273 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 11, 16, 11, _L8("~{VP9z~}xyz"), _L8("~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
274 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 17, 18, 10, _L8("~{VP9z~}xyz~{K}~}"), _L8("~{K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
275 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 19, 20, 9, _L8("~{VP9z~}xyz~{K}K{~}"), _L8("~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
276 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 21, 26, 8, _L8("~{VP9z~}xyz~{K}K{~}~~"), _L8("~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
277 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 27, 28, 7, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}"), _L8("~~~~~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
278 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 29, 30, 6, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~"), _L8("~~~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
279 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 31, 36, 5, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~"), _L8("~{H}~}e~~a~{Q@~}"), originalUnicode); |
|
280 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 37, 37, 4, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}"), _L8("e~~a~{Q@~}"), originalUnicode); |
|
281 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 38, 39, 3, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e"), _L8("~~a~{Q@~}"), originalUnicode); |
|
282 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 40, 40, 2, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~"), _L8("a~{Q@~}"), originalUnicode); |
|
283 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 41, 46, 1, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a"), _L8("~{Q@~}"), originalUnicode); |
|
284 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 47, 50, 0, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), KNullDesC8, originalUnicode); |
|
285 TheTest.Next(_L("Testing converting to Unicode")); |
|
286 const TPtrC8 originalHz(_S8("My name is ~{3W~} ~~~~{~~I ~{'X'Z'S'e~} in ~{11>)~}~~~~}~~~~")); |
|
287 TBuf16<50> expectedUnicode; |
|
288 expectedUnicode.Format(_L16("My name is %c ~~{~I %c%c%c%c in %c%c~~}~~"), 0x5319, 0x0436, 0x0438, 0x0432, 0x0443, 0x5317, 0x4eac); |
|
289 TestTruncatedConversionToUnicodeFromHz(*characterSetConverter, expectedUnicode, originalHz); |
|
290 TestTruncatedConversionToUnicodeFromHz(*characterSetConverter, _L16("Hello"), _L8("~{~}~{~}~{~}Hello")); |
|
291 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 0, 0, 60, CCnvCharacterSetConverter::KStateDefault, 0, expectedUnicode, originalHz); |
|
292 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 1, 1, 59, CCnvCharacterSetConverter::KStateDefault, 1, expectedUnicode, originalHz); |
|
293 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 2, 2, 58, CCnvCharacterSetConverter::KStateDefault, 2, expectedUnicode, originalHz); |
|
294 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 3, 3, 57, CCnvCharacterSetConverter::KStateDefault, 3, expectedUnicode, originalHz); |
|
295 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 4, 4, 56, CCnvCharacterSetConverter::KStateDefault, 4, expectedUnicode, originalHz); |
|
296 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 5, 5, 55, CCnvCharacterSetConverter::KStateDefault, 5, expectedUnicode, originalHz); |
|
297 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 6, 6, 54, CCnvCharacterSetConverter::KStateDefault, 6, expectedUnicode, originalHz); |
|
298 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 7, 7, 53, CCnvCharacterSetConverter::KStateDefault, 7, expectedUnicode, originalHz); |
|
299 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 8, 8, 52, CCnvCharacterSetConverter::KStateDefault, 8, expectedUnicode, originalHz); |
|
300 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 9, 9, 51, CCnvCharacterSetConverter::KStateDefault, 9, expectedUnicode, originalHz); |
|
301 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 10, 10, 50, CCnvCharacterSetConverter::KStateDefault, 10, expectedUnicode, originalHz); |
|
302 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 11, 11, 47, CCnvCharacterSetConverter::KStateDefault+1, 11, expectedUnicode, originalHz); |
|
303 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 12, 12, 43, CCnvCharacterSetConverter::KStateDefault, 12, expectedUnicode, originalHz); |
|
304 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 13, 13, 42, CCnvCharacterSetConverter::KStateDefault, 13, expectedUnicode, originalHz); |
|
305 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 14, 14, 40, CCnvCharacterSetConverter::KStateDefault, 14, expectedUnicode, originalHz); |
|
306 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 15, 15, 38, CCnvCharacterSetConverter::KStateDefault, 15, expectedUnicode, originalHz); |
|
307 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 16, 16, 37, CCnvCharacterSetConverter::KStateDefault, 16, expectedUnicode, originalHz); |
|
308 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 17, 17, 35, CCnvCharacterSetConverter::KStateDefault, 17, expectedUnicode, originalHz); |
|
309 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 18, 18, 34, CCnvCharacterSetConverter::KStateDefault, 18, expectedUnicode, originalHz); |
|
310 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 19, 19, 31, CCnvCharacterSetConverter::KStateDefault+1, 19, expectedUnicode, originalHz); |
|
311 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 20, 20, 29, CCnvCharacterSetConverter::KStateDefault+1, 20, expectedUnicode, originalHz); |
|
312 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 21, 21, 27, CCnvCharacterSetConverter::KStateDefault+1, 21, expectedUnicode, originalHz); |
|
313 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 22, 22, 25, CCnvCharacterSetConverter::KStateDefault+1, 22, expectedUnicode, originalHz); |
|
314 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 23, 23, 21, CCnvCharacterSetConverter::KStateDefault, 23, expectedUnicode, originalHz); |
|
315 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 24, 24, 20, CCnvCharacterSetConverter::KStateDefault, 24, expectedUnicode, originalHz); |
|
316 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 25, 25, 19, CCnvCharacterSetConverter::KStateDefault, 25, expectedUnicode, originalHz); |
|
317 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 26, 26, 18, CCnvCharacterSetConverter::KStateDefault, 26, expectedUnicode, originalHz); |
|
318 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 27, 27, 15, CCnvCharacterSetConverter::KStateDefault+1, 27, expectedUnicode, originalHz); |
|
319 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 28, 28, 13, CCnvCharacterSetConverter::KStateDefault+1, 28, expectedUnicode, originalHz); |
|
320 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 29, 29, 9, CCnvCharacterSetConverter::KStateDefault, 29, expectedUnicode, originalHz); |
|
321 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 30, 30, 7, CCnvCharacterSetConverter::KStateDefault, 30, expectedUnicode, originalHz); |
|
322 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 31, 31, 5, CCnvCharacterSetConverter::KStateDefault, 31, expectedUnicode, originalHz); |
|
323 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 32, 32, 4, CCnvCharacterSetConverter::KStateDefault, 32, expectedUnicode, originalHz); |
|
324 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 33, 33, 2, CCnvCharacterSetConverter::KStateDefault, 33, expectedUnicode, originalHz); |
|
325 TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 34, 40, 0, CCnvCharacterSetConverter::KStateDefault, 34, expectedUnicode, originalHz); |
|
326 TheTest.Next(_L("Having '~' as the second byte of a Chinese character")); |
|
327 originalUnicode.Format(_L16("1%c2"), 0x4e8c); |
|
328 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 0, 0, 3, KNullDesC8, _L8("1~{6~~}2"), originalUnicode); |
|
329 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 1, 6, 2, _L8("1"), _L8("~{6~~}2"), originalUnicode); |
|
330 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 7, 7, 1, _L8("1~{6~~}"), _L8("2"), originalUnicode); |
|
331 TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 8, 20, 0, _L8("1~{6~~}2"), KNullDesC8, originalUnicode); |
|
332 TheTest.Next(_L("Testing ill-formed HZ")); |
|
333 TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{C~} def")); |
|
334 TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{C;C~} def")); |
|
335 TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{C;C;C~} def")); |
|
336 TestIsIllFormedHz(*characterSetConverter, _L8("abc ~")); |
|
337 TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{~")); |
|
338 TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{C")); |
|
339 // note that...................................._L8("abc ~{C~") is actually well-formed |
|
340 TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{C;~")); |
|
341 CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession |
|
342 } |
|
343 |
|
344 GLDEF_C TInt E32Main() |
|
345 { |
|
346 __UHEAP_MARK; |
|
347 |
|
348 TheTest.Title(); |
|
349 |
|
350 CTrapCleanup* trapCleanup=CTrapCleanup::New(); |
|
351 TEST(trapCleanup != NULL); |
|
352 |
|
353 TRAPD(error, DoE32MainL()); |
|
354 TEST2(error, KErrNone); |
|
355 |
|
356 delete trapCleanup; |
|
357 |
|
358 TheTest.End(); |
|
359 TheTest.Close(); |
|
360 |
|
361 __UHEAP_MARKEND; |
|
362 return KErrNone; |
|
363 } |
|
364 |
|