|
1 /* |
|
2 * Copyright (c) 2022 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 the License "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 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #include <e32std.h> |
|
26 #include <e32base.h> |
|
27 #include <e32test.h> |
|
28 #include <f32file.h> |
|
29 #include <charconv.h> |
|
30 |
|
31 /////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
33 RTest TheTest(_L("TISO2022JP")); |
|
34 |
|
35 /////////////////////////////////////////////////////////////////////////////////////// |
|
36 /////////////////////////////////////////////////////////////////////////////////////// |
|
37 //Tests macroses and functions. |
|
38 //If (!aValue) then the test will be panicked, the test data files will be deleted. |
|
39 static void Check(TInt aValue, TInt aLine) |
|
40 { |
|
41 if(!aValue) |
|
42 { |
|
43 TheTest(EFalse, aLine); |
|
44 } |
|
45 } |
|
46 //If (aValue != aExpected) then the test will be panicked, the test data files will be deleted. |
|
47 static void Check(TInt aValue, TInt aExpected, TInt aLine) |
|
48 { |
|
49 if(aValue != aExpected) |
|
50 { |
|
51 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
52 TheTest(EFalse, aLine); |
|
53 } |
|
54 } |
|
55 //Use these to test conditions. |
|
56 #define TEST(arg) ::Check((arg), __LINE__) |
|
57 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
58 |
|
59 /////////////////////////////////////////////////////////////////////////////////////// |
|
60 /////////////////////////////////////////////////////////////////////////////////////// |
|
61 |
|
62 const TInt KBufferLength=100; |
|
63 const TInt KNotEnoughBufferLength=17; |
|
64 /** |
|
65 @SYMTestCaseID SYSLIB-CHARCONV-CT-0522 |
|
66 @SYMTestCaseDesc Tests for conversion from Unicode to ISO2022JP |
|
67 @SYMTestPriority Medium |
|
68 @SYMTestActions Tests for conversion from Unicode to ISO2022JP and back to Unicode |
|
69 @SYMTestExpectedResults Test must not fail |
|
70 @SYMREQ REQ0000 |
|
71 */ |
|
72 LOCAL_C void TestConversionFromUnicodeToIso( |
|
73 CCnvCharacterSetConverter& aCharacterSetConverter, |
|
74 const TDesC16& aOriginalUnicode) |
|
75 { |
|
76 TBuf8<KNotEnoughBufferLength> generatedIso2022Jp; |
|
77 generatedIso2022Jp.FillZ(KNotEnoughBufferLength); |
|
78 const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedIso2022Jp, aOriginalUnicode); |
|
79 TEST(returnValue>=0); |
|
80 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
81 TBuf16<KBufferLength> generatedUnicode; |
|
82 TInt testresult; |
|
83 testresult=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedIso2022Jp, state); |
|
84 TEST(testresult==0); |
|
85 // TEST(generatedUnicode==aOriginalUnicode); |
|
86 } |
|
87 /** |
|
88 @SYMTestCaseID SYSLIB-CHARCONV-CT-0523 |
|
89 @SYMTestCaseDesc Tests for truncated conversion from Unicode to ISO2022JP |
|
90 @SYMTestPriority Medium |
|
91 @SYMTestActions Tests for truncated conversion from Unicode to ISO2022JP and back to Unicode |
|
92 @SYMTestExpectedResults Test must not fail |
|
93 @SYMREQ REQ0000 |
|
94 */ |
|
95 LOCAL_C void TestTruncatedConversionFromUnicodeToIso2022Jp( |
|
96 CCnvCharacterSetConverter& aCharacterSetConverter, |
|
97 const TDesC16& aOriginalUnicode) |
|
98 { |
|
99 for (TInt i=aOriginalUnicode.Length(); i>=0; --i) |
|
100 { |
|
101 TBuf8<KBufferLength> generatedIso2022Jp; |
|
102 const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedIso2022Jp, aOriginalUnicode.Left(i)); |
|
103 TEST(returnValue>=0); |
|
104 TBuf8<KBufferLength> generatedsecondPartOfIso2022Jp; |
|
105 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedsecondPartOfIso2022Jp, aOriginalUnicode.Mid(i-returnValue))==0); |
|
106 generatedIso2022Jp.Append(generatedsecondPartOfIso2022Jp); |
|
107 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
108 TBuf16<KBufferLength> generatedUnicode; |
|
109 TEST(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedIso2022Jp, state)==0); |
|
110 TEST(generatedUnicode==aOriginalUnicode); |
|
111 } |
|
112 } |
|
113 /** |
|
114 @SYMTestCaseID SYSLIB-CHARCONV-CT-0524 |
|
115 @SYMTestCaseDesc Splitting and converting from Unicode to ISO2022JP test |
|
116 @SYMTestPriority Medium |
|
117 @SYMTestActions Tests for conversion after splitting, from Unicode to ISO2022JP and back to Unicode |
|
118 @SYMTestExpectedResults Test must not fail |
|
119 @SYMREQ REQ0000 |
|
120 */ |
|
121 LOCAL_C void TestSplittingConvertingFromUnicodeToIso2022Jp( |
|
122 CCnvCharacterSetConverter& aCharacterSetConverter, |
|
123 TInt aMaximumLengthLowerLimit, |
|
124 TInt aMaximumLengthUpperLimit, |
|
125 TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit, |
|
126 const TDesC8& aExpectedFirstPartOfIso2022Jp, |
|
127 const TDesC8& aExpectedSecondPartOfIso2022Jp, |
|
128 const TDesC16& aOriginalUnicode) |
|
129 { |
|
130 TEST(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit); |
|
131 TEST(aMaximumLengthUpperLimit<=KBufferLength); |
|
132 TUint8 iso2022JpBuffer[KBufferLength]; |
|
133 for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i) |
|
134 { |
|
135 TPtr8 generatedFirstPartOfIso2022Jp(iso2022JpBuffer, i); |
|
136 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfIso2022Jp, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit); |
|
137 TEST(generatedFirstPartOfIso2022Jp==aExpectedFirstPartOfIso2022Jp); |
|
138 TBuf8<KBufferLength> generatedSecondPartOfIso2022Jp; |
|
139 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfIso2022Jp, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0); |
|
140 TEST(generatedSecondPartOfIso2022Jp==aExpectedSecondPartOfIso2022Jp); |
|
141 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
142 TBuf16<KBufferLength> generatedUnicode; |
|
143 TEST(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfIso2022Jp, state)==0); |
|
144 TBuf16<KBufferLength> generatedSecondPartOfUnicode; |
|
145 TEST(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfIso2022Jp, state)==0); |
|
146 generatedUnicode.Append(generatedSecondPartOfUnicode); |
|
147 TEST(generatedUnicode==aOriginalUnicode); |
|
148 } |
|
149 } |
|
150 /** |
|
151 @SYMTestCaseID SYSLIB-CHARCONV-CT-0525 |
|
152 @SYMTestCaseDesc Tests for truncated conversion from ISO2022JP to Unicode test |
|
153 @SYMTestPriority Medium |
|
154 @SYMTestActions Tests for truncated conversion from ISO2022JP to Unicode and back to ISO2022JP |
|
155 @SYMTestExpectedResults Test must not fail |
|
156 @SYMREQ REQ0000 |
|
157 */ |
|
158 LOCAL_C void TestTruncatedConversionToUnicodeFromIso2022Jp( |
|
159 CCnvCharacterSetConverter& aCharacterSetConverter, |
|
160 const TDesC16& aExpectedUnicode, |
|
161 const TDesC8& aOriginalIso2022Jp) |
|
162 { |
|
163 for (TInt i=aOriginalIso2022Jp.Length(); i>=3; --i) // 3 is the length of ISO-2022-JP's longest escape sequence |
|
164 { |
|
165 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
166 TBuf16<KBufferLength> generatedUnicode; |
|
167 const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalIso2022Jp.Left(i), state); |
|
168 TEST(returnValue>=0); |
|
169 TBuf16<KBufferLength> generatedsecondPartOfUnicode; |
|
170 TEST(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalIso2022Jp.Mid(i-returnValue), state)==0); |
|
171 generatedUnicode.Append(generatedsecondPartOfUnicode); |
|
172 TEST(generatedUnicode==aExpectedUnicode); |
|
173 } |
|
174 } |
|
175 /** |
|
176 @SYMTestCaseID SYSLIB-CHARCONV-CT-0526 |
|
177 @SYMTestCaseDesc Splitting and converting from ISO2022JP to Unicode test. |
|
178 @SYMTestPriority Medium |
|
179 @SYMTestActions Tests for conversion after splitting, from ISO2022JP to Unicode and back to ISO2022JP |
|
180 @SYMTestExpectedResults Test must not fail |
|
181 @SYMREQ REQ0000 |
|
182 */ |
|
183 LOCAL_C void TestSplittingConvertingToUnicodeFromIso2022Jp( |
|
184 CCnvCharacterSetConverter& aCharacterSetConverter, |
|
185 TInt aMaximumLengthLowerLimit, |
|
186 TInt aMaximumLengthUpperLimit, |
|
187 TInt aExpectedNumberOfIso2022JpBytesNotConvertedAtSplit, |
|
188 TInt aExpectedLengthOfFirstPartOfUnicode, |
|
189 const TDesC16& aExpectedUnicode, |
|
190 const TDesC8& aOriginalIso2022Jp) |
|
191 { |
|
192 TEST(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit); |
|
193 TEST(aMaximumLengthUpperLimit<=KBufferLength); |
|
194 TUint16 unicodeBuffer[KBufferLength]; |
|
195 for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i) |
|
196 { |
|
197 TPtr16 generatedFirstPartOfUnicode(unicodeBuffer, i); |
|
198 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
199 const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedFirstPartOfUnicode, aOriginalIso2022Jp, state); |
|
200 TEST(generatedFirstPartOfUnicode==aExpectedUnicode.Left(aExpectedLengthOfFirstPartOfUnicode)); |
|
201 TEST(returnValue==aExpectedNumberOfIso2022JpBytesNotConvertedAtSplit); |
|
202 TBuf16<KBufferLength> generatedSecondPartOfUnicode; |
|
203 TEST(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, aOriginalIso2022Jp.Right(aExpectedNumberOfIso2022JpBytesNotConvertedAtSplit), state)==0); |
|
204 TEST(generatedSecondPartOfUnicode==aExpectedUnicode.Mid(aExpectedLengthOfFirstPartOfUnicode)); |
|
205 TBuf8<KBufferLength> generatedIso2022Jp; |
|
206 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedIso2022Jp, generatedFirstPartOfUnicode)==0); |
|
207 TBuf8<KBufferLength> generatedSecondPartOfIso2022Jp; |
|
208 TEST(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfIso2022Jp, generatedSecondPartOfUnicode)==0); |
|
209 generatedIso2022Jp.Append(generatedSecondPartOfIso2022Jp); |
|
210 TBuf16<KBufferLength> regeneratedUnicode; |
|
211 state=CCnvCharacterSetConverter::KStateDefault; |
|
212 TEST(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, generatedIso2022Jp, state)==0); |
|
213 TEST(regeneratedUnicode==aExpectedUnicode); |
|
214 state=CCnvCharacterSetConverter::KStateDefault; |
|
215 TEST(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, aOriginalIso2022Jp, state)==0); |
|
216 TEST(regeneratedUnicode==aExpectedUnicode); |
|
217 } |
|
218 } |
|
219 /** |
|
220 @SYMTestCaseID SYSLIB-CHARCONV-CT-0527 |
|
221 @SYMTestCaseDesc Conversion of bad ISO2022JP format to Unicode test |
|
222 @SYMTestPriority Medium |
|
223 @SYMTestActions Tests to convert bad format ISO2022JP input to Unicode. |
|
224 @SYMTestExpectedResults Test must not fail |
|
225 @SYMREQ REQ0000 |
|
226 */ |
|
227 LOCAL_C void TestIsIllFormedIso2022Jp(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC8& aIso2022Jp) |
|
228 { |
|
229 TBuf16<50> generatedUnicode; |
|
230 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
231 TPtrC8 remainderOfIso2022Jp(aIso2022Jp); |
|
232 TInt lastReturnValue=KMaxTInt; |
|
233 FOREVER |
|
234 { |
|
235 const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, remainderOfIso2022Jp, state); |
|
236 if (returnValue==CCnvCharacterSetConverter::EErrorIllFormedInput) |
|
237 { |
|
238 break; |
|
239 } |
|
240 TEST(returnValue>0); |
|
241 TEST(returnValue<lastReturnValue); |
|
242 lastReturnValue=returnValue; |
|
243 remainderOfIso2022Jp.Set(remainderOfIso2022Jp.Right(returnValue)); |
|
244 } |
|
245 } |
|
246 /** |
|
247 @SYMTestCaseID SYSLIB-CHARCONV-CT-0528 |
|
248 @SYMTestCaseDesc ISO2022JP to Unicode and Unicode to ISO2022JP conversion tests |
|
249 @SYMTestPriority Medium |
|
250 @SYMTestActions Call up conversion of ISO2022JP to Unicode test functions |
|
251 @SYMTestExpectedResults Test must not fail |
|
252 @SYMREQ REQ0000 |
|
253 */ |
|
254 LOCAL_C void DoE32MainL() |
|
255 { |
|
256 RFs fileServerSession; |
|
257 CleanupClosePushL(fileServerSession); |
|
258 User::LeaveIfError(fileServerSession.Connect()); |
|
259 CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC(); |
|
260 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession); |
|
261 TheTest.Printf(_L("Available:\n")); |
|
262 TInt i; |
|
263 for (i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i) |
|
264 { |
|
265 const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i]; |
|
266 characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession); |
|
267 TPtrC charactersSetName(charactersSet.Name()); |
|
268 if (charactersSet.NameIsFileName()) |
|
269 { |
|
270 charactersSetName.Set(TParsePtrC(charactersSetName).Name()); |
|
271 } |
|
272 TheTest.Printf(_L(" %S\n"), &charactersSetName); |
|
273 } |
|
274 TheTest.Start(_L("Testing ISO-2022-JP conversions")); |
|
275 characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierIso2022Jp, *arrayOfCharacterSetsAvailable, fileServerSession); |
|
276 // |
|
277 TheTest.Next(_L("Empty descriptor")); |
|
278 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 0, 10, 0, KNullDesC8, KNullDesC8, KNullDesC16); |
|
279 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 0, 10, 0, 0, KNullDesC16, KNullDesC8); |
|
280 TheTest.Next(_L("Testing converting to ISO-2022-JP")); |
|
281 |
|
282 _LIT(KTestUnicode,">.@>0l90"); |
|
283 _LIT(KTestUnicode2,"\x0393\x03b1\x03c3\x03bf\x03c5\x3055\x3088"); |
|
284 TestConversionFromUnicodeToIso(*characterSetConverter, KTestUnicode2); |
|
285 TestConversionFromUnicodeToIso(*characterSetConverter, KTestUnicode); |
|
286 |
|
287 TBuf16<50> originalUnicode; |
|
288 originalUnicode.Format(_L16("%c%c%c%c%c\xa5\\%c%c%c%c%c"), 0x0393, 0x03b1, 0x03c3, 0x03bf, 0x03c5, 0x3055, 0x3088, 0x3046, 0x306a, 0x3089); |
|
289 TestTruncatedConversionFromUnicodeToIso2022Jp(*characterSetConverter, originalUnicode); |
|
290 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 3, 7, 12, _L8(""), _L8("\x1b\x24\x42\x26\x23\x26\x41\x26\x52\x26\x4f\x26\x54\x1b\x28\x4a\\\x1b\x28\x42\\\x1b\x24\x42\x24\x35\x24\x68\x24\x26\x24\x4a\x24\x69\x1b\x28\x42"), originalUnicode); |
|
291 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 8, 9, 11, _L8("\x1b\x24\x42\x26\x23\x1b\x28\x42"), _L8("\x1b\x24\x42\x26\x41\x26\x52\x26\x4f\x26\x54\x1b\x28\x4a\\\x1b\x28\x42\\\x1b\x24\x42\x24\x35\x24\x68\x24\x26\x24\x4a\x24\x69\x1b\x28\x42"), originalUnicode); |
|
292 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 10, 11, 10, _L8("\x1b\x24\x42\x26\x23\x26\x41\x1b\x28\x42"), _L8("\x1b\x24\x42\x26\x52\x26\x4f\x26\x54\x1b\x28\x4a\\\x1b\x28\x42\\\x1b\x24\x42\x24\x35\x24\x68\x24\x26\x24\x4a\x24\x69\x1b\x28\x42"), originalUnicode); |
|
293 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 12, 13, 9, _L8("\x1b\x24\x42\x26\x23\x26\x41\x26\x52\x1b\x28\x42"), _L8("\x1b\x24\x42\x26\x4f\x26\x54\x1b\x28\x4a\\\x1b\x28\x42\\\x1b\x24\x42\x24\x35\x24\x68\x24\x26\x24\x4a\x24\x69\x1b\x28\x42"), originalUnicode); |
|
294 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 14, 15, 8, _L8("\x1b\x24\x42\x26\x23\x26\x41\x26\x52\x26\x4f\x1b\x28\x42"), _L8("\x1b\x24\x42\x26\x54\x1b\x28\x4a\\\x1b\x28\x42\\\x1b\x24\x42\x24\x35\x24\x68\x24\x26\x24\x4a\x24\x69\x1b\x28\x42"), originalUnicode); |
|
295 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 16, 19, 7, _L8("\x1b\x24\x42\x26\x23\x26\x41\x26\x52\x26\x4f\x26\x54\x1b\x28\x42"), _L8("\x1b\x28\x4a\\\x1b\x28\x42\\\x1b\x24\x42\x24\x35\x24\x68\x24\x26\x24\x4a\x24\x69\x1b\x28\x42"), originalUnicode); |
|
296 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 20, 23, 6, _L8("\x1b\x24\x42\x26\x23\x26\x41\x26\x52\x26\x4f\x26\x54\x1b\x28\x4a\\\x1b\x28\x42"), _L8("\\\x1b\x24\x42\x24\x35\x24\x68\x24\x26\x24\x4a\x24\x69\x1b\x28\x42"), originalUnicode); |
|
297 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 24, 28, 5, _L8("\x1b\x24\x42\x26\x23\x26\x41\x26\x52\x26\x4f\x26\x54\x1b\x28\x4a\\\x1b\x28\x42\\"), _L8("\x1b\x24\x42\x24\x35\x24\x68\x24\x26\x24\x4a\x24\x69\x1b\x28\x42"), originalUnicode); |
|
298 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 29, 30, 4, _L8("\x1b\x24\x42\x26\x23\x26\x41\x26\x52\x26\x4f\x26\x54\x1b\x28\x4a\\\x1b\x28\x42\\\x1b\x24\x42\x24\x35\x1b\x28\x42"), _L8("\x1b\x24\x42\x24\x68\x24\x26\x24\x4a\x24\x69\x1b\x28\x42"), originalUnicode); |
|
299 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 31, 32, 3, _L8("\x1b\x24\x42\x26\x23\x26\x41\x26\x52\x26\x4f\x26\x54\x1b\x28\x4a\\\x1b\x28\x42\\\x1b\x24\x42\x24\x35\x24\x68\x1b\x28\x42"), _L8("\x1b\x24\x42\x24\x26\x24\x4a\x24\x69\x1b\x28\x42"), originalUnicode); |
|
300 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 33, 34, 2, _L8("\x1b\x24\x42\x26\x23\x26\x41\x26\x52\x26\x4f\x26\x54\x1b\x28\x4a\\\x1b\x28\x42\\\x1b\x24\x42\x24\x35\x24\x68\x24\x26\x1b\x28\x42"), _L8("\x1b\x24\x42\x24\x4a\x24\x69\x1b\x28\x42"), originalUnicode); |
|
301 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 35, 36, 1, _L8("\x1b\x24\x42\x26\x23\x26\x41\x26\x52\x26\x4f\x26\x54\x1b\x28\x4a\\\x1b\x28\x42\\\x1b\x24\x42\x24\x35\x24\x68\x24\x26\x24\x4a\x1b\x28\x42"), _L8("\x1b\x24\x42\x24\x69\x1b\x28\x42"), originalUnicode); |
|
302 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 37, 50, 0, _L8("\x1b\x24\x42\x26\x23\x26\x41\x26\x52\x26\x4f\x26\x54\x1b\x28\x4a\\\x1b\x28\x42\\\x1b\x24\x42\x24\x35\x24\x68\x24\x26\x24\x4a\x24\x69\x1b\x28\x42"), KNullDesC8, originalUnicode); |
|
303 originalUnicode.Format(_L16("%cX%cY%cZ"), 0x6153, 0x6376, 0x65d9); |
|
304 TestTruncatedConversionFromUnicodeToIso2022Jp(*characterSetConverter, originalUnicode); |
|
305 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 3, 7, 6, _L8(""), _L8("\x1b\x24\x42XX\x1b\x28\x42X\x1b\x24\x42YY\x1b\x28\x42Y\x1b\x24\x42ZZ\x1b\x28\x42Z"), originalUnicode); |
|
306 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 8, 11, 5, _L8("\x1b\x24\x42XX\x1b\x28\x42"), _L8("X\x1b\x24\x42YY\x1b\x28\x42Y\x1b\x24\x42ZZ\x1b\x28\x42Z"), originalUnicode); |
|
307 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 12, 16, 4, _L8("\x1b\x24\x42XX\x1b\x28\x42X"), _L8("\x1b\x24\x42YY\x1b\x28\x42Y\x1b\x24\x42ZZ\x1b\x28\x42Z"), originalUnicode); |
|
308 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 17, 20, 3, _L8("\x1b\x24\x42XX\x1b\x28\x42X\x1b\x24\x42YY\x1b\x28\x42"), _L8("Y\x1b\x24\x42ZZ\x1b\x28\x42Z"), originalUnicode); |
|
309 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 21, 25, 2, _L8("\x1b\x24\x42XX\x1b\x28\x42X\x1b\x24\x42YY\x1b\x28\x42Y"), _L8("\x1b\x24\x42ZZ\x1b\x28\x42Z"), originalUnicode); |
|
310 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 26, 29, 1, _L8("\x1b\x24\x42XX\x1b\x28\x42X\x1b\x24\x42YY\x1b\x28\x42Y\x1b\x24\x42ZZ\x1b\x28\x42"), _L8("Z"), originalUnicode); |
|
311 TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 30, 40, 0, _L8("\x1b\x24\x42XX\x1b\x28\x42X\x1b\x24\x42YY\x1b\x28\x42Y\x1b\x24\x42ZZ\x1b\x28\x42Z"), KNullDesC8, originalUnicode); |
|
312 TheTest.Next(_L("Testing converting to Unicode")); |
|
313 const TPtrC8 originalIso2022Jp(_S8("\x1b\x24\x40\x1b\x28\x4aMy name is \x1b\x28\x4a\x1b\x28\x42\x1b\x24\x40\x25\x47\x25\x23\x25\x53\x25\x45\x1b\x28\x4a in \x1b\x24\x42\x46\x7c\x4b\x5c\x38\x6c\x1b\x28\x42\\~\x1b\x28\x4a\\~")); |
|
314 TBuf16<50> expectedUnicode; |
|
315 expectedUnicode.Format(_L16("My name is %c%c%c%c in %c%c%c\\~%c%c"), 0x30c7, 0x30a3, 0x30d3, 0x30c5, 0x65e5, 0x672c, 0x8a9e, 0x00a5, 0x203e); |
|
316 TestTruncatedConversionToUnicodeFromIso2022Jp(*characterSetConverter, expectedUnicode, originalIso2022Jp); |
|
317 TestTruncatedConversionToUnicodeFromIso2022Jp(*characterSetConverter, _L16(" Hello"), _L8("\x1b\x24\x42\x1b\x28\x4a\x1b\x24\x42\x1b\x28\x4a\x1b\x24\x42\x1b\x28\x4a Hello")); |
|
318 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 0, 0, 60, 0, expectedUnicode, originalIso2022Jp); |
|
319 for (i=1; i<=10; ++i) |
|
320 { |
|
321 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, i, i, 54-i, i, expectedUnicode, originalIso2022Jp); |
|
322 } |
|
323 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 11, 11, 34, 11, expectedUnicode, originalIso2022Jp); |
|
324 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 12, 12, 32, 12, expectedUnicode, originalIso2022Jp); |
|
325 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 13, 13, 30, 13, expectedUnicode, originalIso2022Jp); |
|
326 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 14, 14, 28, 14, expectedUnicode, originalIso2022Jp); |
|
327 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 15, 15, 23, 15, expectedUnicode, originalIso2022Jp); |
|
328 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 16, 16, 22, 16, expectedUnicode, originalIso2022Jp); |
|
329 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 17, 17, 21, 17, expectedUnicode, originalIso2022Jp); |
|
330 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 18, 18, 20, 18, expectedUnicode, originalIso2022Jp); |
|
331 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 19, 19, 16, 19, expectedUnicode, originalIso2022Jp); |
|
332 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 20, 20, 14, 20, expectedUnicode, originalIso2022Jp); |
|
333 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 21, 21, 12, 21, expectedUnicode, originalIso2022Jp); |
|
334 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 22, 22, 7, 22, expectedUnicode, originalIso2022Jp); |
|
335 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 23, 23, 6, 23, expectedUnicode, originalIso2022Jp); |
|
336 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 24, 24, 2, 24, expectedUnicode, originalIso2022Jp); |
|
337 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 25, 25, 1, 25, expectedUnicode, originalIso2022Jp); |
|
338 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 26, 40, 0, 26, expectedUnicode, originalIso2022Jp); |
|
339 TheTest.Next(_L("Testing the default ISO-2022-JP state")); |
|
340 for (i=0; i<=6; ++i) |
|
341 { |
|
342 TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, i, i, 6-i, i, _L16("Hello\xa5"), _L8("Hello\\")); |
|
343 } |
|
344 TheTest.Next(_L("Testing ill-formed ISO-2022-JP")); |
|
345 TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x24\x42\x21\x1b\x28\x4a def")); |
|
346 TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x24\x42\x21\x21\x21\x1b\x28\x4a def")); |
|
347 TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x24\x42\x21\x21\x21\x21\x21\x1b\x28\x4a def")); |
|
348 TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b")); |
|
349 TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x24")); |
|
350 TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x24\xff")); |
|
351 TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x26\x40")); |
|
352 CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession |
|
353 } |
|
354 |
|
355 GLDEF_C TInt E32Main() |
|
356 { |
|
357 __UHEAP_MARK; |
|
358 |
|
359 TheTest.Title(); |
|
360 |
|
361 CTrapCleanup* trapCleanup=CTrapCleanup::New(); |
|
362 TEST(trapCleanup != NULL); |
|
363 |
|
364 TRAPD(error, DoE32MainL()); |
|
365 TEST2(error, KErrNone); |
|
366 |
|
367 delete trapCleanup; |
|
368 |
|
369 TheTest.End(); |
|
370 TheTest.Close(); |
|
371 |
|
372 __UHEAP_MARKEND; |
|
373 return KErrNone; |
|
374 } |
|
375 |