os/textandloc/charconvfw/charconvplugins/test/rtest/tsrc/main/t_iso2022jp.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2000-2010 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 <e32base.h>
sl@0
    21
#include <f32file.h>
sl@0
    22
#include <charconv.h>
sl@0
    23
#include "t_iso2022jp.h"
sl@0
    24
sl@0
    25
#define test(cond)                                  \
sl@0
    26
    {                                               \
sl@0
    27
    TBool __bb = (cond);                            \
sl@0
    28
    TEST(__bb);                                     \
sl@0
    29
    if (!__bb)                                      \
sl@0
    30
        {                                           \
sl@0
    31
        ERR_PRINTF1(_L("ERROR: Test Failed"));      \
sl@0
    32
        User::Leave(1);                             \
sl@0
    33
        }                                           \
sl@0
    34
    }
sl@0
    35
sl@0
    36
const TInt KBufferLength=100;
sl@0
    37
const TInt KNotEnoughBufferLength=17;
sl@0
    38
/**
sl@0
    39
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0522
sl@0
    40
@SYMTestCaseDesc        Tests for conversion from Unicode to ISO2022JP
sl@0
    41
@SYMTestPriority        Medium
sl@0
    42
@SYMTestActions         Tests for conversion from Unicode to ISO2022JP and back to Unicode
sl@0
    43
@SYMTestExpectedResults Test must not fail
sl@0
    44
@SYMREQ                 REQ0000
sl@0
    45
*/
sl@0
    46
void CT_ISO2022JP::TestConversionFromUnicodeToIso(
sl@0
    47
                CCnvCharacterSetConverter& aCharacterSetConverter,
sl@0
    48
                const TDesC16& aOriginalUnicode)
sl@0
    49
 	{
sl@0
    50
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0522 "));
sl@0
    51
 	TBuf8<KNotEnoughBufferLength> generatedIso2022Jp;
sl@0
    52
	generatedIso2022Jp.FillZ(KNotEnoughBufferLength);
sl@0
    53
 	const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedIso2022Jp, aOriginalUnicode);
sl@0
    54
 	test(returnValue>=0);
sl@0
    55
 	TInt state=CCnvCharacterSetConverter::KStateDefault;
sl@0
    56
 	TBuf16<KBufferLength> generatedUnicode;
sl@0
    57
	TInt testresult;
sl@0
    58
	testresult=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedIso2022Jp, state);
sl@0
    59
 	test(testresult==0);
sl@0
    60
 //	test(generatedUnicode==aOriginalUnicode);
sl@0
    61
 	}
sl@0
    62
/**
sl@0
    63
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0523
sl@0
    64
@SYMTestCaseDesc        Tests for truncated conversion from Unicode to ISO2022JP
sl@0
    65
@SYMTestPriority        Medium
sl@0
    66
@SYMTestActions         Tests for truncated conversion from Unicode to ISO2022JP and back to Unicode
sl@0
    67
@SYMTestExpectedResults Test must not fail
sl@0
    68
@SYMREQ                 REQ0000
sl@0
    69
*/
sl@0
    70
void CT_ISO2022JP::TestTruncatedConversionFromUnicodeToIso2022Jp(
sl@0
    71
                CCnvCharacterSetConverter& aCharacterSetConverter,
sl@0
    72
                const TDesC16& aOriginalUnicode)
sl@0
    73
	{
sl@0
    74
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0523 "));
sl@0
    75
	for (TInt i=aOriginalUnicode.Length(); i>=0; --i)
sl@0
    76
		{
sl@0
    77
		TBuf8<KBufferLength> generatedIso2022Jp;
sl@0
    78
		const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedIso2022Jp, aOriginalUnicode.Left(i));
sl@0
    79
		test(returnValue>=0);
sl@0
    80
		TBuf8<KBufferLength> generatedsecondPartOfIso2022Jp;
sl@0
    81
		test(aCharacterSetConverter.ConvertFromUnicode(generatedsecondPartOfIso2022Jp, aOriginalUnicode.Mid(i-returnValue))==0);
sl@0
    82
		generatedIso2022Jp.Append(generatedsecondPartOfIso2022Jp);
sl@0
    83
		TInt state=CCnvCharacterSetConverter::KStateDefault;
sl@0
    84
		TBuf16<KBufferLength> generatedUnicode;
sl@0
    85
		test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedIso2022Jp, state)==0);
