os/textandloc/charconvfw/charconvplugins/test/rtest/tsrc/main/t_hz.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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_hz.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
/**
sl@0
    38
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0503
sl@0
    39
@SYMTestCaseDesc        Tests for truncated conversion from Unicode to HZ character set
sl@0
    40
@SYMTestPriority        Medium
sl@0
    41
@SYMTestActions         Tests for generated Unicode with the original Unicode
sl@0
    42
@SYMTestExpectedResults Test must not fail
sl@0
    43
@SYMREQ                 REQ0000
sl@0
    44
*/
sl@0
    45
void CT_HZ::TestTruncatedConversionFromUnicodeToHz(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aOriginalUnicode)
sl@0
    46
	{
sl@0
    47
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0503 "));
sl@0
    48
	for (TInt i=aOriginalUnicode.Length(); i>=0; --i)
sl@0
    49
		{
sl@0
    50
		TBuf8<KBufferLength> generatedHz;
sl@0
    51
		const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedHz, aOriginalUnicode.Left(i));
sl@0
    52
		test(returnValue>=0);
sl@0
    53
		TBuf8<KBufferLength> generatedsecondPartOfHz;
sl@0
    54
		test(aCharacterSetConverter.ConvertFromUnicode(generatedsecondPartOfHz, aOriginalUnicode.Mid(i-returnValue))==0);
sl@0
    55
		generatedHz.Append(generatedsecondPartOfHz);
sl@0
    56
		TInt state=CCnvCharacterSetConverter::KStateDefault;
sl@0
    57
		TBuf16<KBufferLength> generatedUnicode;
sl@0
    58
		test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedHz, state)==0);
sl@0
    59
		test(generatedUnicode==aOriginalUnicode);
sl@0
    60
		}
sl@0
    61
	}
sl@0
    62
/**
sl@0
    63
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0504
sl@0
    64
@SYMTestCaseDesc        Splitting and converting from Unicode to HZ test
sl@0
    65
@SYMTestPriority        Medium
sl@0
    66
@SYMTestActions         Tests for conversion after splitting from Unicode to Hz 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_HZ::TestSplittingConvertingFromUnicodeToHz(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit, const TDesC8& aExpectedFirstPartOfHz, const TDesC8& aExpectedSecondPartOfHz, const TDesC16& aOriginalUnicode)
sl@0
    71
	{
sl@0
    72
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0504 "));
sl@0
    73
	test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
sl@0
    74
	test(aMaximumLengthUpperLimit<=KBufferLength);
sl@0
    75
	TUint8 hzBuffer[KBufferLength];
sl@0
    76
	for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
sl@0
    77
		{
sl@0
    78
		TPtr8 generatedFirstPartOfHz(hzBuffer, i);
sl@0
    79
		test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfHz, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit);
sl@0
    80
		test(generatedFirstPartOfHz==aExpectedFirstPartOfHz);
sl@0
    81
		TBuf8<KBufferLength> generatedSecondPartOfHz;
sl@0
    82
		test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfHz, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0);
sl@0
    83
		test(generatedSecondPartOfHz==aExpectedSecondPartOfHz);
sl@0
    84
		TInt state=CCnvCharacterSetConverter::KStateDefault;
sl@0
    85
		TBuf16<KBufferLength> generatedUnicode;
sl@0
    86
		test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfHz, state)==0);
sl@0
    87
		test(state==CCnvCharacterSetConverter::KStateDefault);
sl@0
    88
		TBuf16<KBufferLength> generatedSecondPartOfUnicode;
sl@0
    89
		test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfHz, state)==0);
sl@0
    90
		test(state==CCnvCharacterSetConverter::KStateDefault);
sl@0
    91
		generatedUnicode.Append(generatedSecondPartOfUnicode);
sl@0
    92
		test(generatedUnicode==aOriginalUnicode);
sl@0
    93
		}
sl@0
    94
	}
sl@0
    95
/**
sl@0
    96
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0505
sl@0
    97
@SYMTestCaseDesc        Tests for truncated conversion from HZ to Unicode
sl@0
    98
@SYMTestPriority        Medium
sl@0
    99
@SYMTestActions         Tests for conversion after truncation from HZ to Unicode and back to HZ
sl@0
   100
@SYMTestExpectedResults Test must not fail
sl@0
   101
@SYMREQ                 REQ0000
sl@0
   102
*/
sl@0
   103
