sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-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_gbk.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 KMibValue = 113;
|
sl@0
|
37 |
const TInt KBufferLength=100;
|
sl@0
|
38 |
/**
|
sl@0
|
39 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0509
|
sl@0
|
40 |
@SYMTestCaseDesc Tests for truncated conversion from Unicode to GBK
|
sl@0
|
41 |
@SYMTestPriority Medium
|
sl@0
|
42 |
@SYMTestActions Tests for truncated conversion from Unicode to Gbk and back to Unicode.
|
sl@0
|
43 |
Tests for the generated Unicode with original Unicode
|
sl@0
|
44 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
45 |
@SYMREQ REQ0000
|
sl@0
|
46 |
*/
|
sl@0
|
47 |
void CT_GBK::TestTruncatedConversionFromUnicodeToGbk(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aOriginalUnicode)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0509 "));
|
sl@0
|
50 |
for (TInt i=aOriginalUnicode.Length(); i>=0; --i)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
TBuf8<KBufferLength> generatedGbk;
|
sl@0
|
53 |
const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedGbk, aOriginalUnicode.Left(i));
|
sl@0
|
54 |
test(returnValue>=0);
|
sl@0
|
55 |
TBuf8<KBufferLength> generatedsecondPartOfGbk;
|
sl@0
|
56 |
test(aCharacterSetConverter.ConvertFromUnicode(generatedsecondPartOfGbk, aOriginalUnicode.Mid(i-returnValue))==0);
|
sl@0
|
57 |
generatedGbk.Append(generatedsecondPartOfGbk);
|
sl@0
|
58 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
59 |
TBuf16<KBufferLength> generatedUnicode;
|
sl@0
|
60 |
test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedGbk, state)==0);
|
sl@0
|
61 |
test(generatedUnicode==aOriginalUnicode);
|
sl@0
|
62 |
}
|
sl@0
|
63 |
}
|
sl@0
|
64 |
/**
|
sl@0
|
65 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0510
|
sl@0
|
66 |
@SYMTestCaseDesc Splitting and converting from Unicode to GBK test
|
sl@0
|
67 |
@SYMTestPriority Medium
|
sl@0
|
68 |
@SYMTestActions Tests for conversion after splitting from Unicode to Gbk and back to Unicode
|
sl@0
|
69 |
Tests for the generated Unicode with original Unicode
|
sl@0
|
70 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
71 |
@SYMREQ REQ0000
|
sl@0
|
72 |
*/
|
sl@0
|
73 |
void CT_GBK::TestSplittingConvertingFromUnicodeToGbk(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit, TInt aExpectedLengthOfFirstPartOfGbk, const TDesC8& aExpectedGbk, const TDesC16& aOriginalUnicode)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0510 "));
|
sl@0
|
76 |
test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
|
sl@0
|
77 |
test(aMaximumLengthUpperLimit<=KBufferLength);
|
sl@0
|
78 |
TUint8 gbkBuffer[KBufferLength];
|
sl@0
|
79 |
for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
TPtr8 generatedFirstPartOfGbk(gbkBuffer, i);
|
sl@0
|
82 |
test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfGbk, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit);
|
sl@0
|
83 |
test(generatedFirstPartOfGbk==aExpectedGbk.Left(aExpectedLengthOfFirstPartOfGbk));
|
sl@0
|
84 |
TBuf8<KBufferLength> generatedSecondPartOfGbk;
|
sl@0
|
85 |
test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfGbk, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0);
|
sl@0
|
86 |
test(generatedSecondPartOfGbk==aExpectedGbk.Mid(aExpectedLengthOfFirstPartOfGbk));
|
sl@0
|
87 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
88 |
TBuf16<KBufferLength> generatedUnicode;
|
sl@0
|
89 |
test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfGbk, state)==0);
|
sl@0
|
90 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
91 |
TBuf16<KBufferLength> generatedSecondPartOfUnicode;
|
sl@0
|
92 |
test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfGbk, state)==0);
|
sl@0
|
93 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
94 |
generatedUnicode.Append(generatedSecondPartOfUnicode);
|
sl@0
|
95 |
test(generatedUnicode==aOriginalUnicode);
|
sl@0
|
96 |
}
|
sl@0
|
97 |
}
|
sl@0
|
98 |
/**
|
sl@0
|
99 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0511
|
sl@0
|
100 |
@SYMTestCaseDesc Tests for truncated conversion from GBK to Unicode
|
sl@0
|
101 |
@SYMTestPriority Medium
|
sl@0
|
102 |
@SYMTestActions Tests for conversion after truncation from Unicode to Hz and back to Unicode
|
sl@0
|
103 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
104 |
@SYMREQ REQ0000
|
sl@0
|
105 |
*/
|
sl@0
|
106 |
void CT_GBK::TestTruncatedConversionToUnicodeFromGbk(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalGbk)
|
sl@0
|
107 |
{
|
sl@0
|
108 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0511 "));
|
sl@0
|
109 |
for (TInt i=aOriginalGbk.Length(); i>=2; --i) // 2 is the length of GBK's longest multi-byte characters
|
sl@0
|
110 |
{
|
sl@0
|
111 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
112 |
TBuf16<KBufferLength> generatedUnicode;
|
sl@0
|
113 |
const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalGbk.Left(i), state);
|
sl@0
|
114 |
test(returnValue>=0);
|
sl@0
|
115 |
TBuf16<KBufferLength> generatedsecondPartOfUnicode;
|
sl@0
|
116 |
test(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalGbk.Mid(i-returnValue), state)==0);
|
sl@0
|
117 |
generatedUnicode.Append(generatedsecondPartOfUnicode);
|
sl@0
|
118 |
test(generatedUnicode==aExpectedUnicode);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
}
|
sl@0
|
121 |
/**
|
sl@0
|
122 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0512
|
sl@0
|
123 |
@SYMTestCaseDesc Splitting and converting from GBK to Unicode test
|
sl@0
|
124 |
@SYMTestPriority Medium
|
sl@0
|
125 |
@SYMTestActions Tests for conversion after splitting from Hz to Unicode and back to Hz
|
sl@0
|
126 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
127 |
@SYMREQ REQ0000
|
sl@0
|
128 |
*/
|
sl@0
|
129 |
void CT_GBK::TestSplittingConvertingToUnicodeFromGbk(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfGbkBytesNotConvertedAtSplit, TInt aExpectedLengthOfFirstPartOfUnicode, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalGbk)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0512 "));
|
sl@0
|
132 |
test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
|
sl@0
|
133 |
test(aMaximumLengthUpperLimit<=KBufferLength);
|
sl@0
|
134 |
TUint16 unicodeBuffer[KBufferLength];
|
sl@0
|
135 |
for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
|
sl@0
|
136 |
{
|
sl@0
|
137 |
TPtr16 generatedFirstPartOfUnicode(unicodeBuffer, i);
|
sl@0
|
138 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
139 |
test(aCharacterSetConverter.ConvertToUnicode(generatedFirstPartOfUnicode, aOriginalGbk, state)==aExpectedNumberOfGbkBytesNotConvertedAtSplit);
|
sl@0
|
140 |
test(generatedFirstPartOfUnicode==aExpectedUnicode.Left(aExpectedLengthOfFirstPartOfUnicode));
|
sl@0
|
141 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
142 |
TBuf16<KBufferLength> generatedSecondPartOfUnicode;
|
sl@0
|
143 |
test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, aOriginalGbk.Right(aExpectedNumberOfGbkBytesNotConvertedAtSplit), state)==0);
|
sl@0
|
144 |
test(generatedSecondPartOfUnicode==aExpectedUnicode.Mid(aExpectedLengthOfFirstPartOfUnicode));
|
sl@0
|
145 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
146 |
TBuf8<KBufferLength> generatedGbk;
|
sl@0
|
147 |
test(aCharacterSetConverter.ConvertFromUnicode(generatedGbk, generatedFirstPartOfUnicode)==0);
|
sl@0
|
148 |
TBuf8<KBufferLength> generatedSecondPartOfGbk;
|
sl@0
|
149 |
test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfGbk, generatedSecondPartOfUnicode)==0);
|
sl@0
|
150 |
generatedGbk.Append(generatedSecondPartOfGbk);
|
sl@0
|
151 |
test(generatedGbk==aOriginalGbk);
|
sl@0
|
152 |
}
|
sl@0
|
153 |
}
|
sl@0
|
154 |
|
sl@0
|
155 |
|
sl@0
|
156 |
/**
|
sl@0
|
157 |
Tests retreiving the MIB value from the GBK UID
|
sl@0
|
158 |
Tests retreiving the GBK UID from the MIB value
|
sl@0
|
159 |
|
sl@0
|
160 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0513
|
sl@0
|
161 |
@SYMTestCaseDesc Tests for conversion from MIB to UID and UID to MIB
|
sl@0
|
162 |
@SYMTestPriority Medium
|
sl@0
|
163 |
@SYMTestActions Tests CCnvCharacterSetConverter::ConvertMibEnumOfCharacterSetToIdentifierL(),
|
sl@0
|
164 |
CCnvCharacterSetConverter::ConvertCharacterSetIdentifierToMibEnumL() functions
|
sl@0
|
165 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
166 |
@SYMREQ REQ0000
|
sl@0
|
167 |
*/
|
sl@0
|
168 |
void CT_GBK::CharacterSetValueAndMIBTests(CCnvCharacterSetConverter& aCharacterSetConverter, RFs& aFileServerSession)
|
sl@0
|
169 |
{
|
sl@0
|
170 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0513 "));
|
sl@0
|
171 |
// check that the character set value of '113' is converted to the GBK UID (0x10003ecb)
|
sl@0
|
172 |
test(aCharacterSetConverter.ConvertMibEnumOfCharacterSetToIdentifierL(KMibValue,aFileServerSession)==KCharacterSetIdentifierGbk);
|
sl@0
|
173 |
INFO_PRINTF1(_L("\nMIB->Char Set UID - OK"));
|
sl@0
|
174 |
|
sl@0
|
175 |
// check that the UCS2 GUID (0x10003ecb) is converted to the character set value of '113'
|
sl@0
|
176 |
test(aCharacterSetConverter.ConvertCharacterSetIdentifierToMibEnumL(KCharacterSetIdentifierGbk,aFileServerSession)==KMibValue);
|
sl@0
|
177 |
INFO_PRINTF1(_L("\nChar Set UID->MIB - OK"));
|
sl@0
|
178 |
}
|
sl@0
|
179 |
/**
|
sl@0
|
180 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0514
|
sl@0
|
181 |
@SYMTestCaseDesc Conversion tests for GBK to Unicode
|
sl@0
|
182 |
@SYMTestPriority Medium
|
sl@0
|
183 |
@SYMTestActions Tests for conversion from GBK to Unicode and vice versa.
|
sl@0
|
184 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
185 |
@SYMREQ REQ0000
|
sl@0
|
186 |
*/
|
sl@0
|
187 |
void CT_GBK::DoE32MainL()
|
sl@0
|
188 |
{
|
sl@0
|
189 |
RFs fileServerSession;
|
sl@0
|
190 |
CleanupClosePushL(fileServerSession);
|
sl@0
|
191 |
User::LeaveIfError(fileServerSession.Connect());
|
sl@0
|
192 |
CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
|
sl@0
|
193 |
CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
|
sl@0
|
194 |
INFO_PRINTF1(_L("Available:\n"));
|
sl@0
|
195 |
for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
|
sl@0
|
196 |
{
|
sl@0
|
197 |
const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
|
sl@0
|
198 |
characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
|
sl@0
|
199 |
TPtrC charactersSetName(charactersSet.Name());
|
sl@0
|
200 |
if (charactersSet.NameIsFileName())
|
sl@0
|
201 |
{
|
sl@0
|
202 |
charactersSetName.Set(TParsePtrC(charactersSetName).Name());
|
sl@0
|
203 |
}
|
sl@0
|
204 |
INFO_PRINTF2(_L(" %S\n"), &charactersSetName);
|
sl@0
|
205 |
}
|
sl@0
|
206 |
TPtrC8 originalGbk;
|
sl@0
|
207 |
TBuf16<KBufferLength> originalUnicode;
|
sl@0
|
208 |
TBuf8<KBufferLength> generatedGbk;
|
sl@0
|
209 |
TBuf16<KBufferLength> generatedUnicode;
|
sl@0
|
210 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
211 |
|
sl@0
|
212 |
// test that we can get MIB and Charset values
|
sl@0
|
213 |
CharacterSetValueAndMIBTests(*characterSetConverter, fileServerSession);
|
sl@0
|
214 |
|
sl@0
|
215 |
characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierGbk, *arrayOfCharacterSetsAvailable, fileServerSession);
|
sl@0
|
216 |
|
sl@0
|
217 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0514 Testing characters shared with GB 2312-80 and characters only in GBK "));
|
sl@0
|
218 |
originalGbk.Set(_L8("A\xfd\x7d\xdd\xb6\xb1\xc9\xe9\x8e\xe8\x9d""E b\xd3\x59\xd2\x40\x95\xc0"));
|
sl@0
|
219 |
originalUnicode.Format(_L16("A%c%c%c%c%cE b%c%c%c"), 0x9f77, 0x837b, 0x9119, 0x95b9, 0x94e6, 0x89bb, 0x8938, 0x66b2);
|
sl@0
|
220 |
TestTruncatedConversionFromUnicodeToGbk(*characterSetConverter, originalUnicode);
|
sl@0
|
221 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 0, 0, 12, 0, originalGbk, originalUnicode);
|
sl@0
|
222 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 1, 2, 11, 1, originalGbk, originalUnicode);
|
sl@0
|
223 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 3, 4, 10, 3, originalGbk, originalUnicode);
|
sl@0
|
224 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 5, 6, 9, 5, originalGbk, originalUnicode);
|
sl@0
|
225 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 7, 8, 8, 7, originalGbk, originalUnicode);
|
sl@0
|
226 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 9, 10, 7, 9, originalGbk, originalUnicode);
|
sl@0
|
227 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 11, 11, 6, 11, originalGbk, originalUnicode);
|
sl@0
|
228 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 12, 12, 5, 12, originalGbk, originalUnicode);
|
sl@0
|
229 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 13, 13, 4, 13, originalGbk, originalUnicode);
|
sl@0
|
230 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 14, 15, 3, 14, originalGbk, originalUnicode);
|
sl@0
|
231 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 16, 17, 2, 16, originalGbk, originalUnicode);
|
sl@0
|
232 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 18, 19, 1, 18, originalGbk, originalUnicode);
|
sl@0
|
233 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 20, 40, 0, 20, originalGbk, originalUnicode);
|
sl@0
|
234 |
TestTruncatedConversionToUnicodeFromGbk(*characterSetConverter, originalUnicode, originalGbk);
|
sl@0
|
235 |
TestTruncatedConversionToUnicodeFromGbk(*characterSetConverter, originalUnicode.Mid(1, 2), originalGbk.Mid(1, 4));
|
sl@0
|
236 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 0, 0, 20, 0, originalUnicode, originalGbk);
|
sl@0
|
237 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 1, 1, 19, 1, originalUnicode, originalGbk);
|
sl@0
|
238 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 2, 2, 17, 2, originalUnicode, originalGbk);
|
sl@0
|
239 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 3, 3, 15, 3, originalUnicode, originalGbk);
|
sl@0
|
240 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 4, 4, 13, 4, originalUnicode, originalGbk);
|
sl@0
|
241 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 5, 5, 11, 5, originalUnicode, originalGbk);
|
sl@0
|
242 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 6, 6, 9, 6, originalUnicode, originalGbk);
|
sl@0
|
243 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 7, 7, 8, 7, originalUnicode, originalGbk);
|
sl@0
|
244 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 8, 8, 7, 8, originalUnicode, originalGbk);
|
sl@0
|
245 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 9, 9, 6, 9, originalUnicode, originalGbk);
|
sl@0
|
246 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 10, 10, 4, 10, originalUnicode, originalGbk);
|
sl@0
|
247 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 11, 11, 2, 11, originalUnicode, originalGbk);
|
sl@0
|
248 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 12, 30, 0, 12, originalUnicode, originalGbk);
|
sl@0
|
249 |
|
sl@0
|
250 |
INFO_PRINTF1(_L("Testing GBK characters where the first byte has the high-bit set and the second byte doesn't"));
|
sl@0
|
251 |
originalGbk.Set(_L8("\x20\x5d\xa0\x5d\xa0\xdd"));
|
sl@0
|
252 |
originalUnicode.Format(_L16(" ]%c%c"), 0x71f7, 0x72a6);
|
sl@0
|
253 |
TestTruncatedConversionFromUnicodeToGbk(*characterSetConverter, originalUnicode);
|
sl@0
|
254 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 0, 0, 4, 0, originalGbk, originalUnicode);
|
sl@0
|
255 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 1, 1, 3, 1, originalGbk, originalUnicode);
|
sl@0
|
256 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 2, 3, 2, 2, originalGbk, originalUnicode);
|
sl@0
|
257 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 4, 5, 1, 4, originalGbk, originalUnicode);
|
sl@0
|
258 |
TestSplittingConvertingFromUnicodeToGbk(*characterSetConverter, 6, 20, 0, 6, originalGbk, originalUnicode);
|
sl@0
|
259 |
TestTruncatedConversionToUnicodeFromGbk(*characterSetConverter, originalUnicode, originalGbk);
|
sl@0
|
260 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 0, 0, 6, 0, originalUnicode, originalGbk);
|
sl@0
|
261 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 1, 1, 5, 1, originalUnicode, originalGbk);
|
sl@0
|
262 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 2, 2, 4, 2, originalUnicode, originalGbk);
|
sl@0
|
263 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 3, 3, 2, 3, originalUnicode, originalGbk);
|
sl@0
|
264 |
TestSplittingConvertingToUnicodeFromGbk(*characterSetConverter, 4, 20, 0, 4, originalUnicode, originalGbk);
|
sl@0
|
265 |
|
sl@0
|
266 |
INFO_PRINTF1(_L("Testing the many-to-many mapping in GBK"));
|
sl@0
|
267 |
originalGbk.Set(_L8("\xa8\x44\xa1\xaa"));
|
sl@0
|
268 |
test(characterSetConverter->ConvertToUnicode(generatedUnicode, originalGbk, state)==0);
|
sl@0
|
269 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
270 |
test(generatedUnicode.Length()==2);
|
sl@0
|
271 |
test(generatedUnicode[0]==0x2015);
|
sl@0
|
272 |
test(generatedUnicode[1]==0x2015);
|
sl@0
|
273 |
originalUnicode.SetLength(2);
|
sl@0
|
274 |
originalUnicode[0]=0x2014;
|
sl@0
|
275 |
originalUnicode[1]=0x2015;
|
sl@0
|
276 |
test(characterSetConverter->ConvertFromUnicode(generatedGbk, originalUnicode)==0);
|
sl@0
|
277 |
test(generatedGbk==_L8("\xa1\xaa\xa1\xaa"));
|
sl@0
|
278 |
|
sl@0
|
279 |
INFO_PRINTF1(_L("Testing truncated GBK sequences"));
|
sl@0
|
280 |
originalGbk.Set(_L8("qwe\xb5"));
|
sl@0
|
281 |
test(characterSetConverter->ConvertToUnicode(generatedUnicode, originalGbk, state)==1);
|
sl@0
|
282 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
283 |
test(generatedUnicode==_L16("qwe"));
|
sl@0
|
284 |
originalGbk.Set(_L8("qwe\x80"));
|
sl@0
|
285 |
test(characterSetConverter->ConvertToUnicode(generatedUnicode, originalGbk, state)==1);
|
sl@0
|
286 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
287 |
test(generatedUnicode==_L16("qwe"));
|
sl@0
|
288 |
CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession
|
sl@0
|
289 |
}
|
sl@0
|
290 |
|
sl@0
|
291 |
CT_GBK::CT_GBK()
|
sl@0
|
292 |
{
|
sl@0
|
293 |
SetTestStepName(KTestStep_T_GBK);
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
TVerdict CT_GBK::doTestStepL()
|
sl@0
|
297 |
{
|
sl@0
|
298 |
SetTestStepResult(EFail);
|
sl@0
|
299 |
|
sl@0
|
300 |
__UHEAP_MARK;
|
sl@0
|
301 |
TRAPD(error1, DoE32MainL());
|
sl@0
|
302 |
__UHEAP_MARKEND;
|
sl@0
|
303 |
|
sl@0
|
304 |
if(error1 == KErrNone)
|
sl@0
|
305 |
{
|
sl@0
|
306 |
SetTestStepResult(EPass);
|
sl@0
|
307 |
}
|
sl@0
|
308 |
|
sl@0
|
309 |
return TestStepResult();
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|