sl@0
    86
		test(generatedUnicode==aOriginalUnicode);
sl@0
    87
		}
sl@0
    88
	}
sl@0
    89
/**
sl@0
    90
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0524
sl@0
    91
@SYMTestCaseDesc        Splitting and converting from Unicode to ISO2022JP test
sl@0
    92
@SYMTestPriority        Medium
sl@0
    93
@SYMTestActions         Tests for conversion after splitting, from Unicode to ISO2022JP and back to Unicode
sl@0
    94
@SYMTestExpectedResults Test must not fail
sl@0
    95
@SYMREQ                 REQ0000
sl@0
    96
*/
sl@0
    97
void CT_ISO2022JP::TestSplittingConvertingFromUnicodeToIso2022Jp(
sl@0
    98
                CCnvCharacterSetConverter& aCharacterSetConverter,
sl@0
    99
                TInt aMaximumLengthLowerLimit,
sl@0
   100
                TInt aMaximumLengthUpperLimit,
sl@0
   101
                TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit,
sl@0
   102
                const TDesC8& aExpectedFirstPartOfIso2022Jp,
sl@0
   103
                const TDesC8& aExpectedSecondPartOfIso2022Jp,
sl@0
   104
                const TDesC16& aOriginalUnicode)
sl@0
   105
	{
sl@0
   106
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0524 "));
sl@0
   107
	test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
sl@0
   108
	test(aMaximumLengthUpperLimit<=KBufferLength);
sl@0
   109
	TUint8 iso2022JpBuffer[KBufferLength];
sl@0
   110
	for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
sl@0
   111
		{
sl@0
   112
		TPtr8 generatedFirstPartOfIso2022Jp(iso2022JpBuffer, i);
sl@0
   113
		test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfIso2022Jp, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit);
sl@0
   114
		test(generatedFirstPartOfIso2022Jp==aExpectedFirstPartOfIso2022Jp);
sl@0
   115
		TBuf8<KBufferLength> generatedSecondPartOfIso2022Jp;
sl@0
   116
		test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfIso2022Jp, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0);
sl@0
   117
		test(generatedSecondPartOfIso2022Jp==aExpectedSecondPartOfIso2022Jp);
sl@0
   118
		TInt state=CCnvCharacterSetConverter::KStateDefault;
sl@0
   119
		TBuf16<KBufferLength> generatedUnicode;
sl@0
   120
		test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfIso2022Jp, state)==0);
sl@0
   121
		TBuf16<KBufferLength> generatedSecondPartOfUnicode;
sl@0
   122
		test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfIso2022Jp, state)==0);
sl@0
   123
		generatedUnicode.Append(generatedSecondPartOfUnicode);
sl@0
   124
		test(generatedUnicode==aOriginalUnicode);
sl@0
   125
		}
sl@0
   126
	}
sl@0
   127
/**
sl@0
   128
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0525
sl@0
   129
@SYMTestCaseDesc        Tests for truncated conversion from ISO2022JP to Unicode test
sl@0
   130
@SYMTestPriority        Medium
sl@0
   131
@SYMTestActions         Tests for truncated conversion from ISO2022JP to Unicode and back to ISO2022JP
sl@0
   132
@SYMTestExpectedResults Test must not fail
sl@0
   133
@SYMREQ                 REQ0000
sl@0
   134
*/
sl@0
   135