void CT_HZ::TestTruncatedConversionToUnicodeFromHz(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalHz)
sl@0
   104
	{
sl@0
   105
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0505 "));
sl@0
   106
	for (TInt i=aOriginalHz.Length(); i>=2; --i) // 2 is the length of HZ's "tilde" sequences
sl@0
   107
		{
sl@0
   108
		TInt state=CCnvCharacterSetConverter::KStateDefault;
sl@0
   109
		TBuf16<KBufferLength> generatedUnicode;
sl@0
   110
		const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalHz.Left(i), state);
sl@0
   111
		test(returnValue>=0);
sl@0
   112
		TBuf16<KBufferLength> generatedsecondPartOfUnicode;
sl@0
   113
		test(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalHz.Mid(i-returnValue), state)==0);
sl@0
   114
		generatedUnicode.Append(generatedsecondPartOfUnicode);
sl@0
   115
		test(generatedUnicode==aExpectedUnicode);
sl@0
   116
		}
sl@0
   117
	}
sl@0
   118
/**
sl@0
   119
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0506
sl@0
   120
@SYMTestCaseDesc        Splitting and converting to Unicode from HZ test
sl@0
   121
@SYMTestPriority        Medium
sl@0
   122
@SYMTestActions         Tests for conversion after splitting from Hz to Unicode and back to Hz
sl@0
   123
@SYMTestExpectedResults Test must not fail
sl@0
   124
@SYMREQ                 REQ0000
sl@0
   125
*/
sl@0
   126
void CT_HZ::TestSplittingConvertingToUnicodeFromHz(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfHzBytesNotConvertedAtSplit, TInt aExpectedStateAtSplit, TInt aExpectedLengthOfFirstPartOfUnicode, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalHz)
sl@0
   127
	{
sl@0
   128
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0506 "));
sl@0
   129
	test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
sl@0
   130
	test(aMaximumLengthUpperLimit<=KBufferLength);
sl@0
   131
	TUint16 unicodeBuffer[KBufferLength];
sl@0
   132
	for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
sl@0
   133
		{
sl@0
   134
		TPtr16 generatedFirstPartOfUnicode(unicodeBuffer, i);
sl@0
   135
		TInt state=CCnvCharacterSetConverter::KStateDefault;
sl@0
   136
		const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedFirstPartOfUnicode, aOriginalHz, state);
sl@0
   137
		test(generatedFirstPartOfUnicode==aExpectedUnicode.Left(aExpectedLengthOfFirstPartOfUnicode));
sl@0
   138
		test((returnValue==aExpectedNumberOfHzBytesNotConvertedAtSplit) && (state==aExpectedStateAtSplit));
sl@0
   139
		{
sl@0
   140
		TBuf16<KBufferLength> generatedSecondPartOfUnicode;
sl@0
   141
		state=aExpectedStateAtSplit;
sl@0
   142
		test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, aOriginalHz.Right(aExpectedNumberOfHzBytesNotConvertedAtSplit), state)==0);
sl@0
   143
		test(generatedSecondPartOfUnicode==aExpectedUnicode.Mid(aExpectedLengthOfFirstPartOfUnicode));
sl@0
   144
		test(state==CCnvCharacterSetConverter::KStateDefault);
sl@0
   145
		TBuf8<KBufferLength> generatedHz;
sl@0
   146
		test(aCharacterSetConverter.ConvertFromUnicode(generatedHz, generatedFirstPartOfUnicode)==0);
sl@0
   147
		TBuf8<KBufferLength> generatedSecondPartOfHz;
sl@0
   148
		test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfHz, generatedSecondPartOfUnicode)==0);
sl@0
   149
		generatedHz.Append(generatedSecondPartOfHz);
sl@0
   150
		TBuf16<KBufferLength> regeneratedUnicode;
sl@0
   151
		state=CCnvCharacterSetConverter::KStateDefault;
