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_jis.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-0529
|
sl@0
|
39 |
@SYMTestCaseDesc Tests for truncated conversion from Unicode to JIS
|
sl@0
|
40 |
@SYMTestPriority Medium
|
sl@0
|
41 |
@SYMTestActions Tests for truncated conversion from Unicode to JIS and back to Unicode
|
sl@0
|
42 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
43 |
@SYMREQ REQ0000
|
sl@0
|
44 |
*/
|
sl@0
|
45 |
void CT_JIS::TestTruncatedConversionFromUnicodeToJis(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aOriginalUnicode)
|
sl@0
|
46 |
{
|
sl@0
|
47 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0529 "));
|
sl@0
|
48 |
for (TInt i=aOriginalUnicode.Length(); i>=0; --i)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
TBuf8<KBufferLength> generatedJis;
|
sl@0
|
51 |
test(aCharacterSetConverter.ConvertFromUnicode(generatedJis, aOriginalUnicode.Left(i))>=0);
|
sl@0
|
52 |
TBuf8<KBufferLength> generatedsecondPartOfJis;
|
sl@0
|
53 |
test(aCharacterSetConverter.ConvertFromUnicode(generatedsecondPartOfJis, aOriginalUnicode.Mid(i))==0);
|
sl@0
|
54 |
generatedJis.Append(generatedsecondPartOfJis);
|
sl@0
|
55 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
56 |
TBuf16<KBufferLength> generatedUnicode;
|
sl@0
|
57 |
test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedJis, state)==0);
|
sl@0
|
58 |
test(generatedUnicode==aOriginalUnicode);
|
sl@0
|
59 |
}
|
sl@0
|
60 |
}
|
sl@0
|
61 |
/**
|
sl@0
|
62 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0530
|
sl@0
|
63 |
@SYMTestCaseDesc Splitting and converting from Unicode to JIS test
|
sl@0
|
64 |
@SYMTestPriority Medium
|
sl@0
|
65 |
@SYMTestActions Tests for conversion after splitting, from Unicode to JIS and back to Unicode
|
sl@0
|
66 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
67 |
@SYMREQ REQ0000
|
sl@0
|
68 |
*/
|
sl@0
|
69 |
void CT_JIS::TestSplittingConvertingFromUnicodeToJis(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit, const TDesC8& aExpectedFirstPartOfJis, const TDesC8& aExpectedSecondPartOfJis, const TDesC16& aOriginalUnicode)
|
sl@0
|
70 |
{
|
sl@0
|
71 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0530 "));
|
sl@0
|
72 |
test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
|
sl@0
|
73 |
test(aMaximumLengthUpperLimit<=KBufferLength);
|
sl@0
|
74 |
TUint8 jisBuffer[KBufferLength];
|
sl@0
|
75 |
for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
|
sl@0
|
76 |
{
|
sl@0
|
77 |
TPtr8 generatedFirstPartOfJis(jisBuffer, i);
|
sl@0
|
78 |
test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfJis, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit);
|
sl@0
|
79 |
test(generatedFirstPartOfJis==aExpectedFirstPartOfJis);
|
sl@0
|
80 |
TBuf8<KBufferLength> generatedSecondPartOfJis;
|
sl@0
|
81 |
test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfJis, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0);
|
sl@0
|
82 |
test(generatedSecondPartOfJis==aExpectedSecondPartOfJis);
|
sl@0
|
83 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
84 |
TBuf16<KBufferLength> generatedUnicode;
|
sl@0
|
85 |
test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfJis, state)==0);
|
sl@0
|
86 |
TBuf16<KBufferLength> generatedSecondPartOfUnicode;
|
sl@0
|
87 |
test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfJis, state)==0);
|
sl@0
|
88 |
generatedUnicode.Append(generatedSecondPartOfUnicode);
|
sl@0
|
89 |
test(generatedUnicode==aOriginalUnicode);
|
sl@0
|
90 |
}
|
sl@0
|
91 |
}
|
sl@0
|
92 |
/**
|
sl@0
|
93 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0531
|
sl@0
|
94 |
@SYMTestCaseDesc Tests for truncated conversion from JIS to Unicode
|
sl@0
|
95 |
@SYMTestPriority Medium
|
sl@0
|
96 |
@SYMTestActions Tests for truncated conversion from JIS to Unicode and back to JIS
|
sl@0
|
97 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
98 |
@SYMREQ REQ0000
|
sl@0
|
99 |
*/
|
sl@0
|
100 |
void CT_JIS::TestTruncatedConversionToUnicodeFromJis(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalJis)
|
sl@0
|
101 |
{
|
sl@0
|
102 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0531 "));
|
sl@0
|
103 |
for (TInt i=aOriginalJis.Length(); i>=6; --i) // 6 is the length of JIS' longest escape sequence
|
sl@0
|
104 |
{
|
sl@0
|
105 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
106 |
TBuf16<KBufferLength> generatedUnicode;
|
sl@0
|
107 |
const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalJis.Left(i), state);
|
sl@0
|
108 |
test(returnValue>=0);
|
sl@0
|
109 |
TBuf16<KBufferLength> generatedsecondPartOfUnicode;
|
sl@0
|
110 |
test(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalJis.Mid(i-returnValue), state)==0);
|
sl@0
|
111 |
generatedUnicode.Append(generatedsecondPartOfUnicode);
|
sl@0
|
112 |
test(generatedUnicode==aExpectedUnicode);
|
sl@0
|
113 |
}
|
sl@0
|
114 |
}
|
sl@0
|
115 |
/**
|
sl@0
|
116 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0532
|
sl@0
|
117 |
@SYMTestCaseDesc Splitting and converting from JIS to Unicode test
|
sl@0
|
118 |
@SYMTestPriority Medium
|
sl@0
|
119 |
@SYMTestActions Tests for conversion after splitting, from JIS to Unicode and back to JIS
|
sl@0
|
120 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
121 |
@SYMREQ REQ0000
|
sl@0
|
122 |
*/
|
sl@0
|
123 |
void CT_JIS::TestSplittingConvertingToUnicodeFromJis(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfJisBytesNotConvertedAtSplit, TInt aExpectedLengthOfFirstPartOfUnicode, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalJis)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0532 "));
|
sl@0
|
126 |
test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
|
sl@0
|
127 |
test(aMaximumLengthUpperLimit<=KBufferLength);
|
sl@0
|
128 |
TUint16 unicodeBuffer[KBufferLength];
|
sl@0
|
129 |
for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
TPtr16 generatedFirstPartOfUnicode(unicodeBuffer, i);
|
sl@0
|
132 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
133 |
const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedFirstPartOfUnicode, aOriginalJis, state);
|
sl@0
|
134 |
test(generatedFirstPartOfUnicode==aExpectedUnicode.Left(aExpectedLengthOfFirstPartOfUnicode));
|
sl@0
|
135 |
test(returnValue==aExpectedNumberOfJisBytesNotConvertedAtSplit);
|
sl@0
|
136 |
TBuf16<KBufferLength> generatedSecondPartOfUnicode;
|
sl@0
|
137 |
test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, aOriginalJis.Right(aExpectedNumberOfJisBytesNotConvertedAtSplit), state)==0);
|
sl@0
|
138 |
test(generatedSecondPartOfUnicode==aExpectedUnicode.Mid(aExpectedLengthOfFirstPartOfUnicode));
|
sl@0
|
139 |
TBuf8<KBufferLength> generatedJis;
|
sl@0
|
140 |
test(aCharacterSetConverter.ConvertFromUnicode(generatedJis, generatedFirstPartOfUnicode)==0);
|
sl@0
|
141 |
TBuf8<KBufferLength> generatedSecondPartOfJis;
|
sl@0
|
142 |
test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfJis, generatedSecondPartOfUnicode)==0);
|
sl@0
|
143 |
generatedJis.Append(generatedSecondPartOfJis);
|
sl@0
|
144 |
TBuf16<KBufferLength> regeneratedUnicode;
|
sl@0
|
145 |
state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
146 |
test(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, generatedJis, state)==0);
|
sl@0
|
147 |
test(regeneratedUnicode==aExpectedUnicode);
|
sl@0
|
148 |
state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
149 |
test(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, aOriginalJis, state)==0);
|
sl@0
|
150 |
test(regeneratedUnicode==aExpectedUnicode);
|
sl@0
|
151 |
}
|
sl@0
|
152 |
}
|
sl@0
|
153 |
/**
|
sl@0
|
154 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0533
|
sl@0
|
155 |
@SYMTestCaseDesc Conversion of bad JIS format to Unicode test
|
sl@0
|
156 |
@SYMTestPriority Medium
|
sl@0
|
157 |
@SYMTestActions Tests to convert bad formatted JIS input to Unicode.
|
sl@0
|
158 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
159 |
@SYMREQ REQ0000
|
sl@0
|
160 |
*/
|
sl@0
|
161 |
void CT_JIS::TestIsIllFormedJis(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC8& aJis)
|
sl@0
|
162 |
{
|
sl@0
|
163 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0533 "));
|
sl@0
|
164 |
TBuf16<50> generatedUnicode;
|
sl@0
|
165 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
166 |
TPtrC8 remainderOfJis(aJis);
|
sl@0
|
167 |
TInt lastReturnValue=KMaxTInt;
|
sl@0
|
168 |
FOREVER
|
sl@0
|
169 |
{
|
sl@0
|
170 |
const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, remainderOfJis, state);
|
sl@0
|
171 |
if (returnValue==CCnvCharacterSetConverter::EErrorIllFormedInput)
|
sl@0
|
172 |
{
|
sl@0
|
173 |
break;
|
sl@0
|
174 |
}
|
sl@0
|
175 |
test(returnValue>0);
|
sl@0
|
176 |
test(returnValue<lastReturnValue);
|
sl@0
|
177 |
lastReturnValue=returnValue;
|
sl@0
|
178 |
remainderOfJis.Set(remainderOfJis.Right(returnValue));
|
sl@0
|
179 |
}
|
sl@0
|
180 |
}
|
sl@0
|
181 |
|
sl@0
|
182 |
/**
|
sl@0
|
183 |
* Utility for DEF063276 fix.
|
sl@0
|
184 |
*/
|
sl@0
|
185 |
|
sl@0
|
186 |
_LIT(KOriginalJisFilename, "z:\\test\\data\\originalJis.dat");
|
sl@0
|
187 |
|
sl@0
|
188 |
void CT_JIS::ReadDesc(TDes8& aDes, const TDesC& aFilename, RFs& aFs)
|
sl@0
|
189 |
{
|
sl@0
|
190 |
RFile file;
|
sl@0
|
191 |
TInt err = file.Open(aFs, aFilename, EFileRead);
|
sl@0
|
192 |
test(err == KErrNone);
|
sl@0
|
193 |
CleanupClosePushL(file);
|
sl@0
|
194 |
|
sl@0
|
195 |
err = file.Read(aDes);
|
sl@0
|
196 |
test(err == KErrNone);
|
sl@0
|
197 |
CleanupStack::PopAndDestroy(&file);
|
sl@0
|
198 |
}
|
sl@0
|
199 |
|
sl@0
|
200 |
/**
|
sl@0
|
201 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0534
|
sl@0
|
202 |
@SYMTestCaseDesc JIS to Unicode and Unicode to JIS conversion tests
|
sl@0
|
203 |
@SYMTestPriority Medium
|
sl@0
|
204 |
@SYMTestActions Calls up all conversion test functions from JIS to Unicode
|
sl@0
|
205 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
206 |
@SYMREQ REQ0000
|
sl@0
|
207 |
*/
|
sl@0
|
208 |
|
sl@0
|
209 |
void CT_JIS::DoE32MainL()
|
sl@0
|
210 |
{
|
sl@0
|
211 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0534 "));
|
sl@0
|
212 |
RFs fileServerSession;
|
sl@0
|
213 |
CleanupClosePushL(fileServerSession);
|
sl@0
|
214 |
User::LeaveIfError(fileServerSession.Connect());
|
sl@0
|
215 |
CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
|
sl@0
|
216 |
CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
|
sl@0
|
217 |
INFO_PRINTF1(_L("Available:\n"));
|
sl@0
|
218 |
TInt i;
|
sl@0
|
219 |
for (i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
|
sl@0
|
220 |
{
|
sl@0
|
221 |
const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
|
sl@0
|
222 |
characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
|
sl@0
|
223 |
TPtrC charactersSetName(charactersSet.Name());
|
sl@0
|
224 |
if (charactersSet.NameIsFileName())
|
sl@0
|
225 |
{
|
sl@0
|
226 |
charactersSetName.Set(TParsePtrC(charactersSetName).Name());
|
sl@0
|
227 |
}
|
sl@0
|
228 |
INFO_PRINTF2(_L(" %S\n"), &charactersSetName);
|
sl@0
|
229 |
}
|
sl@0
|
230 |
INFO_PRINTF1(_L("Testing JIS conversions"));
|
sl@0
|
231 |
characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierJis, *arrayOfCharacterSetsAvailable, fileServerSession);
|
sl@0
|
232 |
//
|
sl@0
|
233 |
INFO_PRINTF1(_L("Empty descriptor"));
|
sl@0
|
234 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 0, 10, 0, KNullDesC8, KNullDesC8, KNullDesC16);
|
sl@0
|
235 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 0, 10, 0, 0, KNullDesC16, KNullDesC8);
|
sl@0
|
236 |
INFO_PRINTF1(_L("Testing converting to JIS"));
|
sl@0
|
237 |
TBuf16<50> originalUnicode;
|
sl@0
|
238 |
originalUnicode.Format(_L16("I %c%c%c%c%c%c%c%c"), 0x611b, 0x3059, 0x308b, 0xff74, 0xff9a, 0xff68, 0xff9d, 0x4e04);
|
sl@0
|
239 |
TestTruncatedConversionFromUnicodeToJis(*characterSetConverter, originalUnicode);
|
sl@0
|
240 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 0, 3, 10, KNullDesC8, _L8("\x1b\x28\x4aI \x1b\x24\x42\x30\x26\x24\x39\x24\x6b\x1b\x28\x49\x34\x5a\x28\x5d\x1b\x24\x28\x44\x30\x22"), originalUnicode);
|
sl@0
|
241 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 4, 4, 9, _L8("\x1b\x28\x4aI"), _L8("\x1b\x28\x4a \x1b\x24\x42\x30\x26\x24\x39\x24\x6b\x1b\x28\x49\x34\x5a\x28\x5d\x1b\x24\x28\x44\x30\x22"), originalUnicode);
|
sl@0
|
242 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 5, 9, 8, _L8("\x1b\x28\x4aI "), _L8("\x1b\x24\x42\x30\x26\x24\x39\x24\x6b\x1b\x28\x49\x34\x5a\x28\x5d\x1b\x24\x28\x44\x30\x22"), originalUnicode);
|
sl@0
|
243 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 10, 11, 7, _L8("\x1b\x28\x4aI \x1b\x24\x42\x30\x26"), _L8("\x1b\x24\x42\x24\x39\x24\x6b\x1b\x28\x49\x34\x5a\x28\x5d\x1b\x24\x28\x44\x30\x22"), originalUnicode);
|
sl@0
|
244 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 12, 13, 6, _L8("\x1b\x28\x4aI \x1b\x24\x42\x30\x26\x24\x39"), _L8("\x1b\x24\x42\x24\x6b\x1b\x28\x49\x34\x5a\x28\x5d\x1b\x24\x28\x44\x30\x22"), originalUnicode);
|
sl@0
|
245 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 14, 17, 5, _L8("\x1b\x28\x4aI \x1b\x24\x42\x30\x26\x24\x39\x24\x6b"), _L8("\x1b\x28\x49\x34\x5a\x28\x5d\x1b\x24\x28\x44\x30\x22"), originalUnicode);
|
sl@0
|
246 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 18, 18, 4, _L8("\x1b\x28\x4aI \x1b\x24\x42\x30\x26\x24\x39\x24\x6b\x1b\x28\x49\x34"), _L8("\x1b\x28\x49\x5a\x28\x5d\x1b\x24\x28\x44\x30\x22"), originalUnicode);
|
sl@0
|
247 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 19, 19, 3, _L8("\x1b\x28\x4aI \x1b\x24\x42\x30\x26\x24\x39\x24\x6b\x1b\x28\x49\x34\x5a"), _L8("\x1b\x28\x49\x28\x5d\x1b\x24\x28\x44\x30\x22"), originalUnicode);
|
sl@0
|
248 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 20, 20, 2, _L8("\x1b\x28\x4aI \x1b\x24\x42\x30\x26\x24\x39\x24\x6b\x1b\x28\x49\x34\x5a\x28"), _L8("\x1b\x28\x49\x5d\x1b\x24\x28\x44\x30\x22"), originalUnicode);
|
sl@0
|
249 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 21, 26, 1, _L8("\x1b\x28\x4aI \x1b\x24\x42\x30\x26\x24\x39\x24\x6b\x1b\x28\x49\x34\x5a\x28\x5d"), _L8("\x1b\x24\x28\x44\x30\x22"), originalUnicode);
|
sl@0
|
250 |
TestSplittingConvertingFromUnicodeToJis(*characterSetConverter, 27, 40, 0, _L8("\x1b\x28\x4aI \x1b\x24\x42\x30\x26\x24\x39\x24\x6b\x1b\x28\x49\x34\x5a\x28\x5d\x1b\x24\x28\x44\x30\x22"), KNullDesC8, originalUnicode);
|
sl@0
|
251 |
INFO_PRINTF1(_L("Testing converting to Unicode"));
|
sl@0
|
252 |
|
sl@0
|
253 |
/**
|
sl@0
|
254 |
* Work around for DEF063276.
|
sl@0
|
255 |
* This literal is now loaded from a z:\test\data\originalJis.dat
|
sl@0
|
256 |
* Bullseye Coverage corrupts this literal to avoid this it is stored in a file as to not be touched by Bullseye Coverage.
|
sl@0
|
257 |
*/
|
sl@0
|
258 |
// const TPtrC8 originalJis(_S8("\\\x1b\x28\x42\\\xb4\\\x0e\x31\x0f\\\x0e\x4a\x5e\x1b\x26\x40\x1b\x24\x42\x30\x24\x1b\x24\x28\x44\x30\x24\x1b\x28\x49\x21\x0e\x22\x0f\x30\x24\x0e"));
|
sl@0
|
259 |
|
sl@0
|
260 |
TBuf8<64> buf;
|
sl@0
|
261 |
ReadDesc(buf, KOriginalJisFilename, fileServerSession);
|
sl@0
|
262 |
|
sl@0
|
263 |
TBuf16<50> expectedUnicode;
|
sl@0
|
264 |
expectedUnicode.Format(_L16("\xa5\\%c\xa5%c\xa5%c%c%c%c%c%c0$"), 0xff74, 0xff71, 0xff8a, 0xff9e, 0x963f, 0x4e0c, 0xff61, 0xff62);
|
sl@0
|
265 |
TestTruncatedConversionToUnicodeFromJis(*characterSetConverter, expectedUnicode, buf);
|
sl@0
|
266 |
TestTruncatedConversionToUnicodeFromJis(*characterSetConverter, _L16(" Hello"), _L8("\x1b\x24\x42\x1b\x28\x4a\x1b\x24\x42\x1b\x28\x4a\x1b\x26\x40\x1b\x24\x42\x1b\x28\x4a Hello"));
|
sl@0
|
267 |
TestTruncatedConversionToUnicodeFromJis(*characterSetConverter, _L16(" Hello"), _L8("\x1b\x26\x40\x1b\x24\x42\x1b\x28\x4a Hello"));
|
sl@0
|
268 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 0, 0, 38, 0, expectedUnicode, buf);
|
sl@0
|
269 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 1, 1, 34, 1, expectedUnicode, buf);
|
sl@0
|
270 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 2, 2, 33, 2, expectedUnicode, buf);
|
sl@0
|
271 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 3, 3, 32, 3, expectedUnicode, buf);
|
sl@0
|
272 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 4, 4, 30, 4, expectedUnicode, buf);
|
sl@0
|
273 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 5, 5, 28, 5, expectedUnicode, buf);
|
sl@0
|
274 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 6, 6, 26, 6, expectedUnicode, buf);
|
sl@0
|
275 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 7, 7, 25, 7, expectedUnicode, buf);
|
sl@0
|
276 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 8, 8, 24, 8, expectedUnicode, buf);
|
sl@0
|
277 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 9, 9, 12, 9, expectedUnicode, buf);
|
sl@0
|
278 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 10, 10, 7, 10, expectedUnicode, buf);
|
sl@0
|
279 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 11, 11, 5, 11, expectedUnicode, buf);
|
sl@0
|
280 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 12, 12, 3, 12, expectedUnicode, buf);
|
sl@0
|
281 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 13, 13, 2, 13, expectedUnicode, buf);
|
sl@0
|
282 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, 14, 30, 0, 14, expectedUnicode, buf);
|
sl@0
|
283 |
|
sl@0
|
284 |
// End fix
|
sl@0
|
285 |
INFO_PRINTF1(_L("Testing the default JIS state"));
|
sl@0
|
286 |
for (i=0; i<=6; ++i)
|
sl@0
|
287 |
{
|
sl@0
|
288 |
TestSplittingConvertingToUnicodeFromJis(*characterSetConverter, i, i, 6-i, i, _L16("Hello\xa5"), _L8("Hello\\"));
|
sl@0
|
289 |
}
|
sl@0
|
290 |
INFO_PRINTF1(_L("Testing ill-formed JIS"));
|
sl@0
|
291 |
TestIsIllFormedJis(*characterSetConverter, _L8("abc \x1b\x26\x40\x1b\x24\x42\x21\x1b\x28\x4a def"));
|
sl@0
|
292 |
TestIsIllFormedJis(*characterSetConverter, _L8("abc \x1b\x26\x40\x1b\x24\x42\x21\x21\x21\x1b\x28\x4a def"));
|
sl@0
|
293 |
TestIsIllFormedJis(*characterSetConverter, _L8("abc \x1b\x26\x40\x1b\x24\x42\x21\x21\x21\x21\x21\x1b\x28\x4a def"));
|
sl@0
|
294 |
TestIsIllFormedJis(*characterSetConverter, _L8("abc \x1b"));
|
sl@0
|
295 |
TestIsIllFormedJis(*characterSetConverter, _L8("abc \x1b\x24"));
|
sl@0
|
296 |
TestIsIllFormedJis(*characterSetConverter, _L8("abc \x1b\x24\xff"));
|
sl@0
|
297 |
CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession
|
sl@0
|
298 |
}
|
sl@0
|
299 |
|
sl@0
|
300 |
CT_JIS::CT_JIS()
|
sl@0
|
301 |
{
|
sl@0
|
302 |
SetTestStepName(KTestStep_T_JIS);
|
sl@0
|
303 |
}
|
sl@0
|
304 |
|
sl@0
|
305 |
TVerdict CT_JIS::doTestStepL()
|
sl@0
|
306 |
{
|
sl@0
|
307 |
SetTestStepResult(EFail);
|
sl@0
|
308 |
|
sl@0
|
309 |
__UHEAP_MARK;
|
sl@0
|
310 |
TRAPD(error1, DoE32MainL());
|
sl@0
|
311 |
__UHEAP_MARKEND;
|
sl@0
|
312 |
|
sl@0
|
313 |
if(error1 == KErrNone)
|
sl@0
|
314 |
{
|
sl@0
|
315 |
SetTestStepResult(EPass);
|
sl@0
|
316 |
}
|
sl@0
|
317 |
|
sl@0
|
318 |
return TestStepResult();
|
sl@0
|
319 |
}
|