void CT_ISO2022JP::TestTruncatedConversionToUnicodeFromIso2022Jp(
sl@0
   136
                CCnvCharacterSetConverter& aCharacterSetConverter,
sl@0
   137
                const TDesC16& aExpectedUnicode,
sl@0
   138
                const TDesC8& aOriginalIso2022Jp)
sl@0
   139
	{
sl@0
   140
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0525 "));
sl@0
   141
	for (TInt i=aOriginalIso2022Jp.Length(); i>=3; --i) // 3 is the length of ISO-2022-JP's longest escape sequence
sl@0
   142
		{
sl@0
   143
		TInt state=CCnvCharacterSetConverter::KStateDefault;
sl@0
   144
		TBuf16<KBufferLength> generatedUnicode;
sl@0
   145
		const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalIso2022Jp.Left(i), state);
sl@0
   146
		test(returnValue>=0);
sl@0
   147
		TBuf16<KBufferLength> generatedsecondPartOfUnicode;
sl@0
   148
		test(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalIso2022Jp.Mid(i-returnValue), state)==0);
sl@0
   149
		generatedUnicode.Append(generatedsecondPartOfUnicode);
sl@0
   150
		test(generatedUnicode==aExpectedUnicode);
sl@0
   151
		}
sl@0
   152
	}
sl@0
   153
/**
sl@0
   154
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0526
sl@0
   155
@SYMTestCaseDesc        Splitting and converting from ISO2022JP to Unicode test.
sl@0
   156
@SYMTestPriority        Medium
sl@0
   157
@SYMTestActions         Tests for conversion after splitting, from ISO2022JP to Unicode and back to ISO2022JP
sl@0
   158
@SYMTestExpectedResults Test must not fail
sl@0
   159
@SYMREQ                 REQ0000
sl@0
   160
*/
sl@0
   161
void CT_ISO2022JP::TestSplittingConvertingToUnicodeFromIso2022Jp(
sl@0
   162
                CCnvCharacterSetConverter& aCharacterSetConverter,
sl@0
   163
                TInt aMaximumLengthLowerLimit,
sl@0
   164
                TInt aMaximumLengthUpperLimit,
sl@0
   165
                TInt aExpectedNumberOfIso2022JpBytesNotConvertedAtSplit,
sl@0
   166
                TInt aExpectedLengthOfFirstPartOfUnicode,
sl@0
   167
                const TDesC16& aExpectedUnicode,
sl@0
   168
                const TDesC8& aOriginalIso2022Jp)
sl@0
   169
	{
sl@0
   170
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0526 "));
sl@0
   171
	test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
sl@0
   172
	test(aMaximumLengthUpperLimit<=KBufferLength);
sl@0
   173
	TUint16 unicodeBuffer[KBufferLength];
sl@0
   174
	for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
sl@0
   175
		{
sl@0
   176
		TPtr16 generatedFirstPartOfUnicode(unicodeBuffer, i);
sl@0
   177
		TInt state=CCnvCharacterSetConverter::KStateDefault;
sl@0
   178
		const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedFirstPartOfUnicode, aOriginalIso2022Jp, state);
sl@0
   179
		test(generatedFirstPartOfUnicode==aExpectedUnicode.Left(aExpectedLengthOfFirstPartOfUnicode));
sl@0
   180
		test(returnValue==aExpectedNumberOfIso2022JpBytesNotConvertedAtSplit);
sl@0
   181
		TBuf16<KBufferLength> generatedSecondPartOfUnicode;
sl@0
   182
		test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, aOriginalIso2022Jp.Right(aExpectedNumberOfIso2022JpBytesNotConvertedAtSplit), state)==0);
sl@0
   183
		test(generatedSecondPartOfUnicode==aExpectedUnicode.Mid(aExpectedLengthOfFirstPartOfUnicode));
sl@0
   184
		TBuf8<KBufferLength> generatedIso2022Jp;