sl@0
   152
		test(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, generatedHz, state)==0);
sl@0
   153
		test(regeneratedUnicode==aExpectedUnicode);
sl@0
   154
		test(state==CCnvCharacterSetConverter::KStateDefault);
sl@0
   155
		test(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, aOriginalHz, state)==0);
sl@0
   156
		test(regeneratedUnicode==aExpectedUnicode);
sl@0
   157
		test(state==CCnvCharacterSetConverter::KStateDefault);
sl@0
   158
		}
sl@0
   159
		{
sl@0
   160
		TBuf16<KBufferLength> generatedSecondPartOfUnicode;
sl@0
   161
		state=aExpectedStateAtSplit;
sl@0
   162
		test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, aOriginalHz.Right(aExpectedNumberOfHzBytesNotConvertedAtSplit), state)==0);
sl@0
   163
		test(generatedSecondPartOfUnicode==aExpectedUnicode.Mid(aExpectedLengthOfFirstPartOfUnicode));
sl@0
   164
		test(state==CCnvCharacterSetConverter::KStateDefault);
sl@0
   165
		TBuf8<KBufferLength> generatedHz;
sl@0
   166
		test(aCharacterSetConverter.ConvertFromUnicode(generatedHz, generatedFirstPartOfUnicode)==0);
sl@0
   167
		TBuf8<KBufferLength> generatedSecondPartOfHz;
sl@0
   168
		test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfHz, generatedSecondPartOfUnicode)==0);
sl@0
   169
		generatedHz.Append(generatedSecondPartOfHz);
sl@0
   170
		TBuf16<KBufferLength> regeneratedUnicode;
sl@0
   171
		state=CCnvCharacterSetConverter::KStateDefault;
sl@0
   172
		test(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, generatedHz, state)==0);
sl@0
   173
		test(regeneratedUnicode==aExpectedUnicode);
sl@0
   174
		test(state==CCnvCharacterSetConverter::KStateDefault);
sl@0
   175
		test(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, aOriginalHz, state)==0);
sl@0
   176
		test(regeneratedUnicode==aExpectedUnicode);
sl@0
   177
		test(state==CCnvCharacterSetConverter::KStateDefault);
sl@0
   178
		}
sl@0
   179
		}
sl@0
   180
	}
sl@0
   181
/**
sl@0
   182
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0507
sl@0
   183
@SYMTestCaseDesc        Conversion of bad HZ format to Unicode test
sl@0
   184
@SYMTestPriority        Medium
sl@0
   185
@SYMTestActions         Tests to convert bad Hz format to Unicode.
sl@0
   186
                        Check the status of CCnvCharacterSetConverter::EErrorIllFormedInput error flag
sl@0
   187
@SYMTestExpectedResults Test must not fail
sl@0
   188
@SYMREQ                 REQ0000
sl@0
   189
*/
sl@0
   190
void CT_HZ::TestIsIllFormedHz(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC8& aHz)
sl@0
   191
	{
sl@0
   192
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0507 "));
sl@0
   193
	TBuf16<50> generatedUnicode;
sl@0
   194
	TInt state=CCnvCharacterSetConverter::KStateDefault;
sl@0
   195
	TPtrC8 remainderOfHz(aHz);
sl@0
   196
	TInt lastReturnValue=KMaxTInt;
sl@0
   197
	FOREVER
sl@0
   198
		{
sl@0
   199
		const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, remainderOfHz, state);
sl@0
   200
		if (returnValue==CCnvCharacterSetConverter::EErrorIllFormedInput)
sl@0
   201
			{
sl@0
   202
			break;
sl@0
   203
			}
sl@0
   204
		test(returnValue>0);
sl@0
   205
		test(returnValue<lastReturnValue);
sl@0
   206
		lastReturnValue=returnValue;
sl@0
   207
		remainderOfHz.Set(remainderOfHz.Right(returnValue));
sl@0
   208
		}
sl@0
   209
	}
sl@0
   210
