|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "CEscapeUtilsTest.h" |
|
17 |
|
18 #include <e32base.h> |
|
19 |
|
20 #include "EscapeUtilsTestCommon.h" |
|
21 #include "EscapeUtilsTests.h" |
|
22 #include <tconvbase64.h> |
|
23 |
|
24 CEscapeUtilsTest* CEscapeUtilsTest::NewLC(CIpuTestHarness* aTestHarness) |
|
25 { |
|
26 CEscapeUtilsTest* self = new (ELeave) CEscapeUtilsTest(aTestHarness); |
|
27 CleanupStack::PushL(self); |
|
28 self->ConstructL(); |
|
29 return self; |
|
30 } |
|
31 |
|
32 CEscapeUtilsTest* CEscapeUtilsTest::NewL(CIpuTestHarness* aTestHarness) |
|
33 { |
|
34 CEscapeUtilsTest* self = CEscapeUtilsTest::NewLC(aTestHarness); |
|
35 CleanupStack::Pop(self); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CEscapeUtilsTest::CEscapeUtilsTest(CIpuTestHarness* aTestHarness) |
|
40 : iTestHarness(aTestHarness) |
|
41 { |
|
42 } |
|
43 |
|
44 void CEscapeUtilsTest::ConstructL() |
|
45 { |
|
46 } |
|
47 |
|
48 CEscapeUtilsTest::~CEscapeUtilsTest() |
|
49 { |
|
50 } |
|
51 |
|
52 void CEscapeUtilsTest::DoTestsL() |
|
53 { |
|
54 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded0, KEscapeEncoded0_auth, EscapeUtils::EEscapeAuth); |
|
55 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded0, KEscapeEncoded0_path, EscapeUtils::EEscapePath); |
|
56 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded0, KEscapeEncoded0_query, EscapeUtils::EEscapeQuery); |
|
57 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded0, KEscapeEncoded0_normal, EscapeUtils::EEscapeNormal); |
|
58 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded0, KEscapeEncoded0_url, EscapeUtils::EEscapeUrlEncoded); |
|
59 |
|
60 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded1, KEscapeEncoded1_auth, EscapeUtils::EEscapeAuth); |
|
61 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded1, KEscapeEncoded1_path, EscapeUtils::EEscapePath); |
|
62 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded1, KEscapeEncoded1_query, EscapeUtils::EEscapeQuery); |
|
63 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded1, KEscapeEncoded1_normal, EscapeUtils::EEscapeNormal); |
|
64 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded1, KEscapeEncoded1_url, EscapeUtils::EEscapeUrlEncoded); |
|
65 |
|
66 |
|
67 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded0_auth, KEscapeDecoded0); |
|
68 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded0_path, KEscapeDecoded0); |
|
69 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded0_query, KEscapeDecoded0); |
|
70 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded0_normal, KEscapeDecoded0); |
|
71 |
|
72 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded1_auth, KEscapeDecoded1); |
|
73 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded1_path, KEscapeDecoded1); |
|
74 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded1_query, KEscapeDecoded1); |
|
75 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded1_normal, KEscapeDecoded1); |
|
76 |
|
77 // Test cases for section 2.9.1.2 // |
|
78 |
|
79 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded2, KEscapeEncoded2_auth, EscapeUtils::EEscapeAuth); |
|
80 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded2, KEscapeEncoded2_path, EscapeUtils::EEscapePath); |
|
81 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded2, KEscapeEncoded2_query, EscapeUtils::EEscapeQuery); |
|
82 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded2, KEscapeEncoded2_normal, EscapeUtils::EEscapeNormal); |
|
83 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded2, KEscapeEncoded2_url, EscapeUtils::EEscapeUrlEncoded); |
|
84 |
|
85 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded3, KEscapeEncoded3_auth, EscapeUtils::EEscapeAuth); |
|
86 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded3, KEscapeEncoded3_path, EscapeUtils::EEscapePath); |
|
87 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded3, KEscapeEncoded3_query, EscapeUtils::EEscapeQuery); |
|
88 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded3, KEscapeEncoded3_normal, EscapeUtils::EEscapeNormal); |
|
89 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded3, KEscapeEncoded3_url, EscapeUtils::EEscapeUrlEncoded); |
|
90 |
|
91 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded4, KEscapeEncoded4_auth, EscapeUtils::EEscapeAuth); |
|
92 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded4, KEscapeEncoded4_path, EscapeUtils::EEscapePath); |
|
93 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded4, KEscapeEncoded4_query, EscapeUtils::EEscapeQuery); |
|
94 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded4, KEscapeEncoded4_normal, EscapeUtils::EEscapeNormal); |
|
95 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded4, KEscapeEncoded4_url, EscapeUtils::EEscapeUrlEncoded); |
|
96 |
|
97 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded5, KEscapeEncoded5_auth, EscapeUtils::EEscapeAuth); |
|
98 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded5, KEscapeEncoded5_path, EscapeUtils::EEscapePath); |
|
99 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded5, KEscapeEncoded5_query, EscapeUtils::EEscapeQuery); |
|
100 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded5, KEscapeEncoded5_normal, EscapeUtils::EEscapeNormal); |
|
101 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded5, KEscapeEncoded5_url, EscapeUtils::EEscapeUrlEncoded); |
|
102 |
|
103 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded6, KEscapeEncoded6_auth, EscapeUtils::EEscapeAuth); |
|
104 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded6, KEscapeEncoded6_path, EscapeUtils::EEscapePath); |
|
105 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded6, KEscapeEncoded6_query, EscapeUtils::EEscapeQuery); |
|
106 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded6, KEscapeEncoded6_normal, EscapeUtils::EEscapeNormal); |
|
107 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded6, KEscapeEncoded6_url, EscapeUtils::EEscapeUrlEncoded); |
|
108 |
|
109 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded7, KEscapeEncoded7_auth, EscapeUtils::EEscapeAuth); |
|
110 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded7, KEscapeEncoded7_path, EscapeUtils::EEscapePath); |
|
111 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded7, KEscapeEncoded7_query, EscapeUtils::EEscapeQuery); |
|
112 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded7, KEscapeEncoded7_normal, EscapeUtils::EEscapeNormal); |
|
113 TestEscapeUtilsEscapeEncodeL(KEscapeDecoded7, KEscapeEncoded7_url, EscapeUtils::EEscapeUrlEncoded); |
|
114 |
|
115 |
|
116 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded2_auth, KEscapeDecoded2); |
|
117 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded2_path, KEscapeDecoded2); |
|
118 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded2_query, KEscapeDecoded2); |
|
119 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded2_normal, KEscapeDecoded2); |
|
120 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded2_url, KEscapeDecoded2); |
|
121 |
|
122 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded3_auth, KEscapeDecoded3); |
|
123 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded3_path, KEscapeDecoded3); |
|
124 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded3_query, KEscapeDecoded3); |
|
125 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded3_normal, KEscapeDecoded3); |
|
126 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded3_url, KEscapeDecoded3); |
|
127 |
|
128 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded4_auth, KEscapeDecoded4); |
|
129 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded4_path, KEscapeDecoded4); |
|
130 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded4_query, KEscapeDecoded4); |
|
131 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded4_normal, KEscapeDecoded4); |
|
132 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded4_url, KEscapeDecoded4); |
|
133 |
|
134 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded5_auth, KEscapeDecoded5); |
|
135 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded5_path, KEscapeDecoded5); |
|
136 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded5_query, KEscapeDecoded5); |
|
137 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded5_normal, KEscapeDecoded5); |
|
138 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded5_url, KEscapeDecoded5); |
|
139 |
|
140 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded6_auth, KEscapeDecoded6); |
|
141 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded6_path, KEscapeDecoded6); |
|
142 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded6_query, KEscapeDecoded6); |
|
143 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded6_normal, KEscapeDecoded6); |
|
144 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded6_url, KEscapeDecoded6); |
|
145 |
|
146 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded7_auth, KEscapeDecoded7); |
|
147 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded7_path, KEscapeDecoded7); |
|
148 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded7_query, KEscapeDecoded7); |
|
149 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded7_normal, KEscapeDecoded7); |
|
150 TestEscapeUtilsEscapeDecodeL(KEscapeEncoded7_url, KEscapeDecoded7); |
|
151 |
|
152 // |
|
153 |
|
154 TestEscapeUtilsUnicodeUtf8ConversionsL(KUnicode_0, KUtf8_0); |
|
155 |
|
156 TestEscapeUtilsIsExcludedCharL(KExcludedChar0, KExcludedChar0_excluded); |
|
157 TestEscapeUtilsIsExcludedCharL(KExcludedChar1, KExcludedChar1_excluded); |
|
158 TestEscapeUtilsIsExcludedCharL(KExcludedChar2, KExcludedChar2_excluded); |
|
159 TestEscapeUtilsIsExcludedCharL(KExcludedChar3, KExcludedChar3_excluded); |
|
160 TestEscapeUtilsIsExcludedCharL(KExcludedChar4, KExcludedChar4_excluded); |
|
161 |
|
162 TestEscapeUtilsIsEscapeTripleL(KEscapeTriple0(), KEscapeTriple0_valid, KEscapeTriple0_value); |
|
163 TestEscapeUtilsIsEscapeTripleL(KEscapeTriple1(), KEscapeTriple1_valid, KEscapeTriple1_value); |
|
164 TestEscapeUtilsIsEscapeTripleL(KEscapeTriple2(), KEscapeTriple2_valid, KEscapeTriple2_value); |
|
165 |
|
166 //TConvBase64 Test |
|
167 TestEscapeUtilsBase64ConversionL(KEscapeDecoded2); |
|
168 } |
|
169 |
|
170 void CEscapeUtilsTest::TestEscapeUtilsEscapeEncodeL(const TDesC& aData, const TDesC& aExpected, EscapeUtils::TEscapeMode aEscapeMode) |
|
171 { |
|
172 iTestHarness->StartTestL(_L("Test EscapeUtils EscapeEncode (16-bit)")); |
|
173 |
|
174 TInt error = DoTestEscapeUtilsEscapeEncode<HBufC16>(aData, aExpected, aEscapeMode); |
|
175 |
|
176 iTestHarness->EndTest(error); |
|
177 |
|
178 // Make 8-bit copy |
|
179 HBufC8* dataBuf = HBufC8::NewLC(aData.Length()); |
|
180 TPtr8 data8Bit = dataBuf->Des(); |
|
181 data8Bit.Copy(aData); |
|
182 |
|
183 HBufC8* expectedBuf = HBufC8::NewLC(aExpected.Length()); |
|
184 TPtr8 expected8Bit = expectedBuf->Des(); |
|
185 expected8Bit.Copy(aExpected); |
|
186 |
|
187 iTestHarness->StartTestL(_L("Test EscapeUtils EscapeEncode (8-bit)")); |
|
188 |
|
189 error = DoTestEscapeUtilsEscapeEncode<HBufC8>(data8Bit, expected8Bit, aEscapeMode); |
|
190 |
|
191 iTestHarness->EndTest(error); |
|
192 |
|
193 CleanupStack::PopAndDestroy(2, dataBuf); // dataBuf, expectedBuf |
|
194 } |
|
195 |
|
196 void CEscapeUtilsTest::TestEscapeUtilsEscapeDecodeL(const TDesC& aData, const TDesC& aExpected) |
|
197 { |
|
198 iTestHarness->StartTestL(_L("Test EscapeUtils EscapeDecode (16-bit)")); |
|
199 |
|
200 TInt error = DoTestEscapeUtilsEscapeDecode<HBufC16>(aData, aExpected); |
|
201 |
|
202 iTestHarness->EndTest(error); |
|
203 |
|
204 // Make 8-bit copy |
|
205 HBufC8* dataBuf = HBufC8::NewLC(aData.Length()); |
|
206 TPtr8 data8Bit = dataBuf->Des(); |
|
207 data8Bit.Copy(aData); |
|
208 |
|
209 HBufC8* expectedBuf = HBufC8::NewLC(aExpected.Length()); |
|
210 TPtr8 expected8Bit = expectedBuf->Des(); |
|
211 expected8Bit.Copy(aExpected); |
|
212 |
|
213 iTestHarness->StartTestL(_L("Test EscapeUtils EscapeDecode (8-bit)")); |
|
214 |
|
215 error = DoTestEscapeUtilsEscapeDecode<HBufC8>(data8Bit, expected8Bit); |
|
216 |
|
217 iTestHarness->EndTest(error); |
|
218 |
|
219 CleanupStack::PopAndDestroy(2, dataBuf); // dataBuf, expectedBuf |
|
220 } |
|
221 |
|
222 void CEscapeUtilsTest::TestEscapeUtilsUnicodeUtf8ConversionsL(const TDesC& aUnicode, const TDesC& aUtf8) |
|
223 { |
|
224 // Make 8-bit copy of utf8 |
|
225 HBufC8* utf8Buf = HBufC8::NewLC(aUtf8.Length()); |
|
226 utf8Buf->Des().Copy(aUtf8); |
|
227 |
|
228 // Escape decode |
|
229 HBufC8* unescapedUtf8Buf = EscapeUtils::EscapeDecodeL(*utf8Buf); |
|
230 CleanupStack::PushL(unescapedUtf8Buf); |
|
231 TPtr8 unescapedUtf8 = unescapedUtf8Buf->Des(); |
|
232 |
|
233 iTestHarness->StartTestL(_L("Test EscapeUtils ConvertFromUnicodeToUtf8")); |
|
234 |
|
235 HBufC8* convertedUtf8 = NULL; |
|
236 TRAPD(error, convertedUtf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aUnicode)); |
|
237 if( error == KErrNone ) |
|
238 { |
|
239 // Check is expected |
|
240 if( convertedUtf8->Compare(unescapedUtf8) != 0 ) |
|
241 { |
|
242 error = KErrNotFound; |
|
243 } |
|
244 delete convertedUtf8; |
|
245 } |
|
246 iTestHarness->EndTest(error); |
|
247 |
|
248 iTestHarness->StartTestL(_L("Test EscapeUtils ConvertToUnicodeFromUtf8")); |
|
249 |
|
250 HBufC16* convertedUnicode = NULL; |
|
251 TRAP(error, convertedUnicode = EscapeUtils::ConvertToUnicodeFromUtf8L(unescapedUtf8)); |
|
252 if( error == KErrNone ) |
|
253 { |
|
254 // Check is expected |
|
255 if( convertedUnicode->Compare(aUnicode) != 0 ) |
|
256 { |
|
257 error = KErrNotFound; |
|
258 } |
|
259 delete convertedUnicode; |
|
260 } |
|
261 iTestHarness->EndTest(error); |
|
262 |
|
263 CleanupStack::PopAndDestroy(2, utf8Buf); // utf8Buf, unescapedUtf8Buf |
|
264 } |
|
265 |
|
266 void CEscapeUtilsTest::TestEscapeUtilsIsExcludedCharL(TChar aChar, TBool aIsExcluded) |
|
267 { |
|
268 iTestHarness->StartTestL(_L("Test EscapeUtils IsExcludedChar")); |
|
269 |
|
270 TBool excluded = EscapeUtils::IsExcludedChar(aChar); |
|
271 |
|
272 TInt error = KErrNone; |
|
273 if( (!excluded && aIsExcluded) | (excluded && !aIsExcluded) ) |
|
274 { |
|
275 error = KErrNotFound; |
|
276 } |
|
277 iTestHarness->EndTest(error); |
|
278 } |
|
279 |
|
280 void CEscapeUtilsTest::TestEscapeUtilsIsEscapeTripleL(const TDesC& aData, TBool aIsTriple, TInt aValue) |
|
281 { |
|
282 iTestHarness->StartTestL(_L("Test EscapeUtils IsEscapeTriple (16-Bit)")); |
|
283 |
|
284 TInt error = DoTestEscapeUtilsIsEscapeTriple(aData, aIsTriple, aValue); |
|
285 |
|
286 iTestHarness->EndTest(error); |
|
287 |
|
288 // Make 8-bit copy |
|
289 HBufC8* dataBuf = HBufC8::NewLC(aData.Length()); |
|
290 TPtr8 data8Bit = dataBuf->Des(); |
|
291 data8Bit.Copy(aData); |
|
292 |
|
293 iTestHarness->StartTestL(_L("Test EscapeUtils IsEscapeTriple (8-Bit)")); |
|
294 |
|
295 error = DoTestEscapeUtilsIsEscapeTriple(data8Bit, aIsTriple, aValue); |
|
296 |
|
297 iTestHarness->EndTest(error); |
|
298 |
|
299 CleanupStack::PopAndDestroy(dataBuf); // dataBuf |
|
300 } |
|
301 |
|
302 void CEscapeUtilsTest::TestEscapeUtilsBase64ConversionL(const TDesC& aData) |
|
303 { |
|
304 iTestHarness->StartTestL(_L("Test EscapeUtils Base64 Conversion Check")); |
|
305 |
|
306 TInt error = KErrNotFound; |
|
307 HBufC8* dataBuf = HBufC8::NewMaxLC (aData.Length()); |
|
308 TPtr8 dataPtr(dataBuf->Des()); |
|
309 |
|
310 HBufC8* encodedBuf = HBufC8::NewMaxLC(aData.Length() * 2); |
|
311 TPtr8 encodedPtr(encodedBuf->Des()); |
|
312 |
|
313 TBase64 codec; |
|
314 codec.Encode(dataPtr, encodedPtr); |
|
315 |
|
316 HBufC8* decodedBuf = HBufC8::NewMaxLC(aData.Length()); |
|
317 TPtr8 decodedPtr(decodedBuf->Des()); |
|
318 |
|
319 codec.Decode(encodedPtr, decodedPtr); |
|
320 if(decodedPtr.Compare(dataPtr) == 0) |
|
321 { |
|
322 error = KErrNone; |
|
323 } |
|
324 iTestHarness->EndTest(error); |
|
325 |
|
326 CleanupStack::PopAndDestroy(decodedBuf); // decodedBuf |
|
327 CleanupStack::PopAndDestroy(encodedBuf); // encodedBuf |
|
328 CleanupStack::PopAndDestroy(dataBuf); // dataBuf |
|
329 } |
|
330 |
|
331 // |
|
332 // |
|
333 // Implementation of LOCAL functions |
|
334 // |
|
335 // |
|
336 |
|
337 template<class HBufCType, class TDesCType> |
|
338 LOCAL_C TInt DoTestEscapeUtilsEscapeEncode(const TDesCType& aData, const TDesCType& aExpected, EscapeUtils::TEscapeMode aEscapeMode) |
|
339 { |
|
340 // Do escaping |
|
341 HBufCType* escaped = NULL; |
|
342 TRAPD(error, escaped = EscapeUtils::EscapeEncodeL(aData, aEscapeMode)); |
|
343 if( error != KErrNone ) |
|
344 { |
|
345 return KErrNotFound; |
|
346 } |
|
347 // Check with expected |
|
348 if( escaped->Compare(aExpected) != 0 ) |
|
349 { |
|
350 delete escaped; |
|
351 return KErrNotFound; |
|
352 } |
|
353 delete escaped; |
|
354 return KErrNone; |
|
355 } |
|
356 |
|
357 template<class HBufCType, class TDesCType> |
|
358 LOCAL_C TInt DoTestEscapeUtilsEscapeDecode(const TDesCType& aData, const TDesCType& aExpected) |
|
359 { |
|
360 // Do unescaping |
|
361 HBufCType* unescaped = NULL; |
|
362 TRAPD(error, unescaped = EscapeUtils::EscapeDecodeL(aData)); |
|
363 if( error != KErrNone ) |
|
364 { |
|
365 return KErrNotFound; |
|
366 } |
|
367 // Check with expected |
|
368 if( unescaped->Compare(aExpected) != 0 ) |
|
369 { |
|
370 delete unescaped; |
|
371 return KErrNotFound; |
|
372 } |
|
373 delete unescaped; |
|
374 return KErrNone; |
|
375 } |
|
376 |
|
377 template<class TDesCType> |
|
378 LOCAL_C TInt DoTestEscapeUtilsIsEscapeTriple(const TDesCType& aData, TBool aIsTriple, TInt aValue) |
|
379 { |
|
380 // Check for the triple |
|
381 TInt value; |
|
382 TBool triple = EscapeUtils::IsEscapeTriple(aData, value); |
|
383 if( (!triple && aIsTriple) | (triple && !aIsTriple) ) |
|
384 { |
|
385 return KErrNotFound; |
|
386 } |
|
387 if( triple && value != aValue ) |
|
388 { |
|
389 return KErrNotFound; |
|
390 } |
|
391 return KErrNone; |
|
392 } |