sl@0
   185
		test(aCharacterSetConverter.ConvertFromUnicode(generatedIso2022Jp, generatedFirstPartOfUnicode)==0);
sl@0
   186
		TBuf8<KBufferLength> generatedSecondPartOfIso2022Jp;
sl@0
   187
		test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfIso2022Jp, generatedSecondPartOfUnicode)==0);
sl@0
   188
		generatedIso2022Jp.Append(generatedSecondPartOfIso2022Jp);
sl@0
   189
		TBuf16<KBufferLength> regeneratedUnicode;
sl@0
   190
		state=CCnvCharacterSetConverter::KStateDefault;
sl@0
   191
		test(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, generatedIso2022Jp, state)==0);
sl@0
   192
		test(regeneratedUnicode==aExpectedUnicode);
sl@0
   193
		state=CCnvCharacterSetConverter::KStateDefault;
sl@0
   194
		test(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, aOriginalIso2022Jp, state)==0);
sl@0
   195
		test(regeneratedUnicode==aExpectedUnicode);
sl@0
   196
		}
sl@0
   197
	}
sl@0
   198
/**
sl@0
   199
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0527
sl@0
   200
@SYMTestCaseDesc        Conversion of bad ISO2022JP format to Unicode test
sl@0
   201
@SYMTestPriority        Medium
sl@0
   202
@SYMTestActions         Tests to convert bad format ISO2022JP input to Unicode.
sl@0
   203
@SYMTestExpectedResults Test must not fail
sl@0
   204
@SYMREQ                 REQ0000
sl@0
   205
*/
sl@0
   206
void CT_ISO2022JP::TestIsIllFormedIso2022Jp(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC8& aIso2022Jp)
sl@0
   207
	{
sl@0
   208
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0527 "));
sl@0
   209
	TBuf16<50> generatedUnicode;
sl@0
   210
	TInt state=CCnvCharacterSetConverter::KStateDefault;
sl@0
   211
	TPtrC8 remainderOfIso2022Jp(aIso2022Jp);
sl@0
   212
	TInt lastReturnValue=KMaxTInt;
sl@0
   213
	FOREVER
sl@0
   214
		{
sl@0
   215
		const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, remainderOfIso2022Jp, state);
sl@0
   216
		if (returnValue==CCnvCharacterSetConverter::EErrorIllFormedInput)
sl@0
   217
			{
sl@0
   218
			break;
sl@0
   219
			}
sl@0
   220
		test(returnValue>0);
sl@0
   221
		test(returnValue<lastReturnValue);
sl@0
   222
		lastReturnValue=returnValue;
sl@0
   223
		remainderOfIso2022Jp.Set(remainderOfIso2022Jp.Right(returnValue));
sl@0
   224
		}
sl@0
   225
	}
sl@0
   226
/**
sl@0
   227
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0528
sl@0
   228
@SYMTestCaseDesc        ISO2022JP to Unicode and Unicode to ISO2022JP conversion tests
sl@0
   229
@SYMTestPriority        Medium
sl@0
   230
@SYMTestActions         Call up conversion of ISO2022JP to Unicode test functions
sl@0
   231
@SYMTestExpectedResults Test must not fail
sl@0
   232
@SYMREQ                 REQ0000
sl@0
   233
*/
sl@0
   234