/**
sl@0
   211
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0508
sl@0
   212
@SYMTestCaseDesc        HZ to Unicode and Unicode to HZ conversion tests
sl@0
   213
@SYMTestPriority        Medium
sl@0
   214
@SYMTestActions         Wrapper function to call HZ conversion test functions
sl@0
   215
@SYMTestExpectedResults Test must not fail
sl@0
   216
@SYMREQ                 REQ0000
sl@0
   217
*/
sl@0
   218
void CT_HZ::DoE32MainL()
sl@0
   219
	{
sl@0
   220
    INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0508 "));
sl@0
   221
	RFs fileServerSession;
sl@0
   222
	CleanupClosePushL(fileServerSession);
sl@0
   223
	User::LeaveIfError(fileServerSession.Connect());
sl@0
   224
	CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
sl@0
   225
	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
sl@0
   226
	INFO_PRINTF1(_L("Available:\n"));
sl@0
   227
	for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
sl@0
   228
		{
sl@0
   229
		const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
sl@0
   230
		characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
sl@0
   231
		TPtrC charactersSetName(charactersSet.Name());
sl@0
   232
		if (charactersSet.NameIsFileName())
sl@0
   233
			{
sl@0
   234
			charactersSetName.Set(TParsePtrC(charactersSetName).Name());
sl@0
   235
			}
sl@0
   236
		INFO_PRINTF2(_L("    %S\n"), &charactersSetName);
sl@0
   237
		}
sl@0
   238
	INFO_PRINTF1(_L("Testing HZ conversions"));
sl@0
   239
	characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierHz, *arrayOfCharacterSetsAvailable, fileServerSession);
sl@0
   240
	//
sl@0
   241
	INFO_PRINTF1(_L("Empty descriptor"));
sl@0
   242
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 0, 10, 0, KNullDesC8, KNullDesC8, KNullDesC16);
sl@0
   243
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 0, 10, 0, CCnvCharacterSetConverter::KStateDefault, 0, KNullDesC16, KNullDesC8);
sl@0
   244
	INFO_PRINTF1(_L("Testing converting to HZ"));
sl@0
   245
	TBuf16<50> originalUnicode;
sl@0
   246
	originalUnicode.Format(_L16("%c%cxyz%c%c~%c~~%ce~a%c"), 0x4e2d, 0x56fd, 0x5979, 0x4ed6, 0x4eba, 0x4e09, 0x7259);
sl@0
   247
	TestTruncatedConversionFromUnicodeToHz(*characterSetConverter, originalUnicode);
