sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32std.h>
|
sl@0
|
20 |
#include <utf.h>
|
sl@0
|
21 |
#include "t_partial.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
#define test(cond) \
|
sl@0
|
24 |
{ \
|
sl@0
|
25 |
TBool __bb = (cond); \
|
sl@0
|
26 |
TEST(__bb); \
|
sl@0
|
27 |
if (!__bb) \
|
sl@0
|
28 |
{ \
|
sl@0
|
29 |
ERR_PRINTF1(_L("ERROR: Test Failed")); \
|
sl@0
|
30 |
User::Leave(1); \
|
sl@0
|
31 |
} \
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
|
sl@0
|
35 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
36 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
37 |
|
sl@0
|
38 |
const TInt KUtfBufferLength=100;
|
sl@0
|
39 |
const TUint KIllegalUtfByteValue=0xff;
|
sl@0
|
40 |
const TUint KIllegalUnicodeCharacter=0xffff;
|
sl@0
|
41 |
|
sl@0
|
42 |
LOCAL_C void FillWithIllegalUtf(TUint8* aUtfBuffer)
|
sl@0
|
43 |
{
|
sl@0
|
44 |
for (TInt i=0; i<KUtfBufferLength; ++i)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
aUtfBuffer[i]=KIllegalUtfByteValue;
|
sl@0
|
47 |
}
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
LOCAL_C TBool FillWithIllegalUtfReturningIfMatched(TUint8* aUtfBuffer, const TDes8& aDescriptorAroundBuffer, const TDesC8& aUtfToMatch)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
__ASSERT_ALWAYS(aDescriptorAroundBuffer.Ptr()==aUtfBuffer, User::Panic(_L("TPARTIAL"), 0));
|
sl@0
|
53 |
__ASSERT_ALWAYS(aDescriptorAroundBuffer.MaxLength()>=aUtfToMatch.Length(), User::Panic(_L("TPARTIAL"), 1));
|
sl@0
|
54 |
__ASSERT_ALWAYS(aDescriptorAroundBuffer.MaxLength()<=KUtfBufferLength, User::Panic(_L("TPARTIAL"), 2));
|
sl@0
|
55 |
TBool matched=TPtrC8(aUtfBuffer, aUtfToMatch.Length())==aUtfToMatch;
|
sl@0
|
56 |
if (matched)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
for (TInt i=aDescriptorAroundBuffer.MaxLength(); i<KUtfBufferLength; ++i)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
if (aUtfBuffer[i]!=KIllegalUtfByteValue)
|
sl@0
|
61 |
{
|
sl@0
|
62 |
matched=EFalse;
|
sl@0
|
63 |
break;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
}
|
sl@0
|
66 |
}
|
sl@0
|
67 |
FillWithIllegalUtf(aUtfBuffer);
|
sl@0
|
68 |
return matched;
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
LOCAL_C void FillWithIllegalUnicode(TUint16* aUnicodeBuffer)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
for (TInt i=0; i<KUtfBufferLength; ++i)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
aUnicodeBuffer[i]=KIllegalUnicodeCharacter;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
LOCAL_C TBool FillWithIllegalUnicodeReturningIfMatched(TUint16* aUnicodeBuffer, const TDesC16& aUnicodeToMatch)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
const TInt lengthToMatch=aUnicodeToMatch.Length();
|
sl@0
|
82 |
TBool matched=TPtrC16(aUnicodeBuffer, lengthToMatch)==aUnicodeToMatch;
|
sl@0
|
83 |
if (matched)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
for (TInt i=lengthToMatch; i<KUtfBufferLength; ++i)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
if (aUnicodeBuffer[i]!=KIllegalUnicodeCharacter)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
matched=EFalse;
|
sl@0
|
90 |
break;
|
sl@0
|
91 |
}
|
sl@0
|
92 |
}
|
sl@0
|
93 |
}
|
sl@0
|
94 |
FillWithIllegalUnicode(aUnicodeBuffer);
|
sl@0
|
95 |
return matched;
|
sl@0
|
96 |
}
|
sl@0
|
97 |
/**
|
sl@0
|
98 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0572
|
sl@0
|
99 |
@SYMTestCaseDesc Tests that partial conversions work
|
sl@0
|
100 |
@SYMTestPriority Medium
|
sl@0
|
101 |
@SYMTestActions Tests for converting to Unicode from UTF- 7
|
sl@0
|
102 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
103 |
@SYMREQ REQ0000
|
sl@0
|
104 |
*/
|
sl@0
|
105 |
void CT_PARTIAL::TestConvertingToUtf(TUint8* aUtfBuffer, TInt aMaximumLengthOfUtfDescriptor, const TDesC16& aUnicode, TBool aBoolParameter, TInt aNumberOfUnicodeItemsExpectedToBeConverted, const TDesC8& aFirstHalfOfUtfExpected, const TDesC8& aSecondHalfOfUtfExpected)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0572 "));
|
sl@0
|
108 |
TPtr8 utf(aUtfBuffer, aMaximumLengthOfUtfDescriptor);
|
sl@0
|
109 |
FillWithIllegalUtf(aUtfBuffer);
|
sl@0
|
110 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(utf, aUnicode, aBoolParameter)==aNumberOfUnicodeItemsExpectedToBeConverted);
|
sl@0
|
111 |
test(FillWithIllegalUtfReturningIfMatched(aUtfBuffer, utf, aFirstHalfOfUtfExpected));
|
sl@0
|
112 |
TPtr8 restOfUtf(aUtfBuffer, KUtfBufferLength);
|
sl@0
|
113 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(restOfUtf, aUnicode.Right(aNumberOfUnicodeItemsExpectedToBeConverted), aBoolParameter)==0);
|
sl@0
|
114 |
test(FillWithIllegalUtfReturningIfMatched(aUtfBuffer, restOfUtf, aSecondHalfOfUtfExpected));
|
sl@0
|
115 |
TBuf8<KUtfBufferLength> originalUtf(aFirstHalfOfUtfExpected);
|
sl@0
|
116 |
originalUtf.Append(aSecondHalfOfUtfExpected);
|
sl@0
|
117 |
TBuf16<20> generatedUnicode;
|
sl@0
|
118 |
TInt state=CnvUtfConverter::KStateDefault;
|
sl@0
|
119 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, originalUtf, state)==0);
|
sl@0
|
120 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
121 |
test(generatedUnicode==aUnicode);
|
sl@0
|
122 |
}
|
sl@0
|
123 |
/**
|
sl@0
|
124 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0573
|
sl@0
|
125 |
@SYMTestCaseDesc Tests that partial conversions work
|
sl@0
|
126 |
@SYMTestPriority Medium
|
sl@0
|
127 |
@SYMTestActions Tests for converting to Unicode from UTF- 7
|
sl@0
|
128 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
129 |
@SYMREQ REQ0000
|
sl@0
|
130 |
*/
|
sl@0
|
131 |
void CT_PARTIAL::TestUtf7StatePreservation(const TDesC8& aUtf7)
|
sl@0
|
132 |
{
|
sl@0
|
133 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0573 "));
|
sl@0
|
134 |
TInt state=CnvUtfConverter::KStateDefault;
|
sl@0
|
135 |
TBuf16<50> wholeGeneratedUnicode;
|
sl@0
|
136 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(wholeGeneratedUnicode, aUtf7, state)==0);
|
sl@0
|
137 |
for (TInt i=aUtf7.Length()-1; i>=0; --i)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
140 |
TBuf16<50> generatedUnicode1;
|
sl@0
|
141 |
TInt numberOfUtf7BytesNotConvertedByFirstCall=CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode1, aUtf7.Left(i), state);
|
sl@0
|
142 |
if (numberOfUtf7BytesNotConvertedByFirstCall<0)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
test(numberOfUtf7BytesNotConvertedByFirstCall==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
145 |
numberOfUtf7BytesNotConvertedByFirstCall=i;
|
sl@0
|
146 |
generatedUnicode1=KNullDesC16;
|
sl@0
|
147 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
148 |
}
|
sl@0
|
149 |
test(numberOfUtf7BytesNotConvertedByFirstCall>=0);
|
sl@0
|
150 |
TBuf16<50> generatedUnicode2;
|
sl@0
|
151 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode2, aUtf7.Mid(i-numberOfUtf7BytesNotConvertedByFirstCall), state)==0);
|
sl@0
|
152 |
generatedUnicode1+=generatedUnicode2;
|
sl@0
|
153 |
test(generatedUnicode1==wholeGeneratedUnicode);
|
sl@0
|
154 |
}
|
sl@0
|
155 |
}
|
sl@0
|
156 |
|
sl@0
|
157 |
void CT_PARTIAL::TestConvertingToUtf(TUint8* aUtfBuffer, TInt aMaximumLengthOfUtfDescriptor, const TDesC16& aUnicode, TInt aNumberOfUnicodeItemsExpectedToBeConverted, const TDesC8& aFirstHalfOfUtfExpected, const TDesC8& aSecondHalfOfUtfExpected)
|
sl@0
|
158 |
{
|
sl@0
|
159 |
TestConvertingToUtf(aUtfBuffer, aMaximumLengthOfUtfDescriptor, aUnicode, EFalse, aNumberOfUnicodeItemsExpectedToBeConverted, aFirstHalfOfUtfExpected, aSecondHalfOfUtfExpected);
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
void CT_PARTIAL::TestPARTIAL()
|
sl@0
|
163 |
{
|
sl@0
|
164 |
INFO_PRINTF1(_L("Checking that partial conversions work"));
|
sl@0
|
165 |
TUint8 utfBuffer[KUtfBufferLength];
|
sl@0
|
166 |
TUint16 unicodeBuffer[KUtfBufferLength];
|
sl@0
|
167 |
INFO_PRINTF1(_L("Testing trivial UTF-7 and UTF-8"));
|
sl@0
|
168 |
{
|
sl@0
|
169 |
for (TInt i=0; i<6; ++i)
|
sl@0
|
170 |
{
|
sl@0
|
171 |
const TInt numberOfUnconvertedItemsAtEndOfInputDescriptor=5-i;
|
sl@0
|
172 |
TPtr8 utf(utfBuffer, i);
|
sl@0
|
173 |
FillWithIllegalUtf(utfBuffer);
|
sl@0
|
174 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(utf, _L16("abcde"), EFalse)==numberOfUnconvertedItemsAtEndOfInputDescriptor);
|
sl@0
|
175 |
test(FillWithIllegalUtfReturningIfMatched(utfBuffer, utf, _L8("abcde").Left(i)));
|
sl@0
|
176 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(utf, _L16("abcde"), ETrue)==numberOfUnconvertedItemsAtEndOfInputDescriptor);
|
sl@0
|
177 |
test(FillWithIllegalUtfReturningIfMatched(utfBuffer, utf, _L8("abcde").Left(i)));
|
sl@0
|
178 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf8(utf, _L16("abcde"))==numberOfUnconvertedItemsAtEndOfInputDescriptor);
|
sl@0
|
179 |
test(FillWithIllegalUtfReturningIfMatched(utfBuffer, utf, _L8("abcde").Left(i)));
|
sl@0
|
180 |
TPtr16 unicode(unicodeBuffer, i);
|
sl@0
|
181 |
TInt state=CnvUtfConverter::KStateDefault;
|
sl@0
|
182 |
FillWithIllegalUnicode(unicodeBuffer);
|
sl@0
|
183 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(unicode, _L8("abcde"), state)==numberOfUnconvertedItemsAtEndOfInputDescriptor);
|
sl@0
|
184 |
test(FillWithIllegalUnicodeReturningIfMatched(unicodeBuffer, _L16("abcde").Left(i)));
|
sl@0
|
185 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
186 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(unicode, _L8("abcde"))==numberOfUnconvertedItemsAtEndOfInputDescriptor);
|
sl@0
|
187 |
test(FillWithIllegalUnicodeReturningIfMatched(unicodeBuffer, _L16("abcde").Left(i)));
|
sl@0
|
188 |
}
|
sl@0
|
189 |
}
|
sl@0
|
190 |
INFO_PRINTF1(_L("Testing converting to UTF-7"));
|
sl@0
|
191 |
{
|
sl@0
|
192 |
TBuf16<20> originalUnicode;
|
sl@0
|
193 |
TBuf16<20> generatedUnicode;
|
sl@0
|
194 |
TBuf8<20> generatedUtf;
|
sl@0
|
195 |
originalUnicode.Format(_L16("%c%c%c%c?"), 0x8fd9, 0x662f, 0x4ec0, 0x4e48); // Chinese: zhe4 shi4 shen2 me?
|
sl@0
|
196 |
TInt i;
|
sl@0
|
197 |
for (i=0; i<=4; ++i)
|
sl@0
|
198 |
{
|
sl@0
|
199 |
TestConvertingToUtf(utfBuffer, i, originalUnicode, 5, KNullDesC8, _L8("+j9lmL07ATkg-?"));
|
sl@0
|
200 |
}
|
sl@0
|
201 |
for (i=5; i<=7; ++i)
|
sl@0
|
202 |
{
|
sl@0
|
203 |
TestConvertingToUtf(utfBuffer, i, originalUnicode, 4, _L8("+j9k-"), _L8("+Zi9OwE5I-?"));
|
sl@0
|
204 |
}
|
sl@0
|
205 |
for (i=8; i<=9; ++i)
|
sl@0
|
206 |
{
|
sl@0
|
207 |
TestConvertingToUtf(utfBuffer, i, originalUnicode, 3, _L8("+j9lmLw-"), _L8("+TsBOSA-?"));
|
sl@0
|
208 |
}
|
sl@0
|
209 |
for (i=10; i<=12; ++i)
|
sl@0
|
210 |
{
|
sl@0
|
211 |
TestConvertingToUtf(utfBuffer, i, originalUnicode, 2, _L8("+j9lmL07A-"), _L8("+Tkg-?"));
|
sl@0
|
212 |
}
|
sl@0
|
213 |
TestConvertingToUtf(utfBuffer, 13, originalUnicode, 1, _L8("+j9lmL07ATkg-"), _L8("?"));
|
sl@0
|
214 |
TestConvertingToUtf(utfBuffer, 14, originalUnicode, 0, _L8("+j9lmL07ATkg-?"), KNullDesC8);
|
sl@0
|
215 |
originalUnicode.Format(_L16("%c %c%c %c%c%c%c."), 0x042f, 0x043d, 0x0435, 0x0437, 0x043d, 0x0430, 0x044e); // Russian: ya nye znayu.
|
sl@0
|
216 |
for (i=0; i<=4; ++i)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
TestConvertingToUtf(utfBuffer, i, originalUnicode, 10, KNullDesC8, _L8("+BC8- +BD0ENQ- +BDcEPQQwBE4-."));
|
sl@0
|
219 |
}
|
sl@0
|
220 |
TestConvertingToUtf(utfBuffer, 5, originalUnicode, 9, _L8("+BC8-"), _L8(" +BD0ENQ- +BDcEPQQwBE4-."));
|
sl@0
|
221 |
for (i=6; i<=10; ++i)
|
sl@0
|
222 |
{
|
sl@0
|
223 |
TestConvertingToUtf(utfBuffer, i, originalUnicode, 8, _L8("+BC8- "), _L8("+BD0ENQ- +BDcEPQQwBE4-."));
|
sl@0
|
224 |
}
|
sl@0
|
225 |
for (i=11; i<=13; ++i)
|
sl@0
|
226 |
{
|
sl@0
|
227 |
TestConvertingToUtf(utfBuffer, i, originalUnicode, 7, _L8("+BC8- +BD0-"), _L8("+BDU- +BDcEPQQwBE4-."));
|
sl@0
|
228 |
}
|
sl@0
|
229 |
TestConvertingToUtf(utfBuffer, 14, originalUnicode, 6, _L8("+BC8- +BD0ENQ-"), _L8(" +BDcEPQQwBE4-."));
|
sl@0
|
230 |
for (i=15; i<=19; ++i)
|
sl@0
|
231 |
{
|
sl@0
|
232 |
TestConvertingToUtf(utfBuffer, i, originalUnicode, 5, _L8("+BC8- +BD0ENQ- "), _L8("+BDcEPQQwBE4-."));
|
sl@0
|
233 |
}
|
sl@0
|
234 |
for (i=20; i<=22; ++i)
|
sl@0
|
235 |
{
|
sl@0
|
236 |
TestConvertingToUtf(utfBuffer, i, originalUnicode, 4, _L8("+BC8- +BD0ENQ- +BDc-"), _L8("+BD0EMARO-."));
|
sl@0
|
237 |
}
|
sl@0
|
238 |
for (i=23; i<=24; ++i)
|
sl@0
|
239 |
{
|
sl@0
|
240 |
TestConvertingToUtf(utfBuffer, i, originalUnicode, 3, _L8("+BC8- +BD0ENQ- +BDcEPQ-"), _L8("+BDAETg-."));
|
sl@0
|
241 |
}
|
sl@0
|
242 |
for (i=25; i<=27; ++i)
|
sl@0
|
243 |
{
|
sl@0
|
244 |
TestConvertingToUtf(utfBuffer, i, originalUnicode, 2, _L8("+BC8- +BD0ENQ- +BDcEPQQw-"), _L8("+BE4-."));
|
sl@0
|
245 |
}
|
sl@0
|
246 |
TestConvertingToUtf(utfBuffer, 28, originalUnicode, 1, _L8("+BC8- +BD0ENQ- +BDcEPQQwBE4-"), _L8("."));
|
sl@0
|
247 |
TestConvertingToUtf(utfBuffer, 29, originalUnicode, 0, _L8("+BC8- +BD0ENQ- +BDcEPQQwBE4-."), KNullDesC8);
|
sl@0
|
248 |
INFO_PRINTF1(_L("Testing converting UCS-2 ending in truncated sequences"));
|
sl@0
|
249 |
originalUnicode.Format(_L16(" %c"), 0xd800);
|
sl@0
|
250 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf, originalUnicode, EFalse)==0);
|
sl@0
|
251 |
test(generatedUtf==_L8(" +2AA-"));
|
sl@0
|
252 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf, originalUnicode, ETrue)==0);
|
sl@0
|
253 |
test(generatedUtf==_L8(" +2AA-"));
|
sl@0
|
254 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf8(generatedUtf, originalUnicode)==1);
|
sl@0
|
255 |
test(generatedUtf.Length()==1);
|
sl@0
|
256 |
test(generatedUtf[0]==' ');
|
sl@0
|
257 |
originalUnicode.Format(_L16("%c"), 0xd800);
|
sl@0
|
258 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf, originalUnicode, EFalse)==0);
|
sl@0
|
259 |
test(generatedUtf==_L8("+2AA-"));
|
sl@0
|
260 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf, originalUnicode, ETrue)==0);
|
sl@0
|
261 |
test(generatedUtf==_L8("+2AA-"));
|
sl@0
|
262 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf8(generatedUtf, originalUnicode)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
263 |
originalUnicode.Format(_L16("%c%c"), 0xd800, 0xdbff);
|
sl@0
|
264 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf8(generatedUtf, originalUnicode)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
265 |
|
sl@0
|
266 |
originalUnicode.Format(_L16("%c%c"), 0xd800, 0xdc00);
|
sl@0
|
267 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf8(generatedUtf, originalUnicode)==0);
|
sl@0
|
268 |
test(generatedUtf==_L8("\xf0\x90\x80\x80"));
|
sl@0
|
269 |
|
sl@0
|
270 |
INFO_PRINTF1(_L("Testing converting UTF-7 ending in truncated sequences"));
|
sl@0
|
271 |
TInt state=CnvUtfConverter::KStateDefault;
|
sl@0
|
272 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+"), state)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
273 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
274 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("e+"), state)==1);
|
sl@0
|
275 |
test(generatedUnicode.Length()==1);
|
sl@0
|
276 |
test(generatedUnicode[0]=='e');
|
sl@0
|
277 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
278 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
279 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+-"), state)==0);
|
sl@0
|
280 |
test(generatedUnicode==_L16("+"));
|
sl@0
|
281 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
282 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
283 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++"), state)==1);
|
sl@0
|
284 |
test(generatedUnicode.Length()==0);
|
sl@0
|
285 |
test(state!=CnvUtfConverter::KStateDefault);
|
sl@0
|
286 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+"), state)==CnvUtfConverter::EErrorIllFormedInput); // before resetting state
|
sl@0
|
287 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
288 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++-"), state)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
289 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
290 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+++"), state)==2);
|
sl@0
|
291 |
test(generatedUnicode.Length()==0);
|
sl@0
|
292 |
test(state!=CnvUtfConverter::KStateDefault);
|
sl@0
|
293 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++"), state)==CnvUtfConverter::EErrorIllFormedInput); // before resetting state
|
sl@0
|
294 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
295 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+++-"), state)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
296 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
297 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++"), state)==3);
|
sl@0
|
298 |
test(generatedUnicode.Length()==0);
|
sl@0
|
299 |
test(state!=CnvUtfConverter::KStateDefault);
|
sl@0
|
300 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+++"), state)==CnvUtfConverter::EErrorIllFormedInput); // before resetting state
|
sl@0
|
301 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
302 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++-"), state)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
303 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
304 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+++8"), state)==0);
|
sl@0
|
305 |
test(generatedUnicode.Length()==1);
|
sl@0
|
306 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
307 |
test(state!=CnvUtfConverter::KStateDefault); // this is imporant, as even though we've converted all the input UTF-7, the input may be being received in chunks, in which case, we need to make sure we remember when converting the next chunk that we were previously in a base-64 sequence
|
sl@0
|
308 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
309 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+++8-"), state)==0);
|
sl@0
|
310 |
test(generatedUnicode.Length()==1);
|
sl@0
|
311 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
312 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
313 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
314 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++/"), state)==1);
|
sl@0
|
315 |
test(generatedUnicode.Length()==1);
|
sl@0
|
316 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
317 |
test(state!=CnvUtfConverter::KStateDefault);
|
sl@0
|
318 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
319 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++/-"), state)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
320 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
321 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++//"), state)==2);
|
sl@0
|
322 |
test(generatedUnicode.Length()==1);
|
sl@0
|
323 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
324 |
test(state!=CnvUtfConverter::KStateDefault);
|
sl@0
|
325 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
326 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++//-"), state)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
327 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
328 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///"), state)==3);
|
sl@0
|
329 |
test(generatedUnicode.Length()==1);
|
sl@0
|
330 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
331 |
test(state!=CnvUtfConverter::KStateDefault);
|
sl@0
|
332 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
333 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///-"), state)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
334 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
335 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++//w"), state)==0);
|
sl@0
|
336 |
test(generatedUnicode.Length()==2);
|
sl@0
|
337 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
338 |
test(generatedUnicode[1]==0xbfff);
|
sl@0
|
339 |
test(state!=CnvUtfConverter::KStateDefault); // this is imporant, as even though we've converted all the input UTF-7, the input may be being received in chunks, in which case, we need to make sure we remember when converting the next chunk that we were previously in a base-64 sequence
|
sl@0
|
340 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
341 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++//w-"), state)==0);
|
sl@0
|
342 |
test(generatedUnicode.Length()==2);
|
sl@0
|
343 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
344 |
test(generatedUnicode[1]==0xbfff);
|
sl@0
|
345 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
346 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
347 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///h"), state)==1);
|
sl@0
|
348 |
test(generatedUnicode.Length()==2);
|
sl@0
|
349 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
350 |
test(generatedUnicode[1]==0xbfff);
|
sl@0
|
351 |
test(state!=CnvUtfConverter::KStateDefault);
|
sl@0
|
352 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
353 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///h-"), state)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
354 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
355 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hh"), state)==0);
|
sl@0
|
356 |
test(generatedUnicode.Length()==3);
|
sl@0
|
357 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
358 |
test(generatedUnicode[1]==0xbfff);
|
sl@0
|
359 |
test(generatedUnicode[2]==0xf861);
|
sl@0
|
360 |
test(state!=CnvUtfConverter::KStateDefault); // this is imporant, as even though we've converted all the input UTF-7, the input may be being received in chunks, in which case, we need to make sure we remember when converting the next chunk that we were previously in a base-64 sequence
|
sl@0
|
361 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
362 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hh-"), state)==0);
|
sl@0
|
363 |
test(generatedUnicode.Length()==3);
|
sl@0
|
364 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
365 |
test(generatedUnicode[1]==0xbfff);
|
sl@0
|
366 |
test(generatedUnicode[2]==0xf861);
|
sl@0
|
367 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
368 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
369 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hht"), state)==1);
|
sl@0
|
370 |
test(generatedUnicode.Length()==3);
|
sl@0
|
371 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
372 |
test(generatedUnicode[1]==0xbfff);
|
sl@0
|
373 |
test(generatedUnicode[2]==0xf861);
|
sl@0
|
374 |
test(state!=CnvUtfConverter::KStateDefault);
|
sl@0
|
375 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
376 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hht-"), state)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
377 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
378 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hhtt"), state)==2);
|
sl@0
|
379 |
test(generatedUnicode.Length()==3);
|
sl@0
|
380 |
test(generatedUnicode[0]==0xfbef);
|
sl@0
|
381 |
test(generatedUnicode[1]==0xbfff);
|
sl@0
|
382 |
test(generatedUnicode[2]==0xf861);
|
sl@0
|
383 |
test(state!=CnvUtfConverter::KStateDefault);
|
sl@0
|
384 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
385 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hhtt-"), state)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
386 |
state=CnvUtfConverter::KStateDefault;
|
sl@0
|
387 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+34-"), state)==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
388 |
TestUtf7StatePreservation(_L8("++34-"));
|
sl@0
|
389 |
TestUtf7StatePreservation(_L8("+rY4/5b+al3V98w-"));
|
sl@0
|
390 |
TestUtf7StatePreservation(_L8("+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/-"));
|
sl@0
|
391 |
INFO_PRINTF1(_L("Testing converting UTF-8 ending in truncated sequences"));
|
sl@0
|
392 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xc8"))==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
393 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("x\xc8"))==1);
|
sl@0
|
394 |
test(generatedUnicode.Length()==1);
|
sl@0
|
395 |
test(generatedUnicode[0]=='x');
|
sl@0
|
396 |
|
sl@0
|
397 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xc8\xc0"))==0);
|
sl@0
|
398 |
test(generatedUnicode[0]==0xfffd);
|
sl@0
|
399 |
test(generatedUnicode[1]==0xfffd);
|
sl@0
|
400 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xc8\xb0"))==0);
|
sl@0
|
401 |
test(generatedUnicode.Length()==1);
|
sl@0
|
402 |
test(generatedUnicode[0]==0x0230);
|
sl@0
|
403 |
|
sl@0
|
404 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xe4"))==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
405 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("y\xe4"))==1);
|
sl@0
|
406 |
test(generatedUnicode.Length()==1);
|
sl@0
|
407 |
test(generatedUnicode[0]=='y');
|
sl@0
|
408 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xe4\x80"))==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
409 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("H\xe4\x80"))==2);
|
sl@0
|
410 |
test(generatedUnicode.Length()==1);
|
sl@0
|
411 |
test(generatedUnicode[0]=='H');
|
sl@0
|
412 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xe4\xc0"))==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
413 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("e\xe4\xc0"))==2);
|
sl@0
|
414 |
test(generatedUnicode.Length()==1);
|
sl@0
|
415 |
test(generatedUnicode[0]=='e');
|
sl@0
|
416 |
|
sl@0
|
417 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xe4\x80\xc0"))==0);
|
sl@0
|
418 |
test(generatedUnicode[0]==0xfffd);
|
sl@0
|
419 |
test(generatedUnicode[1]==0xfffd);
|
sl@0
|
420 |
test(generatedUnicode[1]==0xfffd);
|
sl@0
|
421 |
|
sl@0
|
422 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xe4\x80\xb0"))==0);
|
sl@0
|
423 |
test(generatedUnicode.Length()==1);
|
sl@0
|
424 |
test(generatedUnicode[0]==0x4030);
|
sl@0
|
425 |
|
sl@0
|
426 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2"))==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
427 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("7\xf2"))==1);
|
sl@0
|
428 |
test(generatedUnicode.Length()==1);
|
sl@0
|
429 |
test(generatedUnicode[0]=='7');
|
sl@0
|
430 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\x80"))==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
431 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\\\xf2\x80"))==2);
|
sl@0
|
432 |
test(generatedUnicode.Length()==1);
|
sl@0
|
433 |
test(generatedUnicode[0]=='\\');
|
sl@0
|
434 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\xc0"))==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
435 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("$\xf2\xc0"))==2);
|
sl@0
|
436 |
test(generatedUnicode.Length()==1);
|
sl@0
|
437 |
test(generatedUnicode[0]=='$');
|
sl@0
|
438 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\x80\x80"))==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
439 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("{\xf2\x80\x80"))==3);
|
sl@0
|
440 |
test(generatedUnicode.Length()==1);
|
sl@0
|
441 |
test(generatedUnicode[0]=='{');
|
sl@0
|
442 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\x80\xc0"))==CnvUtfConverter::EErrorIllFormedInput);
|
sl@0
|
443 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8(" \xf2\x80\xc0"))==3);
|
sl@0
|
444 |
test(generatedUnicode.Length()==1);
|
sl@0
|
445 |
test(generatedUnicode[0]==' ');
|
sl@0
|
446 |
|
sl@0
|
447 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\x80\x80\xc0"))==0);
|
sl@0
|
448 |
test(generatedUnicode[0]==0xfffd);
|
sl@0
|
449 |
test(generatedUnicode[1]==0xfffd);
|
sl@0
|
450 |
test(generatedUnicode[2]==0xfffd);
|
sl@0
|
451 |
test(generatedUnicode[3]==0xfffd);
|
sl@0
|
452 |
|
sl@0
|
453 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\x80\x80\xb0"))==0);
|
sl@0
|
454 |
test(generatedUnicode.Length()==2);
|
sl@0
|
455 |
test(generatedUnicode[0]==0xd9c0);
|
sl@0
|
456 |
test(generatedUnicode[1]==0xdc30);
|
sl@0
|
457 |
}
|
sl@0
|
458 |
|
sl@0
|
459 |
}
|
sl@0
|
460 |
|
sl@0
|
461 |
CT_PARTIAL::CT_PARTIAL()
|
sl@0
|
462 |
{
|
sl@0
|
463 |
SetTestStepName(KTestStep_T_PARTIAL);
|
sl@0
|
464 |
}
|
sl@0
|
465 |
|
sl@0
|
466 |
TVerdict CT_PARTIAL::doTestStepL()
|
sl@0
|
467 |
{
|
sl@0
|
468 |
SetTestStepResult(EFail);
|
sl@0
|
469 |
|
sl@0
|
470 |
__UHEAP_MARK;
|
sl@0
|
471 |
|
sl@0
|
472 |
TRAPD(error1, TestPARTIAL());
|
sl@0
|
473 |
|
sl@0
|
474 |
__UHEAP_MARKEND;
|
sl@0
|
475 |
|
sl@0
|
476 |
if(error1 == KErrNone )
|
sl@0
|
477 |
{
|
sl@0
|
478 |
SetTestStepResult(EPass);
|
sl@0
|
479 |
}
|
sl@0
|
480 |
|
sl@0
|
481 |
return TestStepResult();
|
sl@0
|
482 |
}
|