void CT_ISO2022JP::DoE32MainL()
sl@0
   235
	{
sl@0
   236
    INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0528 "));
sl@0
   237
	RFs fileServerSession;
sl@0
   238
	CleanupClosePushL(fileServerSession);
sl@0
   239
	User::LeaveIfError(fileServerSession.Connect());
sl@0
   240
	CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
sl@0
   241
	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
sl@0
   242
	INFO_PRINTF1(_L("Available:\n"));
sl@0
   243
	TInt i;
sl@0
   244
	for (i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
sl@0
   245
		{
sl@0
   246
		const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
sl@0
   247
		characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
sl@0
   248
		TPtrC charactersSetName(charactersSet.Name());
sl@0
   249
		if (charactersSet.NameIsFileName())
sl@0
   250
			{
sl@0
   251
			charactersSetName.Set(TParsePtrC(charactersSetName).Name());
sl@0
   252
			}
sl@0
   253
		INFO_PRINTF2(_L("    %S\n"), &charactersSetName);
sl@0
   254
		}
sl@0
   255
	INFO_PRINTF1(_L("Testing ISO-2022-JP conversions"));
sl@0
   256
	characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierIso2022Jp, *arrayOfCharacterSetsAvailable, fileServerSession);
sl@0
   257
	//
sl@0
   258
	INFO_PRINTF1(_L("Empty descriptor"));
sl@0
   259
	TestSplittingConvertingFromUnicodeToIso2022Jp(*characterSetConverter, 0, 10, 0, KNullDesC8, KNullDesC8, KNullDesC16);
sl@0
   260
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 0, 10, 0, 0, KNullDesC16, KNullDesC8);
sl@0
   261
	INFO_PRINTF1(_L("Testing converting to ISO-2022-JP"));
sl@0
   262
sl@0
   263
	_LIT(KTestUnicode,">.@>0l90");
sl@0
   264
	_LIT(KTestUnicode2,"\x0393\x03b1\x03c3\x03bf\x03c5\x3055\x3088");
sl@0
   265
 	TestConversionFromUnicodeToIso(*characterSetConverter, KTestUnicode2);
sl@0
   266
 	TestConversionFromUnicodeToIso(*characterSetConverter, KTestUnicode);
sl@0
   267
sl@0
   268
	TBuf16<50> originalUnicode;
sl@0
   269
	originalUnicode.Format(_L16("%c%c%c%c%c\xa5\\%c%c%c%c%c"), 0x0393, 0x03b1, 0x03c3, 0x03bf, 0x03c5, 0x3055, 0x3088, 0x3046, 0x306a, 0x3089);
sl@0
   270
	TestTruncatedConversionFromUnicodeToIso2022Jp(*characterSetConverter, originalUnicode);
sl@0
   271
	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);
sl@0
   272
	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);
sl@0
   273
	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);
sl@0
   274
	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);
sl@0
   275
	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);
sl@0
   276
	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);
sl@0
   277
    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);
sl@0
   278
	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);
sl@0
   279
	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);
sl@0
   280
	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);
sl@0
   281
	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);
sl@0
   282
	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);
sl@0
   283
	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);
sl@0
   284
	originalUnicode.Format(_L16("%cX%cY%cZ"), 0x6153, 0x6376, 0x65d9);
sl@0
   285
	TestTruncatedConversionFromUnicodeToIso2022Jp(*characterSetConverter, originalUnicode);
sl@0
   286
	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);
sl@0
   287
	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);
sl@0
   288
	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);
sl@0
   289
	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);
sl@0
   290
	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);
sl@0
   291
	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);
sl@0
   292
	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);
sl@0
   293
	INFO_PRINTF1(_L("Testing converting to Unicode"));
sl@0
   294
	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\\~"));
sl@0
   295
	TBuf16<50> expectedUnicode;
sl@0
   296
	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);
sl@0
   297
	TestTruncatedConversionToUnicodeFromIso2022Jp(*characterSetConverter, expectedUnicode, originalIso2022Jp);
sl@0
   298
	TestTruncatedConversionToUnicodeFromIso2022Jp(*characterSetConverter, _L16(" Hello"), _L8("\x1b\x24\x42\x1b\x28\x4a\x1b\x24\x42\x1b\x28\x4a\x1b\x24\x42\x1b\x28\x4a Hello"));
sl@0
   299
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 0, 0, 60, 0, expectedUnicode, originalIso2022Jp);
sl@0
   300
	for (i=1; i<=10; ++i)