sl@0
   248
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 0, 5, 16, KNullDesC8, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   249
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 6, 7, 15, _L8("~{VP~}"), _L8("~{9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   250
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 8, 8, 14, _L8("~{VP9z~}"), _L8("xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   251
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 9, 9, 13, _L8("~{VP9z~}x"), _L8("yz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   252
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 10, 10, 12, _L8("~{VP9z~}xy"), _L8("z~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   253
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 11, 16, 11, _L8("~{VP9z~}xyz"), _L8("~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   254
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 17, 18, 10, _L8("~{VP9z~}xyz~{K}~}"), _L8("~{K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   255
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 19, 20, 9, _L8("~{VP9z~}xyz~{K}K{~}"), _L8("~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   256
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 21, 26, 8, _L8("~{VP9z~}xyz~{K}K{~}~~"), _L8("~{HK~}~~~~~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   257
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 27, 28, 7, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}"), _L8("~~~~~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   258
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 29, 30, 6, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~"), _L8("~~~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   259
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 31, 36, 5, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~"), _L8("~{H}~}e~~a~{Q@~}"), originalUnicode);
sl@0
   260
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 37, 37, 4, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}"), _L8("e~~a~{Q@~}"), originalUnicode);
sl@0
   261
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 38, 39, 3, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e"), _L8("~~a~{Q@~}"), originalUnicode);
sl@0
   262
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 40, 40, 2, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~"), _L8("a~{Q@~}"), originalUnicode);
sl@0
   263
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 41, 46, 1, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a"), _L8("~{Q@~}"), originalUnicode);
sl@0
   264
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 47, 50, 0, _L8("~{VP9z~}xyz~{K}K{~}~~~{HK~}~~~~~{H}~}e~~a~{Q@~}"), KNullDesC8, originalUnicode);
sl@0
   265
	INFO_PRINTF1(_L("Testing converting to Unicode"));
sl@0
   266
	const TPtrC8 originalHz(_S8("My name is ~{3W~} ~~~~{~~I ~{'X'Z'S'e~} in ~{11>)~}~~~~}~~~~"));
sl@0
   267
	TBuf16<50> expectedUnicode;
sl@0
   268
	expectedUnicode.Format(_L16("My name is %c ~~{~I %c%c%c%c in %c%c~~}~~"), 0x5319, 0x0436, 0x0438, 0x0432, 0x0443, 0x5317, 0x4eac);
sl@0
   269
	TestTruncatedConversionToUnicodeFromHz(*characterSetConverter, expectedUnicode, originalHz);
sl@0
   270
	TestTruncatedConversionToUnicodeFromHz(*characterSetConverter, _L16("Hello"), _L8("~{~}~{~}~{~}Hello"));
sl@0
   271
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 0, 0, 60, CCnvCharacterSetConverter::KStateDefault, 0, expectedUnicode, originalHz);
sl@0
   272
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 1, 1, 59, CCnvCharacterSetConverter::KStateDefault, 1, expectedUnicode, originalHz);
sl@0
   273
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 2, 2, 58, CCnvCharacterSetConverter::KStateDefault, 2, expectedUnicode, originalHz);
sl@0
   274
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 3, 3, 57, CCnvCharacterSetConverter::KStateDefault, 3, expectedUnicode, originalHz);
sl@0
   275
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 4, 4, 56, CCnvCharacterSetConverter::KStateDefault, 4, expectedUnicode, originalHz);
sl@0
   276
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 5, 5, 55, CCnvCharacterSetConverter::KStateDefault, 5, expectedUnicode, originalHz);
sl@0
   277
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 6, 6, 54, CCnvCharacterSetConverter::KStateDefault, 6, expectedUnicode, originalHz);
sl@0
   278
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 7, 7, 53, CCnvCharacterSetConverter::KStateDefault, 7, expectedUnicode, originalHz);
sl@0
   279
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 8, 8, 52, CCnvCharacterSetConverter::KStateDefault, 8, expectedUnicode, originalHz);
sl@0
   280
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 9, 9, 51, CCnvCharacterSetConverter::KStateDefault, 9, expectedUnicode, originalHz);
sl@0
   281
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 10, 10, 50, CCnvCharacterSetConverter::KStateDefault, 10, expectedUnicode, originalHz);
sl@0
   282
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 11, 11, 47, CCnvCharacterSetConverter::KStateDefault+1, 11, expectedUnicode, originalHz);
sl@0
   283
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 12, 12, 43, CCnvCharacterSetConverter::KStateDefault, 12, expectedUnicode, originalHz);
sl@0
   284
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 13, 13, 42, CCnvCharacterSetConverter::KStateDefault, 13, expectedUnicode, originalHz);
sl@0
   285
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 14, 14, 40, CCnvCharacterSetConverter::KStateDefault, 14, expectedUnicode, originalHz);
sl@0
   286
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 15, 15, 38, CCnvCharacterSetConverter::KStateDefault, 15, expectedUnicode, originalHz);
sl@0
   287
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 16, 16, 37, CCnvCharacterSetConverter::KStateDefault, 16, expectedUnicode, originalHz);
sl@0
   288
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 17, 17, 35, CCnvCharacterSetConverter::KStateDefault, 17, expectedUnicode, originalHz);
sl@0
   289
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 18, 18, 34, CCnvCharacterSetConverter::KStateDefault, 18, expectedUnicode, originalHz);
sl@0
   290
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 19, 19, 31, CCnvCharacterSetConverter::KStateDefault+1, 19, expectedUnicode, originalHz);
sl@0
   291
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 20, 20, 29, CCnvCharacterSetConverter::KStateDefault+1, 20, expectedUnicode, originalHz);
sl@0
   292
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 21, 21, 27, CCnvCharacterSetConverter::KStateDefault+1, 21, expectedUnicode, originalHz);
sl@0
   293
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 22, 22, 25, CCnvCharacterSetConverter::KStateDefault+1, 22, expectedUnicode, originalHz);
sl@0
   294
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 23, 23, 21, CCnvCharacterSetConverter::KStateDefault, 23, expectedUnicode, originalHz);
sl@0
   295
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 24, 24, 20, CCnvCharacterSetConverter::KStateDefault, 24, expectedUnicode, originalHz);
sl@0
   296
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 25, 25, 19, CCnvCharacterSetConverter::KStateDefault, 25, expectedUnicode, originalHz);
sl@0
   297
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 26, 26, 18, CCnvCharacterSetConverter::KStateDefault, 26, expectedUnicode, originalHz);
sl@0
   298
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 27, 27, 15, CCnvCharacterSetConverter::KStateDefault+1, 27, expectedUnicode, originalHz);
sl@0
   299
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 28, 28, 13, CCnvCharacterSetConverter::KStateDefault+1, 28, expectedUnicode, originalHz);
sl@0
   300
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 29, 29, 9, CCnvCharacterSetConverter::KStateDefault, 29, expectedUnicode, originalHz);
sl@0
   301
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 30, 30, 7, CCnvCharacterSetConverter::KStateDefault, 30, expectedUnicode, originalHz);
sl@0
   302
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 31, 31, 5, CCnvCharacterSetConverter::KStateDefault, 31, expectedUnicode, originalHz);
sl@0
   303
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 32, 32, 4, CCnvCharacterSetConverter::KStateDefault, 32, expectedUnicode, originalHz);
sl@0
   304
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 33, 33, 2, CCnvCharacterSetConverter::KStateDefault, 33, expectedUnicode, originalHz);
sl@0
   305
	TestSplittingConvertingToUnicodeFromHz(*characterSetConverter, 34, 40, 0, CCnvCharacterSetConverter::KStateDefault, 34, expectedUnicode, originalHz);
