sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-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_ucs2.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 = 1000;
|
sl@0
|
37 |
|
sl@0
|
38 |
const TInt KBufferLength1=1;
|
sl@0
|
39 |
const TInt KBufferLength6=6;
|
sl@0
|
40 |
const TInt KBufferLength8=8;
|
sl@0
|
41 |
const TInt KBufferLength40=40;
|
sl@0
|
42 |
|
sl@0
|
43 |
const TPtrC8 KForeignBufferEven12LE(_S8("\xff\xfe\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a"));
|
sl@0
|
44 |
const TPtrC8 KForeignBufferOdd13LE(_S8("\xff\xfe\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b"));
|
sl@0
|
45 |
const TPtrC8 KForeignBufferEven12BE(_S8("\xfe\xff\x42\x41\x44\x43\x46\x45\x48\x47\x4a\x49"));
|
sl@0
|
46 |
const TPtrC8 KForeignBufferOdd13BE(_S8("\xfe\xff\x42\x41\x44\x43\x46\x45\x48\x47\x4a\x49\x4b"));
|
sl@0
|
47 |
|
sl@0
|
48 |
const TPtrC8 KForeignBufferEvenWithoutBOM10LE(_S8("\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a"));
|
sl@0
|
49 |
const TPtrC8 KForeignBufferOddWithoutBOM11LE(_S8("\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b"));
|
sl@0
|
50 |
const TPtrC8 KForeignBufferEvenWithoutBOM10BE(_S8("\x42\x41\x44\x43\x46\x45\x48\x47\x4a\x49"));
|
sl@0
|
51 |
const TPtrC8 KForeignBufferOddWithoutBOM11BE(_S8("\x42\x41\x44\x43\x46\x45\x48\x47\x4a\x49\x4b"));
|
sl@0
|
52 |
|
sl@0
|
53 |
const TPtrC8 KForeignBufferEven24LE(_S8("\xff\xfe\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56"));
|
sl@0
|
54 |
const TPtrC8 KForeignBufferOdd25LE(_S8("\xff\xfe\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57"));
|
sl@0
|
55 |
const TPtrC8 KForeignBufferEven24BE(_S8("\xfe\xff\x42\x41\x44\x43\x46\x45\x48\x47\x4a\x49\x4c\x4b\x4e\x4d\x50\x4f\x52\x51\x54\x53\x56\x55"));
|
sl@0
|
56 |
const TPtrC8 KForeignBufferOdd25BE(_S8("\xfe\xff\x42\x41\x44\x43\x46\x45\x48\x47\x4a\x49\x4c\x4b\x4e\x4d\x50\x4f\x52\x51\x54\x53\x56\x55\x57"));
|
sl@0
|
57 |
|
sl@0
|
58 |
const TPtrC8 KForeignBufferEvenWithoutBOM22LE(_S8("\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56"));
|
sl@0
|
59 |
const TPtrC8 KForeignBufferOddWithoutBOM23LE(_S8("\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57"));
|
sl@0
|
60 |
const TPtrC8 KForeignBufferEvenWithoutBOM22BE(_S8("\x42\x41\x44\x43\x46\x45\x48\x47\x4a\x49\x4c\x4b\x4e\x4d\x50\x4f\x52\x51\x54\x53\x56\x55"));
|
sl@0
|
61 |
const TPtrC8 KForeignBufferOddWithoutBOM23BE(_S8("\x42\x41\x44\x43\x46\x45\x48\x47\x4a\x49\x4c\x4b\x4e\x4d\x50\x4f\x52\x51\x54\x53\x56\x55\x57"));
|
sl@0
|
62 |
|
sl@0
|
63 |
const TPtrC16 KUnicodeBufferEven14BE(_S16("\xfeff\x4142\x4344\x4546\x4748\x494a\x4b4c\x4d4e\x4f50\x5152\x5354\x5556\x5758\x595a"));
|
sl@0
|
64 |
const TPtrC16 KUnicodeBufferOdd15BE(_S16("\xfeff\x4142\x4344\x4546\x4748\x494a\x4b4c\x4d4e\x4f50\x5152\x5354\x5556\x5758\x595a\x5b5c"));
|
sl@0
|
65 |
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0553
|
sl@0
|
68 |
@SYMTestCaseDesc 8 bit to UCS2 Little Endian Conversion - Single pass test
|
sl@0
|
69 |
@SYMTestPriority Medium
|
sl@0
|
70 |
@SYMTestActions Tests a 8 bit string to 16 bit UCS2 conversion.
|
sl@0
|
71 |
Test with and without Byte Order Mark. Byte Order Mark is set to Little Endian.
|
sl@0
|
72 |
Output buffer is large enough to contain the complete input string
|
sl@0
|
73 |
on a single pass
|
sl@0
|
74 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
75 |
@SYMREQ REQ0000
|
sl@0
|
76 |
*/
|
sl@0
|
77 |
void CT_UCS2::LEConversionSinglePassBOM(CCnvCharacterSetConverter& aCharacterSetConverter)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0553 "));
|
sl@0
|
80 |
TBuf16<KBufferLength40> generatedUnicode;
|
sl@0
|
81 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
82 |
TInt numberOfUnconvertibleCharacters=0;
|
sl@0
|
83 |
TInt indexOfFirstByteOfFirstUnconvertibleCharacter=0;
|
sl@0
|
84 |
TInt numberLeft =0;
|
sl@0
|
85 |
|
sl@0
|
86 |
// set the default endianness to little Endian
|
sl@0
|
87 |
aCharacterSetConverter.SetDefaultEndiannessOfForeignCharacters(CCnvCharacterSetConverter::ELittleEndian);
|
sl@0
|
88 |
|
sl@0
|
89 |
// test even number of foreign bytes
|
sl@0
|
90 |
aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEven12LE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
91 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49"));
|
sl@0
|
92 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
93 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
94 |
INFO_PRINTF1(_L("\nLittleEndianConversionSinglePassEvenBOM - OK"));
|
sl@0
|
95 |
|
sl@0
|
96 |
// test even number of foreign bytes without BOM
|
sl@0
|
97 |
aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEvenWithoutBOM10LE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
98 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49"));
|
sl@0
|
99 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
100 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
101 |
INFO_PRINTF1(_L("\nLittleEndianConversionSinglePassEvenBOM - OK"));
|
sl@0
|
102 |
|
sl@0
|
103 |
// test odd number of foreign bytes
|
sl@0
|
104 |
state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
105 |
numberLeft = aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOdd13LE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
106 |
test(numberLeft==1);
|
sl@0
|
107 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49"));
|
sl@0
|
108 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
109 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
110 |
|
sl@0
|
111 |
// test odd number of foreign bytes without BOM
|
sl@0
|
112 |
numberLeft = aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOddWithoutBOM11LE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
113 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49"));
|
sl@0
|
114 |
test(numberLeft==1);
|
sl@0
|
115 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
116 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
117 |
|
sl@0
|
118 |
INFO_PRINTF1(_L("\nLittleEndianConversionSinglePassOddBOM - OK"));
|
sl@0
|
119 |
}
|
sl@0
|
120 |
/**
|
sl@0
|
121 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0554
|
sl@0
|
122 |
@SYMTestCaseDesc 8 bit to UCS2 Little Endian Conversion - Multiple pass test
|
sl@0
|
123 |
@SYMTestPriority Medium
|
sl@0
|
124 |
@SYMTestActions Tests a 8 bit string to 16 bit UCS2 conversion.
|
sl@0
|
125 |
With and without Byte Order Mark. Byte Order Mark is set to Little Endian.
|
sl@0
|
126 |
Output buffer is NOT large enough to contain the complete input string
|
sl@0
|
127 |
on a single pass. Multiple calls are made to complete translation.
|
sl@0
|
128 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
129 |
@SYMREQ REQ0000
|
sl@0
|
130 |
*/
|
sl@0
|
131 |
void CT_UCS2::LEConversionMultiplePassBOM(CCnvCharacterSetConverter& aCharacterSetConverter)
|
sl@0
|
132 |
{
|
sl@0
|
133 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0554 "));
|
sl@0
|
134 |
TBuf16<KBufferLength6> generatedUnicode;
|
sl@0
|
135 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
136 |
TInt numberOfUnconvertibleCharacters=0;
|
sl@0
|
137 |
TInt indexOfFirstByteOfFirstUnconvertibleCharacter=0;
|
sl@0
|
138 |
|
sl@0
|
139 |
// set the default endianness to little Endian
|
sl@0
|
140 |
aCharacterSetConverter.SetDefaultEndiannessOfForeignCharacters(CCnvCharacterSetConverter::ELittleEndian);
|
sl@0
|
141 |
|
sl@0
|
142 |
// test even number of foreign bytes
|
sl@0
|
143 |
// first pass
|
sl@0
|
144 |
TInt numberUnconverted;
|
sl@0
|
145 |
numberUnconverted = aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEven24LE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
146 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49\x4c4b"));
|
sl@0
|
147 |
test(numberUnconverted==10);
|
sl@0
|
148 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
149 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
150 |
|
sl@0
|
151 |
// test even number of foreign bytes without BOM
|
sl@0
|
152 |
numberUnconverted = aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEvenWithoutBOM22LE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
153 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49\x4c4b"));
|
sl@0
|
154 |
test(numberUnconverted==10);
|
sl@0
|
155 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
156 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
157 |
|
sl@0
|
158 |
// second pass
|
sl@0
|
159 |
numberUnconverted = aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEven24LE.Right(numberUnconverted), state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
160 |
test(numberUnconverted==0);
|
sl@0
|
161 |
test(generatedUnicode==_L16("\x4e4d\x504f\x5251\x5453\x5655"));
|
sl@0
|
162 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
163 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
164 |
INFO_PRINTF1(_L("\nLittleEndianConversionMultiplePassOddEven - OK"));
|
sl@0
|
165 |
|
sl@0
|
166 |
// without BOM
|
sl@0
|
167 |
numberOfUnconvertibleCharacters=10;
|
sl@0
|
168 |
aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEvenWithoutBOM22LE.Right(numberOfUnconvertibleCharacters), state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
169 |
test(generatedUnicode==_L16("\x4e4d\x504f\x5251\x5453\x5655"));
|
sl@0
|
170 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
171 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
172 |
INFO_PRINTF1(_L("\nLittleEndianConversionMultiplePassOddEven - OK"));
|
sl@0
|
173 |
|
sl@0
|
174 |
|
sl@0
|
175 |
// test odd number of foreign bytes
|
sl@0
|
176 |
// first pass
|
sl@0
|
177 |
state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
178 |
numberUnconverted = aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOdd25LE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
179 |
test(numberUnconverted==11);
|
sl@0
|
180 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
181 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49\x4c4b"));
|
sl@0
|
182 |
|
sl@0
|
183 |
// without BOM
|
sl@0
|
184 |
numberUnconverted = aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOddWithoutBOM23LE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
185 |
test(numberUnconverted==11);
|
sl@0
|
186 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
187 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49\x4c4b"));
|
sl@0
|
188 |
|
sl@0
|
189 |
// second pass
|
sl@0
|
190 |
numberUnconverted = aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOdd25LE.Right(numberUnconverted), state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
191 |
test(generatedUnicode==_L16("\x4e4d\x504f\x5251\x5453\x5655"));
|
sl@0
|
192 |
test(numberUnconverted==1);
|
sl@0
|
193 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
194 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
195 |
|
sl@0
|
196 |
// without BOM
|
sl@0
|
197 |
numberUnconverted = 11;
|
sl@0
|
198 |
numberUnconverted = aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOddWithoutBOM23LE.Right(numberUnconverted), state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
199 |
test(numberUnconverted==1);
|
sl@0
|
200 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
201 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
202 |
test(generatedUnicode==_L16("\x4e4d\x504f\x5251\x5453\x5655"));
|
sl@0
|
203 |
|
sl@0
|
204 |
|
sl@0
|
205 |
INFO_PRINTF1(_L("\nLittleEndianConversionMultiplePassOddBOM - OK"));
|
sl@0
|
206 |
}
|
sl@0
|
207 |
/**
|
sl@0
|
208 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0555
|
sl@0
|
209 |
@SYMTestCaseDesc 8 bit to UCS2 Big Endian Conversion - Single pass
|
sl@0
|
210 |
@SYMTestPriority Medium
|
sl@0
|
211 |
@SYMTestActions Tests a 8 bit string to 16 bit UCS2 conversion.
|
sl@0
|
212 |
With and without Byte Order Mark. Byte Order Mark is set to Big Endian.
|
sl@0
|
213 |
Output buffer is large enough to contain the complete input string
|
sl@0
|
214 |
on a single pass
|
sl@0
|
215 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
216 |
@SYMREQ REQ0000
|
sl@0
|
217 |
*/
|
sl@0
|
218 |
void CT_UCS2::BEConversionSinglePassBOM(CCnvCharacterSetConverter& aCharacterSetConverter)
|
sl@0
|
219 |
{
|
sl@0
|
220 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0555 "));
|
sl@0
|
221 |
TBuf16<KBufferLength40> generatedUnicode;
|
sl@0
|
222 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
223 |
TInt numberOfUnconvertibleCharacters=0;
|
sl@0
|
224 |
TInt indexOfFirstByteOfFirstUnconvertibleCharacter=0;
|
sl@0
|
225 |
TInt numberLeft=0;
|
sl@0
|
226 |
|
sl@0
|
227 |
// set the default endianness to Big Endian
|
sl@0
|
228 |
aCharacterSetConverter.SetDefaultEndiannessOfForeignCharacters(CCnvCharacterSetConverter::EBigEndian);
|
sl@0
|
229 |
|
sl@0
|
230 |
// test even number of foreign bytes
|
sl@0
|
231 |
aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEven12BE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
232 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49"));
|
sl@0
|
233 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
234 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
235 |
INFO_PRINTF1(_L("\nBigEndianConversionSinglePassEvenBOM - OK"));
|
sl@0
|
236 |
|
sl@0
|
237 |
// test even number of foreign bytes without BOM
|
sl@0
|
238 |
aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEvenWithoutBOM10BE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
239 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49"));
|
sl@0
|
240 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
241 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
242 |
INFO_PRINTF1(_L("\nBigEndianConversionSinglePassEvenBOM - OK"));
|
sl@0
|
243 |
|
sl@0
|
244 |
|
sl@0
|
245 |
// test odd number of foreign bytes
|
sl@0
|
246 |
state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
247 |
numberLeft = aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOdd13BE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
248 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49"));
|
sl@0
|
249 |
test(numberLeft==1);
|
sl@0
|
250 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
251 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
252 |
|
sl@0
|
253 |
// test odd number of foreign bytes without BOM
|
sl@0
|
254 |
numberLeft = aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOddWithoutBOM11BE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
255 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49"));
|
sl@0
|
256 |
test(numberLeft==1);
|
sl@0
|
257 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
258 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
259 |
|
sl@0
|
260 |
INFO_PRINTF1(_L("\nBigEndianConversionSinglePassOddBOM - OK"));
|
sl@0
|
261 |
}
|
sl@0
|
262 |
/**
|
sl@0
|
263 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0556
|
sl@0
|
264 |
@SYMTestCaseDesc 8 bit to UCS2 Big Endian Conversion - Multiple pass test
|
sl@0
|
265 |
@SYMTestPriority Medium
|
sl@0
|
266 |
@SYMTestActions Tests a 8 bit string to 16 bit UCS2 conversion.
|
sl@0
|
267 |
With and without Byte Order Mark. Byte Order Mark is set to Big Endian.
|
sl@0
|
268 |
Output buffer is NOT large enough to contain the complete input string
|
sl@0
|
269 |
on a single pass. Multiple calls are made to complete translation.
|
sl@0
|
270 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
271 |
@SYMREQ REQ0000
|
sl@0
|
272 |
*/
|
sl@0
|
273 |
void CT_UCS2::BEConversionMultiplePassBOM(CCnvCharacterSetConverter& aCharacterSetConverter)
|
sl@0
|
274 |
{
|
sl@0
|
275 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0556 "));
|
sl@0
|
276 |
TBuf16<KBufferLength6> generatedUnicode;
|
sl@0
|
277 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
278 |
TInt numberOfUnconvertibleCharacters=0;
|
sl@0
|
279 |
TInt indexOfFirstByteOfFirstUnconvertibleCharacter=0;
|
sl@0
|
280 |
TInt numberUnconverted=0;
|
sl@0
|
281 |
|
sl@0
|
282 |
// set the default endianness to Big Endian
|
sl@0
|
283 |
aCharacterSetConverter.SetDefaultEndiannessOfForeignCharacters(CCnvCharacterSetConverter::EBigEndian);
|
sl@0
|
284 |
|
sl@0
|
285 |
// test even number of foreign bytes
|
sl@0
|
286 |
// first pass
|
sl@0
|
287 |
numberUnconverted=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEven24BE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
288 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49\x4c4b"));
|
sl@0
|
289 |
test(numberUnconverted==10);
|
sl@0
|
290 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
291 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
292 |
|
sl@0
|
293 |
// without BOM
|
sl@0
|
294 |
numberUnconverted=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEvenWithoutBOM22BE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
295 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49\x4c4b"));
|
sl@0
|
296 |
test(numberUnconverted==10);
|
sl@0
|
297 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
298 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
299 |
|
sl@0
|
300 |
// second pass
|
sl@0
|
301 |
numberUnconverted=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEven24BE.Right(numberUnconverted), state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
302 |
test(generatedUnicode==_L16("\x4e4d\x504f\x5251\x5453\x5655"));
|
sl@0
|
303 |
test(numberUnconverted==0);
|
sl@0
|
304 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
305 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
306 |
INFO_PRINTF1(_L("\nBigEndianConversionMultiplePassOddEven - OK"));
|
sl@0
|
307 |
|
sl@0
|
308 |
// without BOM
|
sl@0
|
309 |
numberOfUnconvertibleCharacters=10;
|
sl@0
|
310 |
numberUnconverted=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferEvenWithoutBOM22BE.Right(numberOfUnconvertibleCharacters), state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
311 |
test(generatedUnicode==_L16("\x4e4d\x504f\x5251\x5453\x5655"));
|
sl@0
|
312 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
313 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
314 |
INFO_PRINTF1(_L("\nBigEndianConversionMultiplePassOddEven - OK"));
|
sl@0
|
315 |
|
sl@0
|
316 |
// test odd number of foreign bytes
|
sl@0
|
317 |
// first pass
|
sl@0
|
318 |
state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
319 |
numberUnconverted=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOdd25BE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
320 |
test(numberUnconverted==11);
|
sl@0
|
321 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
322 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
323 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49\x4c4b"));
|
sl@0
|
324 |
|
sl@0
|
325 |
// without BOM
|
sl@0
|
326 |
numberUnconverted=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOddWithoutBOM23BE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
327 |
test(numberUnconverted==11);
|
sl@0
|
328 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
329 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
330 |
test(generatedUnicode==_L16("\x4241\x4443\x4645\x4847\x4a49\x4c4b"));
|
sl@0
|
331 |
|
sl@0
|
332 |
// second pass
|
sl@0
|
333 |
numberUnconverted=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOdd25BE.Right(numberUnconverted), state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
334 |
test(generatedUnicode==_L16("\x4e4d\x504f\x5251\x5453\x5655"));
|
sl@0
|
335 |
test(numberUnconverted==1);
|
sl@0
|
336 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
337 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
338 |
|
sl@0
|
339 |
// without BOM
|
sl@0
|
340 |
numberOfUnconvertibleCharacters=11;
|
sl@0
|
341 |
numberUnconverted=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, KForeignBufferOddWithoutBOM23BE.Right(numberOfUnconvertibleCharacters), state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
342 |
test(generatedUnicode==_L16("\x4e4d\x504f\x5251\x5453\x5655"));
|
sl@0
|
343 |
test(numberUnconverted==1);
|
sl@0
|
344 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
345 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
346 |
|
sl@0
|
347 |
|
sl@0
|
348 |
INFO_PRINTF1(_L("\nBigEndianConversionMultiplePassOddBOM - OK"));
|
sl@0
|
349 |
}
|
sl@0
|
350 |
/**
|
sl@0
|
351 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0557
|
sl@0
|
352 |
@SYMTestCaseDesc UCS2 to 8 bit Big Endian Conversion - Single pass test
|
sl@0
|
353 |
@SYMTestPriority Medium
|
sl@0
|
354 |
@SYMTestActions Tests a 16 bit UCS2 to 8 bit descriptor conversion.
|
sl@0
|
355 |
Byte Order Mark is present and is set to Big Endian.
|
sl@0
|
356 |
Output buffer is large enough to contain the complete input string
|
sl@0
|
357 |
on a single pass
|
sl@0
|
358 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
359 |
@SYMREQ REQ0000
|
sl@0
|
360 |
*/
|
sl@0
|
361 |
void CT_UCS2::UCS2BEConversionSinglePassBOM(CCnvCharacterSetConverter& aCharacterSetConverter)
|
sl@0
|
362 |
{
|
sl@0
|
363 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0557 "));
|
sl@0
|
364 |
TBuf8<KBufferLength40> generatedForeign;
|
sl@0
|
365 |
CCnvCharacterSetConverter::TArrayOfAscendingIndices indicesOfUnconvertibleCharacters;
|
sl@0
|
366 |
|
sl@0
|
367 |
// set the default endianness to Big Endian
|
sl@0
|
368 |
aCharacterSetConverter.SetDefaultEndiannessOfForeignCharacters(CCnvCharacterSetConverter::EBigEndian);
|
sl@0
|
369 |
|
sl@0
|
370 |
// test even number of foreign bytes
|
sl@0
|
371 |
aCharacterSetConverter.ConvertFromUnicode( generatedForeign,
|
sl@0
|
372 |
KUnicodeBufferEven14BE,
|
sl@0
|
373 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
374 |
|
sl@0
|
375 |
test(generatedForeign==_L8("\xfe\xff\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a"));
|
sl@0
|
376 |
INFO_PRINTF1(_L("\nUCS2BEConversionSinglePassEvenBOM - OK"));
|
sl@0
|
377 |
|
sl@0
|
378 |
// test odd number of foreign bytes
|
sl@0
|
379 |
aCharacterSetConverter.ConvertFromUnicode( generatedForeign,
|
sl@0
|
380 |
KUnicodeBufferOdd15BE,
|
sl@0
|
381 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
382 |
|
sl@0
|
383 |
test(generatedForeign==_L8("\xfe\xff\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c"));
|
sl@0
|
384 |
INFO_PRINTF1(_L("\nUCS2BEConversionSinglePassOddBOM - OK"));
|
sl@0
|
385 |
}
|
sl@0
|
386 |
/**
|
sl@0
|
387 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0558
|
sl@0
|
388 |
@SYMTestCaseDesc UCS2 to 8 bit Big Endian Conversion - Multiple pass test
|
sl@0
|
389 |
@SYMTestPriority Medium
|
sl@0
|
390 |
@SYMTestActions Tests a 16 bit UCS2 to 8 bit descriptor conversion.
|
sl@0
|
391 |
Byte Order Mark is present and is set to Big Endian.
|
sl@0
|
392 |
Output buffer is NOT large enough to contain the complete input string
|
sl@0
|
393 |
on a single pass
|
sl@0
|
394 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
395 |
@SYMREQ REQ0000
|
sl@0
|
396 |
*/
|
sl@0
|
397 |
void CT_UCS2::UCS2BEConversionMultiplePassBOM (CCnvCharacterSetConverter& aCharacterSetConverter)
|
sl@0
|
398 |
{
|
sl@0
|
399 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0558 "));
|
sl@0
|
400 |
TBuf8<KBufferLength6> generatedForeign;
|
sl@0
|
401 |
TBuf8<KBufferLength8> generatedForeign2;
|
sl@0
|
402 |
TInt result=0;
|
sl@0
|
403 |
CCnvCharacterSetConverter::TArrayOfAscendingIndices indicesOfUnconvertibleCharacters;
|
sl@0
|
404 |
|
sl@0
|
405 |
// set the default endianness to Big Endian
|
sl@0
|
406 |
aCharacterSetConverter.SetDefaultEndiannessOfForeignCharacters(CCnvCharacterSetConverter::EBigEndian);
|
sl@0
|
407 |
|
sl@0
|
408 |
// *** Test even number of bytes ***
|
sl@0
|
409 |
// test even number of foreign bytes - pass 1
|
sl@0
|
410 |
result = aCharacterSetConverter.ConvertFromUnicode( generatedForeign,
|
sl@0
|
411 |
KUnicodeBufferEven14BE,
|
sl@0
|
412 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
413 |
test(generatedForeign==_L8("\xfe\xff\x41\x42\x43\x44"));
|
sl@0
|
414 |
test(result==11);
|
sl@0
|
415 |
|
sl@0
|
416 |
// test even number of foreign bytes - pass 2
|
sl@0
|
417 |
result = aCharacterSetConverter.ConvertFromUnicode( generatedForeign,
|
sl@0
|
418 |
KUnicodeBufferEven14BE.Right(result),
|
sl@0
|
419 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
420 |
test(result==8);
|
sl@0
|
421 |
test(generatedForeign==_L8("\x45\x46\x47\x48\x49\x4A"));
|
sl@0
|
422 |
|
sl@0
|
423 |
// test even number of foreign bytes - pass 3
|
sl@0
|
424 |
result = aCharacterSetConverter.ConvertFromUnicode( generatedForeign,
|
sl@0
|
425 |
KUnicodeBufferEven14BE.Right(result),
|
sl@0
|
426 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
427 |
test(result==5);
|
sl@0
|
428 |
test(generatedForeign==_L8("\x4b\x4c\x4d\x4e\x4f\x50"));
|
sl@0
|
429 |
|
sl@0
|
430 |
|
sl@0
|
431 |
// test even number of foreign bytes - pass 4
|
sl@0
|
432 |
result = aCharacterSetConverter.ConvertFromUnicode( generatedForeign,
|
sl@0
|
433 |
KUnicodeBufferEven14BE.Right(result),
|
sl@0
|
434 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
435 |
test(result==2);
|
sl@0
|
436 |
test(generatedForeign==_L8("\x51\x52\x53\x54\x55\x56"));
|
sl@0
|
437 |
|
sl@0
|
438 |
// test even number of foreign bytes - pass 5
|
sl@0
|
439 |
result = aCharacterSetConverter.ConvertFromUnicode( generatedForeign2,
|
sl@0
|
440 |
KUnicodeBufferEven14BE.Right(result),
|
sl@0
|
441 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
442 |
test(generatedForeign2==_L8("\x57\x58\x59\x5a"));
|
sl@0
|
443 |
test(result==0);
|
sl@0
|
444 |
|
sl@0
|
445 |
INFO_PRINTF1(_L("\nUCS2LEConversionMultiplePassEvenBOM - OK"));
|
sl@0
|
446 |
|
sl@0
|
447 |
// *** Test odd numer of bytes ***
|
sl@0
|
448 |
result = aCharacterSetConverter.ConvertFromUnicode( generatedForeign,
|
sl@0
|
449 |
KUnicodeBufferOdd15BE,
|
sl@0
|
450 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
451 |
test(generatedForeign==_L8("\xfe\xff\x41\x42\x43\x44"));
|
sl@0
|
452 |
|
sl@0
|
453 |
// test even number of foreign bytes - pass 2
|
sl@0
|
454 |
result = aCharacterSetConverter.ConvertFromUnicode( generatedForeign,
|
sl@0
|
455 |
KUnicodeBufferOdd15BE.Right(result),
|
sl@0
|
456 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
457 |
test(generatedForeign==_L8("\x45\x46\x47\x48\x49\x4a"));
|
sl@0
|
458 |
|
sl@0
|
459 |
// test even number of foreign bytes - pass 3
|
sl@0
|
460 |
result = aCharacterSetConverter.ConvertFromUnicode( generatedForeign,
|
sl@0
|
461 |
KUnicodeBufferOdd15BE.Right(result),
|
sl@0
|
462 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
463 |
test(generatedForeign==_L8("\x4b\x4c\x4d\x4e\x4f\x50"));
|
sl@0
|
464 |
|
sl@0
|
465 |
// test even number of foreign bytes - pass 4
|
sl@0
|
466 |
result = aCharacterSetConverter.ConvertFromUnicode( generatedForeign,
|
sl@0
|
467 |
KUnicodeBufferOdd15BE.Right(result),
|
sl@0
|
468 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
469 |
test(generatedForeign==_L8("\x51\x52\x53\x54\x55\x56"));
|
sl@0
|
470 |
|
sl@0
|
471 |
|
sl@0
|
472 |
// test even number of foreign bytes - pass 5
|
sl@0
|
473 |
result = aCharacterSetConverter.ConvertFromUnicode( generatedForeign,
|
sl@0
|
474 |
KUnicodeBufferOdd15BE.Right(result),
|
sl@0
|
475 |
indicesOfUnconvertibleCharacters );
|
sl@0
|
476 |
test(generatedForeign==_L8("\x57\x58\x59\x5a\x5b\x5c"));
|
sl@0
|
477 |
test(result==0);
|
sl@0
|
478 |
|
sl@0
|
479 |
INFO_PRINTF1(_L("\nUCS2LEConversionMultiplePassOddBOM - OK"));
|
sl@0
|
480 |
}
|
sl@0
|
481 |
/**
|
sl@0
|
482 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0559
|
sl@0
|
483 |
@SYMTestCaseDesc Tests a 16 bit UCS2 to 8 bit & 16 bit UCS2 to 8 bit conversion with empty buffers.
|
sl@0
|
484 |
@SYMTestPriority Medium
|
sl@0
|
485 |
@SYMTestActions Attempt for conversion when input and output buffers are small
|
sl@0
|
486 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
487 |
@SYMREQ REQ0000
|
sl@0
|
488 |
*/
|
sl@0
|
489 |
void CT_UCS2::TooSmallBufferConversion (CCnvCharacterSetConverter& aCharacterSetConverter)
|
sl@0
|
490 |
{
|
sl@0
|
491 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0559 "));
|
sl@0
|
492 |
TBuf16<KBufferLength1> generatedUnicode1;
|
sl@0
|
493 |
TBuf8<KBufferLength1> generatedForeign1;
|
sl@0
|
494 |
|
sl@0
|
495 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
496 |
TInt numberOfUnconvertibleCharacters=0;
|
sl@0
|
497 |
TInt indexOfFirstByteOfFirstUnconvertibleCharacter=0;
|
sl@0
|
498 |
|
sl@0
|
499 |
CCnvCharacterSetConverter::TArrayOfAscendingIndices indicesOfUnconvertibleCharacters;
|
sl@0
|
500 |
|
sl@0
|
501 |
// set the default endianness to little Endian
|
sl@0
|
502 |
aCharacterSetConverter.SetDefaultEndiannessOfForeignCharacters(CCnvCharacterSetConverter::ELittleEndian);
|
sl@0
|
503 |
|
sl@0
|
504 |
// convert to UCS2 using an output buffer that is too small
|
sl@0
|
505 |
TInt result = aCharacterSetConverter.ConvertToUnicode(generatedUnicode1, KForeignBufferEven12LE, state, numberOfUnconvertibleCharacters, indexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
506 |
test(generatedUnicode1==_L16("\x4241"));
|
sl@0
|
507 |
test(result==8);
|
sl@0
|
508 |
test(numberOfUnconvertibleCharacters==0);
|
sl@0
|
509 |
test(indexOfFirstByteOfFirstUnconvertibleCharacter==-1);
|
sl@0
|
510 |
INFO_PRINTF1(_L("\n8bit->UCS2 output buffer size 1 - OK"));
|
sl@0
|
511 |
|
sl@0
|
512 |
INFO_PRINTF1(_L("\nConversionTooSmallBuffer - OK"));
|
sl@0
|
513 |
}
|
sl@0
|
514 |
/**
|
sl@0
|
515 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0560
|
sl@0
|
516 |
@SYMTestCaseDesc Conversion tests from UCS2 GUID to MIB
|
sl@0
|
517 |
@SYMTestPriority Medium
|
sl@0
|
518 |
@SYMTestActions Tests retreiving the MIB value from the UCS2 GUID
|
sl@0
|
519 |
Tests retreiving the UCS2 GUID from the MIB value
|
sl@0
|
520 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
521 |
@SYMREQ REQ0000
|
sl@0
|
522 |
*/
|
sl@0
|
523 |
void CT_UCS2::CharacterSetValueAndMIBTests(CCnvCharacterSetConverter& aCharacterSetConverter, RFs& aFileServerSession)
|
sl@0
|
524 |
{
|
sl@0
|
525 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0560 "));
|
sl@0
|
526 |
// check that the character set value of '1000' is converted to the UCS2 GUID (0x101ff492)
|
sl@0
|
527 |
test(aCharacterSetConverter.ConvertMibEnumOfCharacterSetToIdentifierL(KMibValue,aFileServerSession)==KCharacterSetIdentifierUcs2);
|
sl@0
|
528 |
INFO_PRINTF1(_L("\nMIB->Char Set GUID - OK"));
|
sl@0
|
529 |
|
sl@0
|
530 |
// check that the UCS2 GUID (0x101ff492) is converted to the character set value of '1000'
|
sl@0
|
531 |
test(aCharacterSetConverter.ConvertCharacterSetIdentifierToMibEnumL(KCharacterSetIdentifierUcs2,aFileServerSession)==KMibValue);
|
sl@0
|
532 |
INFO_PRINTF1(_L("\nChar Set GUID->MIB - OK"));
|
sl@0
|
533 |
}
|
sl@0
|
534 |
|
sl@0
|
535 |
|
sl@0
|
536 |
void CT_UCS2::DoE32MainL()
|
sl@0
|
537 |
{
|
sl@0
|
538 |
RFs fileServerSession;
|
sl@0
|
539 |
CleanupClosePushL(fileServerSession);
|
sl@0
|
540 |
User::LeaveIfError(fileServerSession.Connect());
|
sl@0
|
541 |
CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
|
sl@0
|
542 |
CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
|
sl@0
|
543 |
TInt i;
|
sl@0
|
544 |
for (i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
|
sl@0
|
545 |
{
|
sl@0
|
546 |
const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
|
sl@0
|
547 |
characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
|
sl@0
|
548 |
TPtrC charactersSetName(charactersSet.Name());
|
sl@0
|
549 |
if (charactersSet.NameIsFileName())
|
sl@0
|
550 |
{
|
sl@0
|
551 |
charactersSetName.Set(TParsePtrC(charactersSetName).Name());
|
sl@0
|
552 |
}
|
sl@0
|
553 |
INFO_PRINTF2(_L(" %S\n"), &charactersSetName);
|
sl@0
|
554 |
}
|
sl@0
|
555 |
|
sl@0
|
556 |
// test MIB to Character Set ID (and visa versa) conversion
|
sl@0
|
557 |
CharacterSetValueAndMIBTests(*characterSetConverter, fileServerSession);
|
sl@0
|
558 |
|
sl@0
|
559 |
// prepare for conversion
|
sl@0
|
560 |
INFO_PRINTF1(_L("\nTesting 8 bit -> UCS2 conversion"));
|
sl@0
|
561 |
TRAPD( error, characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierUcs2, *arrayOfCharacterSetsAvailable, fileServerSession));
|
sl@0
|
562 |
if ( error != KErrNone )
|
sl@0
|
563 |
{
|
sl@0
|
564 |
RDebug::Print(_L("PrepareToConvertToOrFromL failed code:%d\n"),error);
|
sl@0
|
565 |
RDebug::Print(_L("KCharacterSetIdentifierUcs2 is not available so tests failed\n"));
|
sl@0
|
566 |
User::LeaveIfError(error);
|
sl@0
|
567 |
}
|
sl@0
|
568 |
|
sl@0
|
569 |
|
sl@0
|
570 |
// *** 8 bit to UCS2 conversion ***
|
sl@0
|
571 |
INFO_PRINTF1(_L("\n8->UCS2 Little Endian Conversion - Single pass"));
|
sl@0
|
572 |
LEConversionSinglePassBOM(*characterSetConverter);
|
sl@0
|
573 |
|
sl@0
|
574 |
INFO_PRINTF1(_L("\n8->UCS2 Little Endian Conversion - Multiple pass"));
|
sl@0
|
575 |
LEConversionMultiplePassBOM(*characterSetConverter);
|
sl@0
|
576 |
|
sl@0
|
577 |
INFO_PRINTF1(_L("\n8->UCS2 Big Endian Conversion - Single pass"));
|
sl@0
|
578 |
BEConversionSinglePassBOM(*characterSetConverter);
|
sl@0
|
579 |
|
sl@0
|
580 |
INFO_PRINTF1(_L("\n8->UCS2 Big Endian Conversion - Multiple pass"));
|
sl@0
|
581 |
BEConversionMultiplePassBOM(*characterSetConverter);
|
sl@0
|
582 |
|
sl@0
|
583 |
|
sl@0
|
584 |
// *** UCS2 to 8 bit conversion ***
|
sl@0
|
585 |
INFO_PRINTF1(_L("\nUCS2->8 Big Endian Conversion - Single pass"));
|
sl@0
|
586 |
UCS2BEConversionSinglePassBOM(*characterSetConverter);
|
sl@0
|
587 |
|
sl@0
|
588 |
INFO_PRINTF1(_L("\nUCS2->8 Big Endian Conversion - Multiple pass"));
|
sl@0
|
589 |
UCS2BEConversionMultiplePassBOM(*characterSetConverter);
|
sl@0
|
590 |
|
sl@0
|
591 |
// *** attempted conversion when input/output buffers are too small
|
sl@0
|
592 |
INFO_PRINTF1(_L("\nTooSmallBufferConversion"));
|
sl@0
|
593 |
TooSmallBufferConversion(*characterSetConverter);
|
sl@0
|
594 |
|
sl@0
|
595 |
INFO_PRINTF1(_L("\n"));
|
sl@0
|
596 |
CleanupStack::PopAndDestroy(3);// arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession
|
sl@0
|
597 |
}
|
sl@0
|
598 |
|
sl@0
|
599 |
CT_UCS2::CT_UCS2()
|
sl@0
|
600 |
{
|
sl@0
|
601 |
SetTestStepName(KTestStep_T_UCS2);
|
sl@0
|
602 |
}
|
sl@0
|
603 |
|
sl@0
|
604 |
TVerdict CT_UCS2::doTestStepL()
|
sl@0
|
605 |
{
|
sl@0
|
606 |
SetTestStepResult(EFail);
|
sl@0
|
607 |
|
sl@0
|
608 |
__UHEAP_MARK;
|
sl@0
|
609 |
TRAPD(error1, DoE32MainL());
|
sl@0
|
610 |
__UHEAP_MARKEND;
|
sl@0
|
611 |
|
sl@0
|
612 |
if(error1 == KErrNone)
|
sl@0
|
613 |
{
|
sl@0
|
614 |
SetTestStepResult(EPass);
|
sl@0
|
615 |
}
|
sl@0
|
616 |
|
sl@0
|
617 |
return TestStepResult();
|
sl@0
|
618 |
}
|