sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 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 <utf.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
23 |
|
sl@0
|
24 |
#include "t_simple7.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
#define test(cond) \
|
sl@0
|
27 |
TEST((cond)); \
|
sl@0
|
28 |
if (!(cond)) \
|
sl@0
|
29 |
{ \
|
sl@0
|
30 |
ERR_PRINTF1(_L("ERROR: Test Failed")); \
|
sl@0
|
31 |
User::Leave(1); \
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
/**
|
sl@0
|
35 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0562
|
sl@0
|
36 |
@SYMTestCaseDesc Conversion tests from Unicode to UTF-7 character set
|
sl@0
|
37 |
@SYMTestPriority Medium
|
sl@0
|
38 |
@SYMTestActions Tests for CnvUtfConverter::ConvertFromUnicodeToUtf7() function
|
sl@0
|
39 |
Tests for CnvUtfConverter::ConvertToUnicodeFromUtf7() function
|
sl@0
|
40 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
41 |
@SYMREQ REQ0000
|
sl@0
|
42 |
*/
|
sl@0
|
43 |
void CT_SIMPLE7::TestSIMPLE7()
|
sl@0
|
44 |
{
|
sl@0
|
45 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0562 Testing simple UTF-7 round trips "));
|
sl@0
|
46 |
TBuf16<256> originalUnicode;
|
sl@0
|
47 |
TBuf8<256> generatedUtf7;
|
sl@0
|
48 |
TBuf16<256> generatedUnicode;
|
sl@0
|
49 |
TInt state=CnvUtfConverter::KStateDefault;
|
sl@0
|
50 |
//
|
sl@0
|
51 |
INFO_PRINTF1(_L("Empty descriptor"));
|
sl@0
|
52 |
originalUnicode=_L16("");
|
sl@0
|
53 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, ETrue)==0);
|
sl@0
|
54 |
test(generatedUtf7==_L8(""));
|
sl@0
|
55 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
56 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
57 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
58 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, EFalse)==0);
|
sl@0
|
59 |
test(generatedUtf7==_L8(""));
|
sl@0
|
60 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
61 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
62 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
63 |
INFO_PRINTF1(_L("English \"Hello!\""));
|
sl@0
|
64 |
originalUnicode=_L16("Hello!");
|
sl@0
|
65 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, ETrue)==0);
|
sl@0
|
66 |
test(generatedUtf7==_L8("Hello+ACE-"));
|
sl@0
|
67 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
68 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
69 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
70 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, EFalse)==0);
|
sl@0
|
71 |
test(generatedUtf7==_L8("Hello!"));
|
sl@0
|
72 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
73 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
74 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
75 |
INFO_PRINTF1(_L("Russian \"Hello!\""));
|
sl@0
|
76 |
originalUnicode.Format(_L16("%c%c%c%c%c%c%c%c%c%c%c%c!"), 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443, 0x0439, 0x0442, 0x0435);
|
sl@0
|
77 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, ETrue)==0);
|
sl@0
|
78 |
test(generatedUtf7==_L8("+BBcENARABDAEMgRBBEIEMgRDBDkEQgQ1ACE-"));
|
sl@0
|
79 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
80 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
81 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
82 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, EFalse)==0);
|
sl@0
|
83 |
test(generatedUtf7==_L8("+BBcENARABDAEMgRBBEIEMgRDBDkEQgQ1-!"));
|
sl@0
|
84 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
85 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
86 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
87 |
INFO_PRINTF1(_L("Greek \"Hello!\""));
|
sl@0
|
88 |
originalUnicode.Format(_L16("%c%c%c%c%c!"), 0x0393, 0x03b1, 0x03c3, 0x03bf, 0x03c5);
|
sl@0
|
89 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, ETrue)==0);
|
sl@0
|
90 |
test(generatedUtf7==_L8("+A5MDsQPDA78DxQAh-"));
|
sl@0
|
91 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
92 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
93 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
94 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, EFalse)==0);
|
sl@0
|
95 |
test(generatedUtf7==_L8("+A5MDsQPDA78DxQ-!"));
|
sl@0
|
96 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
97 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
98 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
99 |
INFO_PRINTF1(_L("Chinese \"Hello!\""));
|
sl@0
|
100 |
originalUnicode.Format(_L16("%c%c!"), 0x4f60, 0x597d);
|
sl@0
|
101 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, ETrue)==0);
|
sl@0
|
102 |
test(generatedUtf7==_L8("+T2BZfQAh-"));
|
sl@0
|
103 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
104 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
105 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
106 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, EFalse)==0);
|
sl@0
|
107 |
test(generatedUtf7==_L8("+T2BZfQ-!"));
|
sl@0
|
108 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
109 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
110 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
111 |
INFO_PRINTF1(_L("Japanese \"Hello!\""));
|
sl@0
|
112 |
originalUnicode.Format(_L16("%c%c%c!"), 0x4eca, 0x65e5, 0x306f);
|
sl@0
|
113 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, ETrue)==0);
|
sl@0
|
114 |
test(generatedUtf7==_L8("+Tspl5TBvACE-"));
|
sl@0
|
115 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
116 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
117 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
118 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, EFalse)==0);
|
sl@0
|
119 |
test(generatedUtf7==_L8("+Tspl5TBv-!"));
|
sl@0
|
120 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
121 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
122 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
123 |
INFO_PRINTF1(_L("Trailing \"-\" character"));
|
sl@0
|
124 |
originalUnicode=_L16(":-");
|
sl@0
|
125 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, ETrue)==0);
|
sl@0
|
126 |
test(generatedUtf7==_L8(":-"));
|
sl@0
|
127 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
128 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
129 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
130 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, EFalse)==0);
|
sl@0
|
131 |
test(generatedUtf7==_L8(":-"));
|
sl@0
|
132 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
133 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
134 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
135 |
originalUnicode=_L16("=-");
|
sl@0
|
136 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, ETrue)==0);
|
sl@0
|
137 |
test(generatedUtf7==_L8("+AD0--"));
|
sl@0
|
138 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
139 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
140 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
141 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, EFalse)==0);
|
sl@0
|
142 |
test(generatedUtf7==_L8("=-"));
|
sl@0
|
143 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
144 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
145 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
146 |
originalUnicode.Format(_L16("%c-"), 0x1e77);
|
sl@0
|
147 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, ETrue)==0);
|
sl@0
|
148 |
test(generatedUtf7==_L8("+Hnc--"));
|
sl@0
|
149 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
150 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
151 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
152 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, EFalse)==0);
|
sl@0
|
153 |
test(generatedUtf7==_L8("+Hnc--"));
|
sl@0
|
154 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
155 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
156 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
157 |
INFO_PRINTF1(_L("Interspersed \"+\" characters"));
|
sl@0
|
158 |
originalUnicode.Format(_L16("+%c+&+a+"), 0x52ff);
|
sl@0
|
159 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, ETrue)==0);
|
sl@0
|
160 |
test(generatedUtf7==_L8("+-+Uv8-+-+ACY-+-a+-"));
|
sl@0
|
161 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
162 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
163 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
164 |
test(CnvUtfConverter::ConvertFromUnicodeToUtf7(generatedUtf7, originalUnicode, EFalse)==0);
|
sl@0
|
165 |
test(generatedUtf7==_L8("+-+Uv8-+-&+-a+-"));
|
sl@0
|
166 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
167 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
168 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
169 |
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
CT_SIMPLE7::CT_SIMPLE7()
|
sl@0
|
173 |
{
|
sl@0
|
174 |
SetTestStepName(KTestStep_T_SIMPLE7);
|
sl@0
|
175 |
}
|
sl@0
|
176 |
|
sl@0
|
177 |
TVerdict CT_SIMPLE7::doTestStepL()
|
sl@0
|
178 |
{
|
sl@0
|
179 |
SetTestStepResult(EFail);
|
sl@0
|
180 |
|
sl@0
|
181 |
__UHEAP_MARK;
|
sl@0
|
182 |
|
sl@0
|
183 |
TRAPD(error1, TestSIMPLE7());
|
sl@0
|
184 |
|
sl@0
|
185 |
|
sl@0
|
186 |
__UHEAP_MARKEND;
|
sl@0
|
187 |
|
sl@0
|
188 |
if(error1 == KErrNone)
|
sl@0
|
189 |
{
|
sl@0
|
190 |
SetTestStepResult(EPass);
|
sl@0
|
191 |
}
|
sl@0
|
192 |
|
sl@0
|
193 |
return TestStepResult();
|
sl@0
|
194 |
}
|