sl@0
   306
	INFO_PRINTF1(_L("Having '~' as the second byte of a Chinese character"));
sl@0
   307
	originalUnicode.Format(_L16("1%c2"), 0x4e8c);
sl@0
   308
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 0, 0, 3, KNullDesC8, _L8("1~{6~~}2"), originalUnicode);
sl@0
   309
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 1, 6, 2, _L8("1"), _L8("~{6~~}2"), originalUnicode);
sl@0
   310
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 7, 7, 1, _L8("1~{6~~}"), _L8("2"), originalUnicode);
sl@0
   311
	TestSplittingConvertingFromUnicodeToHz(*characterSetConverter, 8, 20, 0, _L8("1~{6~~}2"), KNullDesC8, originalUnicode);
sl@0
   312
	INFO_PRINTF1(_L("Testing ill-formed HZ"));
sl@0
   313
	TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{C~} def"));
sl@0
   314
	TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{C;C~} def"));
sl@0
   315
	TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{C;C;C~} def"));
sl@0
   316
	TestIsIllFormedHz(*characterSetConverter, _L8("abc ~"));
sl@0
   317
	TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{~"));
sl@0
   318
	TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{C"));
sl@0
   319
	// note that...................................._L8("abc ~{C~") is actually well-formed
sl@0
   320
	TestIsIllFormedHz(*characterSetConverter, _L8("abc ~{C;~"));
sl@0
   321
	CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession
sl@0
   322
	}
sl@0
   323
sl@0
   324
CT_HZ::CT_HZ()
sl@0
   325
    {
sl@0
   326
    SetTestStepName(KTestStep_T_HZ);
sl@0
   327
    }
sl@0
   328
sl@0
   329
TVerdict CT_HZ::doTestStepL()
sl@0
   330
    {
sl@0
   331
    SetTestStepResult(EFail);
sl@0
   332
sl@0
   333
    __UHEAP_MARK;
sl@0
   334
    TRAPD(error1, DoE32MainL());    
sl@0
   335
    __UHEAP_MARKEND;
sl@0
   336
sl@0
   337
    if(error1 == KErrNone)
sl@0
   338
        {
sl@0
   339
        SetTestStepResult(EPass);
sl@0
   340
        }
sl@0
   341
sl@0
   342
    return TestStepResult();
sl@0
   343
    }
sl@0
   344
sl@0
   345