sl@0
   301
		{
sl@0
   302
		TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, i, i, 54-i, i, expectedUnicode, originalIso2022Jp);
sl@0
   303
		}
sl@0
   304
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 11, 11, 34, 11, expectedUnicode, originalIso2022Jp);
sl@0
   305
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 12, 12, 32, 12, expectedUnicode, originalIso2022Jp);
sl@0
   306
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 13, 13, 30, 13, expectedUnicode, originalIso2022Jp);
sl@0
   307
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 14, 14, 28, 14, expectedUnicode, originalIso2022Jp);
sl@0
   308
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 15, 15, 23, 15, expectedUnicode, originalIso2022Jp);
sl@0
   309
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 16, 16, 22, 16, expectedUnicode, originalIso2022Jp);
sl@0
   310
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 17, 17, 21, 17, expectedUnicode, originalIso2022Jp);
sl@0
   311
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 18, 18, 20, 18, expectedUnicode, originalIso2022Jp);
sl@0
   312
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 19, 19, 16, 19, expectedUnicode, originalIso2022Jp);
sl@0
   313
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 20, 20, 14, 20, expectedUnicode, originalIso2022Jp);
sl@0
   314
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 21, 21, 12, 21, expectedUnicode, originalIso2022Jp);
sl@0
   315
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 22, 22, 7, 22, expectedUnicode, originalIso2022Jp);
sl@0
   316
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 23, 23, 6, 23, expectedUnicode, originalIso2022Jp);
sl@0
   317
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 24, 24, 2, 24, expectedUnicode, originalIso2022Jp);
sl@0
   318
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 25, 25, 1, 25, expectedUnicode, originalIso2022Jp);
sl@0
   319
	TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, 26, 40, 0, 26, expectedUnicode, originalIso2022Jp);
sl@0
   320
	INFO_PRINTF1(_L("Testing the default ISO-2022-JP state"));
sl@0
   321
	for (i=0; i<=6; ++i)
sl@0
   322
		{
sl@0
   323
		TestSplittingConvertingToUnicodeFromIso2022Jp(*characterSetConverter, i, i, 6-i, i, _L16("Hello\xa5"), _L8("Hello\\"));
sl@0
   324
		}
sl@0
   325
	INFO_PRINTF1(_L("Testing ill-formed ISO-2022-JP"));
sl@0
   326
	TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x24\x42\x21\x1b\x28\x4a def"));
sl@0
   327
	TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x24\x42\x21\x21\x21\x1b\x28\x4a def"));
sl@0
   328
	TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x24\x42\x21\x21\x21\x21\x21\x1b\x28\x4a def"));
sl@0
   329
	TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b"));
sl@0
   330
	TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x24"));
sl@0
   331
	TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x24\xff"));
sl@0
   332
	TestIsIllFormedIso2022Jp(*characterSetConverter, _L8("abc \x1b\x26\x40"));
sl@0
   333
	CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession
sl@0
   334
	}
sl@0
   335
sl@0
   336
CT_ISO2022JP::CT_ISO2022JP()
sl@0
   337
    {
sl@0
   338
    SetTestStepName(KTestStep_T_ISO2022JP);
sl@0
   339
    }
sl@0
   340
sl@0
   341
TVerdict CT_ISO2022JP::doTestStepL()
sl@0
   342
    {
sl@0
   343
    SetTestStepResult(EFail);
sl@0
   344
sl@0
   345
    __UHEAP_MARK;
sl@0
   346
    TRAPD(error1, DoE32MainL());    
sl@0
   347
    __UHEAP_MARKEND;
sl@0
   348
sl@0
   349
    if(error1 == KErrNone)
sl@0
   350
        {
sl@0
   351
        SetTestStepResult(EPass);
sl@0
   352
        }
sl@0
   353
sl@0
   354
    return TestStepResult();
sl@0
   355
    }
sl@0
   356