1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/charconvfw/charconv_fw/test/rtest/tsrc/utf/tpartial.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,482 @@
1.4 +/*
1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <e32std.h>
1.23 +#include <utf.h>
1.24 +#include "t_partial.h"
1.25 +
1.26 +#define test(cond) \
1.27 + { \
1.28 + TBool __bb = (cond); \
1.29 + TEST(__bb); \
1.30 + if (!__bb) \
1.31 + { \
1.32 + ERR_PRINTF1(_L("ERROR: Test Failed")); \
1.33 + User::Leave(1); \
1.34 + } \
1.35 + }
1.36 +
1.37 +
1.38 +///////////////////////////////////////////////////////////////////////////////////////
1.39 +///////////////////////////////////////////////////////////////////////////////////////
1.40 +
1.41 +const TInt KUtfBufferLength=100;
1.42 +const TUint KIllegalUtfByteValue=0xff;
1.43 +const TUint KIllegalUnicodeCharacter=0xffff;
1.44 +
1.45 +LOCAL_C void FillWithIllegalUtf(TUint8* aUtfBuffer)
1.46 + {
1.47 + for (TInt i=0; i<KUtfBufferLength; ++i)
1.48 + {
1.49 + aUtfBuffer[i]=KIllegalUtfByteValue;
1.50 + }
1.51 + }
1.52 +
1.53 +LOCAL_C TBool FillWithIllegalUtfReturningIfMatched(TUint8* aUtfBuffer, const TDes8& aDescriptorAroundBuffer, const TDesC8& aUtfToMatch)
1.54 + {
1.55 + __ASSERT_ALWAYS(aDescriptorAroundBuffer.Ptr()==aUtfBuffer, User::Panic(_L("TPARTIAL"), 0));
1.56 + __ASSERT_ALWAYS(aDescriptorAroundBuffer.MaxLength()>=aUtfToMatch.Length(), User::Panic(_L("TPARTIAL"), 1));
1.57 + __ASSERT_ALWAYS(aDescriptorAroundBuffer.MaxLength()<=KUtfBufferLength, User::Panic(_L("TPARTIAL"), 2));
1.58 + TBool matched=TPtrC8(aUtfBuffer, aUtfToMatch.Length())==aUtfToMatch;
1.59 + if (matched)
1.60 + {
1.61 + for (TInt i=aDescriptorAroundBuffer.MaxLength(); i<KUtfBufferLength; ++i)
1.62 + {
1.63 + if (aUtfBuffer[i]!=KIllegalUtfByteValue)
1.64 + {
1.65 + matched=EFalse;
1.66 + break;
1.67 + }
1.68 + }
1.69 + }
1.70 + FillWithIllegalUtf(aUtfBuffer);
1.71 + return matched;
1.72 + }
1.73 +
1.74 +LOCAL_C void FillWithIllegalUnicode(TUint16* aUnicodeBuffer)
1.75 + {
1.76 + for (TInt i=0; i<KUtfBufferLength; ++i)
1.77 + {
1.78 + aUnicodeBuffer[i]=KIllegalUnicodeCharacter;
1.79 + }
1.80 + }
1.81 +
1.82 +LOCAL_C TBool FillWithIllegalUnicodeReturningIfMatched(TUint16* aUnicodeBuffer, const TDesC16& aUnicodeToMatch)
1.83 + {
1.84 + const TInt lengthToMatch=aUnicodeToMatch.Length();
1.85 + TBool matched=TPtrC16(aUnicodeBuffer, lengthToMatch)==aUnicodeToMatch;
1.86 + if (matched)
1.87 + {
1.88 + for (TInt i=lengthToMatch; i<KUtfBufferLength; ++i)
1.89 + {
1.90 + if (aUnicodeBuffer[i]!=KIllegalUnicodeCharacter)
1.91 + {
1.92 + matched=EFalse;
1.93 + break;
1.94 + }
1.95 + }
1.96 + }
1.97 + FillWithIllegalUnicode(aUnicodeBuffer);
1.98 + return matched;
1.99 + }
1.100 +/**
1.101 +@SYMTestCaseID SYSLIB-CHARCONV-CT-0572
1.102 +@SYMTestCaseDesc Tests that partial conversions work
1.103 +@SYMTestPriority Medium
1.104 +@SYMTestActions Tests for converting to Unicode from UTF- 7
1.105 +@SYMTestExpectedResults Test must not fail
1.106 +@SYMREQ REQ0000
1.107 +*/
1.108 +void CT_PARTIAL::TestConvertingToUtf(TUint8* aUtfBuffer, TInt aMaximumLengthOfUtfDescriptor, const TDesC16& aUnicode, TBool aBoolParameter, TInt aNumberOfUnicodeItemsExpectedToBeConverted, const TDesC8& aFirstHalfOfUtfExpected, const TDesC8& aSecondHalfOfUtfExpected)
1.109 + {
1.110 + INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0572 "));
1.111 + TPtr8 utf(aUtfBuffer, aMaximumLengthOfUtfDescriptor);
1.112 + FillWithIllegalUtf(aUtfBuffer);
1.113 + test(CnvUtfConverter::ConvertFromUnicodeToUtf7(utf, aUnicode, aBoolParameter)==aNumberOfUnicodeItemsExpectedToBeConverted);
1.114 + test(FillWithIllegalUtfReturningIfMatched(aUtfBuffer, utf, aFirstHalfOfUtfExpected));
1.115 + TPtr8 restOfUtf(aUtfBuffer, KUtfBufferLength);
1.116 + test(CnvUtfConverter::ConvertFromUnicodeToUtf7(restOfUtf, aUnicode.Right(aNumberOfUnicodeItemsExpectedToBeConverted), aBoolParameter)==0);
1.117 + test(FillWithIllegalUtfReturningIfMatched(aUtfBuffer, restOfUtf, aSecondHalfOfUtfExpected));
1.118 + TBuf8<KUtfBufferLength> originalUtf(aFirstHalfOfUtfExpected);
1.119 + originalUtf.Append(aSecondHalfOfUtfExpected);
1.120 + TBuf16<20> generatedUnicode;
1.121 + TInt state=CnvUtfConverter::KStateDefault;
1.122 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, originalUtf, state)==0);
1.123 + test(state==CnvUtfConverter::KStateDefault);
1.124 + test(generatedUnicode==aUnicode);
1.125 + }
1.126 +/**
1.127 +@SYMTestCaseID SYSLIB-CHARCONV-CT-0573
1.128 +@SYMTestCaseDesc Tests that partial conversions work
1.129 +@SYMTestPriority Medium
1.130 +@SYMTestActions Tests for converting to Unicode from UTF- 7
1.131 +@SYMTestExpectedResults Test must not fail
1.132 +@SYMREQ REQ0000
1.133 +*/
1.134 +void CT_PARTIAL::TestUtf7StatePreservation(const TDesC8& aUtf7)
1.135 + {
1.136 + INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0573 "));
1.137 + TInt state=CnvUtfConverter::KStateDefault;
1.138 + TBuf16<50> wholeGeneratedUnicode;
1.139 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(wholeGeneratedUnicode, aUtf7, state)==0);
1.140 + for (TInt i=aUtf7.Length()-1; i>=0; --i)
1.141 + {
1.142 + state=CnvUtfConverter::KStateDefault;
1.143 + TBuf16<50> generatedUnicode1;
1.144 + TInt numberOfUtf7BytesNotConvertedByFirstCall=CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode1, aUtf7.Left(i), state);
1.145 + if (numberOfUtf7BytesNotConvertedByFirstCall<0)
1.146 + {
1.147 + test(numberOfUtf7BytesNotConvertedByFirstCall==CnvUtfConverter::EErrorIllFormedInput);
1.148 + numberOfUtf7BytesNotConvertedByFirstCall=i;
1.149 + generatedUnicode1=KNullDesC16;
1.150 + state=CnvUtfConverter::KStateDefault;
1.151 + }
1.152 + test(numberOfUtf7BytesNotConvertedByFirstCall>=0);
1.153 + TBuf16<50> generatedUnicode2;
1.154 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode2, aUtf7.Mid(i-numberOfUtf7BytesNotConvertedByFirstCall), state)==0);
1.155 + generatedUnicode1+=generatedUnicode2;
1.156 + test(generatedUnicode1==wholeGeneratedUnicode);
1.157 + }
1.158 + }
1.159 +
1.160 +void CT_PARTIAL::TestConvertingToUtf(TUint8* aUtfBuffer, TInt aMaximumLengthOfUtfDescriptor, const TDesC16& aUnicode, TInt aNumberOfUnicodeItemsExpectedToBeConverted, const TDesC8& aFirstHalfOfUtfExpected, const TDesC8& aSecondHalfOfUtfExpected)
1.161 + {
1.162 + TestConvertingToUtf(aUtfBuffer, aMaximumLengthOfUtfDescriptor, aUnicode, EFalse, aNumberOfUnicodeItemsExpectedToBeConverted, aFirstHalfOfUtfExpected, aSecondHalfOfUtfExpected);
1.163 + }
1.164 +
1.165 +void CT_PARTIAL::TestPARTIAL()
1.166 + {
1.167 + INFO_PRINTF1(_L("Checking that partial conversions work"));
1.168 + TUint8 utfBuffer[KUtfBufferLength];
1.169 + TUint16 unicodeBuffer[KUtfBufferLength];
1.170 + INFO_PRINTF1(_L("Testing trivial UTF-7 and UTF-8"));
1.171 + {
1.172 + for (TInt i=0; i<6; ++i)
1.173 + {
1.174 + const TInt numberOfUnconvertedItemsAtEndOfInputDescriptor=5-i;
1.175 + TPtr8 utf(utfBuffer, i);
1.176 + FillWithIllegalUtf(utfBuffer);
1.177 + test(CnvUtfConverter::ConvertFromUnicodeToUtf7(utf, _L16("abcde"), EFalse)==numberOfUnconvertedItemsAtEndOfInputDescriptor);
1.178 + test(FillWithIllegalUtfReturningIfMatched(utfBuffer, utf, _L8("abcde").Left(i)));
1.179 + test(CnvUtfConverter::ConvertFromUnicodeToUtf7(utf, _L16("abcde"), ETrue)==numberOfUnconvertedItemsAtEndOfInputDescriptor);
1.180 + test(FillWithIllegalUtfReturningIfMatched(utfBuffer, utf, _L8("abcde").Left(i)));
1.181 + test(CnvUtfConverter::ConvertFromUnicodeToUtf8(utf, _L16("abcde"))==numberOfUnconvertedItemsAtEndOfInputDescriptor);
1.182 + test(FillWithIllegalUtfReturningIfMatched(utfBuffer, utf, _L8("abcde").Left(i)));
1.183 + TPtr16 unicode(unicodeBuffer, i);
1.184 + TInt state=CnvUtfConverter::KStateDefault;
1.185 + FillWithIllegalUnicode(unicodeBuffer);
1.186 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(unicode, _L8("abcde"), state)==numberOfUnconvertedItemsAtEndOfInputDescriptor);
1.187 + test(FillWithIllegalUnicodeReturningIfMatched(unicodeBuffer, _L16("abcde").Left(i)));
1.188 + test(state==CnvUtfConverter::KStateDefault);
1.189 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(unicode, _L8("abcde"))==numberOfUnconvertedItemsAtEndOfInputDescriptor);
1.190 + test(FillWithIllegalUnicodeReturningIfMatched(unicodeBuffer, _L16("abcde").Left(i)));
1.191 + }
1.192 + }
1.193 + INFO_PRINTF1(_L("Testing converting to UTF-7"));
1.194 + {
1.195 + TBuf16<20> originalUnicode;
1.196 + TBuf16<20> generatedUnicode;
1.197 + TBuf8<20> generatedUtf;
1.198 + originalUnicode.Format(_L16("%c%c%c%c?"), 0x8fd9, 0x662f, 0x4ec0, 0x4e48); // Chinese: zhe4 shi4 shen2 me?
1.199 + TInt i;
1.200 + for (i=0; i<=4; ++i)
1.201 + {
1.202 + TestConvertingToUtf(utfBuffer, i, originalUnicode, 5, KNullDesC8, _L8("+j9lmL07ATkg-?"));
1.203 + }
1.204 + for (i=5; i<=7; ++i)
1.205 + {
1.206 + TestConvertingToUtf(utfBuffer, i, originalUnicode, 4, _L8("+j9k-"), _L8("+Zi9OwE5I-?"));
1.207 + }
1.208 + for (i=8; i<=9; ++i)
1.209 + {
1.210 + TestConvertingToUtf(utfBuffer, i, originalUnicode, 3, _L8("+j9lmLw-"), _L8("+TsBOSA-?"));
1.211 + }
1.212 + for (i=10; i<=12; ++i)
1.213 + {
1.214 + TestConvertingToUtf(utfBuffer, i, originalUnicode, 2, _L8("+j9lmL07A-"), _L8("+Tkg-?"));
1.215 + }
1.216 + TestConvertingToUtf(utfBuffer, 13, originalUnicode, 1, _L8("+j9lmL07ATkg-"), _L8("?"));
1.217 + TestConvertingToUtf(utfBuffer, 14, originalUnicode, 0, _L8("+j9lmL07ATkg-?"), KNullDesC8);
1.218 + originalUnicode.Format(_L16("%c %c%c %c%c%c%c."), 0x042f, 0x043d, 0x0435, 0x0437, 0x043d, 0x0430, 0x044e); // Russian: ya nye znayu.
1.219 + for (i=0; i<=4; ++i)
1.220 + {
1.221 + TestConvertingToUtf(utfBuffer, i, originalUnicode, 10, KNullDesC8, _L8("+BC8- +BD0ENQ- +BDcEPQQwBE4-."));
1.222 + }
1.223 + TestConvertingToUtf(utfBuffer, 5, originalUnicode, 9, _L8("+BC8-"), _L8(" +BD0ENQ- +BDcEPQQwBE4-."));
1.224 + for (i=6; i<=10; ++i)
1.225 + {
1.226 + TestConvertingToUtf(utfBuffer, i, originalUnicode, 8, _L8("+BC8- "), _L8("+BD0ENQ- +BDcEPQQwBE4-."));
1.227 + }
1.228 + for (i=11; i<=13; ++i)
1.229 + {
1.230 + TestConvertingToUtf(utfBuffer, i, originalUnicode, 7, _L8("+BC8- +BD0-"), _L8("+BDU- +BDcEPQQwBE4-."));
1.231 + }
1.232 + TestConvertingToUtf(utfBuffer, 14, originalUnicode, 6, _L8("+BC8- +BD0ENQ-"), _L8(" +BDcEPQQwBE4-."));
1.233 + for (i=15; i<=19; ++i)
1.234 + {
1.235 + TestConvertingToUtf(utfBuffer, i, originalUnicode, 5, _L8("+BC8- +BD0ENQ- "), _L8("+BDcEPQQwBE4-."));
1.236 + }
1.237 + for (i=20; i<=22; ++i)
1.238 + {
1.239 + TestConvertingToUtf(utfBuffer, i, originalUnicode, 4, _L8("+BC8- +BD0ENQ- +BDc-"), _L8("+BD0EMARO-."));
1.240 + }
1.241 + for (i=23; i<=24; ++i)
1.242 + {
1.243 + TestConvertingToUtf(utfBuffer, i, originalUnicode, 3, _L8("+BC8- +BD0ENQ- +BDcEPQ-"), _L8("+BDAETg-."));
1.244 + }
1.245 + for (i=25; i<=27; ++i)
1.246 + {
1.247 + TestConvertingToUtf(utfBuffer, i, originalUnicode, 2, _L8("+BC8- +BD0ENQ- +BDcEPQQw-"), _L8("+BE4-."));
1.248 + }
1.249 + TestConvertingToUtf(utfBuffer, 28, originalUnicode, 1, _L8("+BC8- +BD0ENQ- +BDcEPQQwBE4-"), _L8("."));
1.250 + TestConvertingToUtf(utfBuffer, 29, originalUnicode, 0, _L8("+BC8- +BD0ENQ- +BDcEPQQwBE4-."), KNullDesC8);
1.251 + INFO_PRINTF1(_L("Testing converting UCS-2 ending in truncated sequences"));
1.252 + originalUnicode.Format(_L16(" %c"), 0xd800);
1.253 + test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf, originalUnicode, EFalse)==0);
1.254 + test(generatedUtf==_L8(" +2AA-"));
1.255 + test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf, originalUnicode, ETrue)==0);
1.256 + test(generatedUtf==_L8(" +2AA-"));
1.257 + test(CnvUtfConverter::ConvertFromUnicodeToUtf8(generatedUtf, originalUnicode)==1);
1.258 + test(generatedUtf.Length()==1);
1.259 + test(generatedUtf[0]==' ');
1.260 + originalUnicode.Format(_L16("%c"), 0xd800);
1.261 + test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf, originalUnicode, EFalse)==0);
1.262 + test(generatedUtf==_L8("+2AA-"));
1.263 + test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf, originalUnicode, ETrue)==0);
1.264 + test(generatedUtf==_L8("+2AA-"));
1.265 + test(CnvUtfConverter::ConvertFromUnicodeToUtf8(generatedUtf, originalUnicode)==CnvUtfConverter::EErrorIllFormedInput);
1.266 + originalUnicode.Format(_L16("%c%c"), 0xd800, 0xdbff);
1.267 + test(CnvUtfConverter::ConvertFromUnicodeToUtf8(generatedUtf, originalUnicode)==CnvUtfConverter::EErrorIllFormedInput);
1.268 +
1.269 + originalUnicode.Format(_L16("%c%c"), 0xd800, 0xdc00);
1.270 + test(CnvUtfConverter::ConvertFromUnicodeToUtf8(generatedUtf, originalUnicode)==0);
1.271 + test(generatedUtf==_L8("\xf0\x90\x80\x80"));
1.272 +
1.273 + INFO_PRINTF1(_L("Testing converting UTF-7 ending in truncated sequences"));
1.274 + TInt state=CnvUtfConverter::KStateDefault;
1.275 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+"), state)==CnvUtfConverter::EErrorIllFormedInput);
1.276 + state=CnvUtfConverter::KStateDefault;
1.277 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("e+"), state)==1);
1.278 + test(generatedUnicode.Length()==1);
1.279 + test(generatedUnicode[0]=='e');
1.280 + test(state==CnvUtfConverter::KStateDefault);
1.281 + state=CnvUtfConverter::KStateDefault;
1.282 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+-"), state)==0);
1.283 + test(generatedUnicode==_L16("+"));
1.284 + test(state==CnvUtfConverter::KStateDefault);
1.285 + state=CnvUtfConverter::KStateDefault;
1.286 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++"), state)==1);
1.287 + test(generatedUnicode.Length()==0);
1.288 + test(state!=CnvUtfConverter::KStateDefault);
1.289 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+"), state)==CnvUtfConverter::EErrorIllFormedInput); // before resetting state
1.290 + state=CnvUtfConverter::KStateDefault;
1.291 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++-"), state)==CnvUtfConverter::EErrorIllFormedInput);
1.292 + state=CnvUtfConverter::KStateDefault;
1.293 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+++"), state)==2);
1.294 + test(generatedUnicode.Length()==0);
1.295 + test(state!=CnvUtfConverter::KStateDefault);
1.296 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++"), state)==CnvUtfConverter::EErrorIllFormedInput); // before resetting state
1.297 + state=CnvUtfConverter::KStateDefault;
1.298 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+++-"), state)==CnvUtfConverter::EErrorIllFormedInput);
1.299 + state=CnvUtfConverter::KStateDefault;
1.300 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++"), state)==3);
1.301 + test(generatedUnicode.Length()==0);
1.302 + test(state!=CnvUtfConverter::KStateDefault);
1.303 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+++"), state)==CnvUtfConverter::EErrorIllFormedInput); // before resetting state
1.304 + state=CnvUtfConverter::KStateDefault;
1.305 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++-"), state)==CnvUtfConverter::EErrorIllFormedInput);
1.306 + state=CnvUtfConverter::KStateDefault;
1.307 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+++8"), state)==0);
1.308 + test(generatedUnicode.Length()==1);
1.309 + test(generatedUnicode[0]==0xfbef);
1.310 + 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
1.311 + state=CnvUtfConverter::KStateDefault;
1.312 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+++8-"), state)==0);
1.313 + test(generatedUnicode.Length()==1);
1.314 + test(generatedUnicode[0]==0xfbef);
1.315 + test(state==CnvUtfConverter::KStateDefault);
1.316 + state=CnvUtfConverter::KStateDefault;
1.317 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++/"), state)==1);
1.318 + test(generatedUnicode.Length()==1);
1.319 + test(generatedUnicode[0]==0xfbef);
1.320 + test(state!=CnvUtfConverter::KStateDefault);
1.321 + state=CnvUtfConverter::KStateDefault;
1.322 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++/-"), state)==CnvUtfConverter::EErrorIllFormedInput);
1.323 + state=CnvUtfConverter::KStateDefault;
1.324 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++//"), state)==2);
1.325 + test(generatedUnicode.Length()==1);
1.326 + test(generatedUnicode[0]==0xfbef);
1.327 + test(state!=CnvUtfConverter::KStateDefault);
1.328 + state=CnvUtfConverter::KStateDefault;
1.329 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++//-"), state)==CnvUtfConverter::EErrorIllFormedInput);
1.330 + state=CnvUtfConverter::KStateDefault;
1.331 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///"), state)==3);
1.332 + test(generatedUnicode.Length()==1);
1.333 + test(generatedUnicode[0]==0xfbef);
1.334 + test(state!=CnvUtfConverter::KStateDefault);
1.335 + state=CnvUtfConverter::KStateDefault;
1.336 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///-"), state)==CnvUtfConverter::EErrorIllFormedInput);
1.337 + state=CnvUtfConverter::KStateDefault;
1.338 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++//w"), state)==0);
1.339 + test(generatedUnicode.Length()==2);
1.340 + test(generatedUnicode[0]==0xfbef);
1.341 + test(generatedUnicode[1]==0xbfff);
1.342 + 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
1.343 + state=CnvUtfConverter::KStateDefault;
1.344 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++//w-"), state)==0);
1.345 + test(generatedUnicode.Length()==2);
1.346 + test(generatedUnicode[0]==0xfbef);
1.347 + test(generatedUnicode[1]==0xbfff);
1.348 + test(state==CnvUtfConverter::KStateDefault);
1.349 + state=CnvUtfConverter::KStateDefault;
1.350 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///h"), state)==1);
1.351 + test(generatedUnicode.Length()==2);
1.352 + test(generatedUnicode[0]==0xfbef);
1.353 + test(generatedUnicode[1]==0xbfff);
1.354 + test(state!=CnvUtfConverter::KStateDefault);
1.355 + state=CnvUtfConverter::KStateDefault;
1.356 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///h-"), state)==CnvUtfConverter::EErrorIllFormedInput);
1.357 + state=CnvUtfConverter::KStateDefault;
1.358 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hh"), state)==0);
1.359 + test(generatedUnicode.Length()==3);
1.360 + test(generatedUnicode[0]==0xfbef);
1.361 + test(generatedUnicode[1]==0xbfff);
1.362 + test(generatedUnicode[2]==0xf861);
1.363 + 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
1.364 + state=CnvUtfConverter::KStateDefault;
1.365 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hh-"), state)==0);
1.366 + test(generatedUnicode.Length()==3);
1.367 + test(generatedUnicode[0]==0xfbef);
1.368 + test(generatedUnicode[1]==0xbfff);
1.369 + test(generatedUnicode[2]==0xf861);
1.370 + test(state==CnvUtfConverter::KStateDefault);
1.371 + state=CnvUtfConverter::KStateDefault;
1.372 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hht"), state)==1);
1.373 + test(generatedUnicode.Length()==3);
1.374 + test(generatedUnicode[0]==0xfbef);
1.375 + test(generatedUnicode[1]==0xbfff);
1.376 + test(generatedUnicode[2]==0xf861);
1.377 + test(state!=CnvUtfConverter::KStateDefault);
1.378 + state=CnvUtfConverter::KStateDefault;
1.379 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hht-"), state)==CnvUtfConverter::EErrorIllFormedInput);
1.380 + state=CnvUtfConverter::KStateDefault;
1.381 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hhtt"), state)==2);
1.382 + test(generatedUnicode.Length()==3);
1.383 + test(generatedUnicode[0]==0xfbef);
1.384 + test(generatedUnicode[1]==0xbfff);
1.385 + test(generatedUnicode[2]==0xf861);
1.386 + test(state!=CnvUtfConverter::KStateDefault);
1.387 + state=CnvUtfConverter::KStateDefault;
1.388 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("++++///hhtt-"), state)==CnvUtfConverter::EErrorIllFormedInput);
1.389 + state=CnvUtfConverter::KStateDefault;
1.390 + test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+34-"), state)==CnvUtfConverter::EErrorIllFormedInput);
1.391 + TestUtf7StatePreservation(_L8("++34-"));
1.392 + TestUtf7StatePreservation(_L8("+rY4/5b+al3V98w-"));
1.393 + TestUtf7StatePreservation(_L8("+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/-"));
1.394 + INFO_PRINTF1(_L("Testing converting UTF-8 ending in truncated sequences"));
1.395 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xc8"))==CnvUtfConverter::EErrorIllFormedInput);
1.396 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("x\xc8"))==1);
1.397 + test(generatedUnicode.Length()==1);
1.398 + test(generatedUnicode[0]=='x');
1.399 +
1.400 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xc8\xc0"))==0);
1.401 + test(generatedUnicode[0]==0xfffd);
1.402 + test(generatedUnicode[1]==0xfffd);
1.403 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xc8\xb0"))==0);
1.404 + test(generatedUnicode.Length()==1);
1.405 + test(generatedUnicode[0]==0x0230);
1.406 +
1.407 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xe4"))==CnvUtfConverter::EErrorIllFormedInput);
1.408 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("y\xe4"))==1);
1.409 + test(generatedUnicode.Length()==1);
1.410 + test(generatedUnicode[0]=='y');
1.411 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xe4\x80"))==CnvUtfConverter::EErrorIllFormedInput);
1.412 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("H\xe4\x80"))==2);
1.413 + test(generatedUnicode.Length()==1);
1.414 + test(generatedUnicode[0]=='H');
1.415 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xe4\xc0"))==CnvUtfConverter::EErrorIllFormedInput);
1.416 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("e\xe4\xc0"))==2);
1.417 + test(generatedUnicode.Length()==1);
1.418 + test(generatedUnicode[0]=='e');
1.419 +
1.420 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xe4\x80\xc0"))==0);
1.421 + test(generatedUnicode[0]==0xfffd);
1.422 + test(generatedUnicode[1]==0xfffd);
1.423 + test(generatedUnicode[1]==0xfffd);
1.424 +
1.425 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xe4\x80\xb0"))==0);
1.426 + test(generatedUnicode.Length()==1);
1.427 + test(generatedUnicode[0]==0x4030);
1.428 +
1.429 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2"))==CnvUtfConverter::EErrorIllFormedInput);
1.430 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("7\xf2"))==1);
1.431 + test(generatedUnicode.Length()==1);
1.432 + test(generatedUnicode[0]=='7');
1.433 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\x80"))==CnvUtfConverter::EErrorIllFormedInput);
1.434 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\\\xf2\x80"))==2);
1.435 + test(generatedUnicode.Length()==1);
1.436 + test(generatedUnicode[0]=='\\');
1.437 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\xc0"))==CnvUtfConverter::EErrorIllFormedInput);
1.438 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("$\xf2\xc0"))==2);
1.439 + test(generatedUnicode.Length()==1);
1.440 + test(generatedUnicode[0]=='$');
1.441 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\x80\x80"))==CnvUtfConverter::EErrorIllFormedInput);
1.442 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("{\xf2\x80\x80"))==3);
1.443 + test(generatedUnicode.Length()==1);
1.444 + test(generatedUnicode[0]=='{');
1.445 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\x80\xc0"))==CnvUtfConverter::EErrorIllFormedInput);
1.446 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8(" \xf2\x80\xc0"))==3);
1.447 + test(generatedUnicode.Length()==1);
1.448 + test(generatedUnicode[0]==' ');
1.449 +
1.450 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\x80\x80\xc0"))==0);
1.451 + test(generatedUnicode[0]==0xfffd);
1.452 + test(generatedUnicode[1]==0xfffd);
1.453 + test(generatedUnicode[2]==0xfffd);
1.454 + test(generatedUnicode[3]==0xfffd);
1.455 +
1.456 + test(CnvUtfConverter::ConvertToUnicodeFromUtf8(generatedUnicode, _L8("\xf2\x80\x80\xb0"))==0);
1.457 + test(generatedUnicode.Length()==2);
1.458 + test(generatedUnicode[0]==0xd9c0);
1.459 + test(generatedUnicode[1]==0xdc30);
1.460 + }
1.461 +
1.462 + }
1.463 +
1.464 +CT_PARTIAL::CT_PARTIAL()
1.465 + {
1.466 + SetTestStepName(KTestStep_T_PARTIAL);
1.467 + }
1.468 +
1.469 +TVerdict CT_PARTIAL::doTestStepL()
1.470 + {
1.471 + SetTestStepResult(EFail);
1.472 +
1.473 + __UHEAP_MARK;
1.474 +
1.475 + TRAPD(error1, TestPARTIAL());
1.476 +
1.477 + __UHEAP_MARKEND;
1.478 +
1.479 + if(error1 == KErrNone )
1.480 + {
1.481 + SetTestStepResult(EPass);
1.482 + }
1.483 +
1.484 + return TestStepResult();
1.485 + }