author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 256 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1995-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 the License "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 |
// e32test\buffer\t_des.cpp |
|
15 |
// Overview: |
|
16 |
// Test methods of the TDes template class. |
|
17 |
// API Information: |
|
18 |
// TDes |
|
19 |
// Details: |
|
20 |
// - Test assigning TPtrs in various ways and confirm results are as expected. |
|
21 |
// - Test locating in reverse on an empty TPtr, verify it returns KErrNoFound. |
|
22 |
// - For TBuf, TBuf8 and TBuf16 objects: |
|
23 |
// - Construct a default TBuf object and verify Length and MaxLength values are |
|
24 |
// as expected. |
|
25 |
// - Construct a TBuf object with length and verify Length and MaxLength values |
|
26 |
// are as expected. |
|
27 |
// - Construct a TBuf object over a string, verify Length and MaxLength values |
|
28 |
// are as expected. Verify the string data is correct. |
|
29 |
// - Construct a TBuf object over a descriptor, verify Length and MaxLength values |
|
30 |
// are as expected. Verify the data is correct. |
|
31 |
// - Construct a TBuf object over a buffer, verify Length and MaxLength values |
|
32 |
// are as expected. Verify the data is correct. |
|
33 |
// - Construct a TBuf object and assign a string to it, verify Length and MaxLength |
|
34 |
// values are as expected. Verify the data is correct. |
|
35 |
// - Construct a TBuf object and assign a descriptor to it, verify Length and MaxLength |
|
36 |
// values are as expected. Verify the data is correct. |
|
37 |
// - Construct a TBuf object and assign a buffer to it, verify Length and MaxLength |
|
38 |
// values are as expected. Verify the data is correct. |
|
39 |
// - Check the available user heap space and check for memory leaks by comparing it to |
|
40 |
// the initial value. |
|
41 |
// - For TPtrC, TPtrC8 and TPtrC16 objects: |
|
42 |
// - Verify the invariant for a null pointer descriptor |
|
43 |
// - Construct a TPtrC object over a constant string, verify Length and string data |
|
44 |
// are correct. |
|
45 |
// - Construct a TPtrC object over a constant descriptor, verify Length and data are |
|
46 |
// correct. |
|
47 |
// - Construct a TPtrC object over a constant buffer with length, verify Length and |
|
48 |
// data are correct. |
|
49 |
// - Check the available user heap space and check for memory leaks by comparing it to |
|
50 |
// the initial value. |
|
51 |
// - For TPtr, TPtr8 and TPtr16 objects: |
|
52 |
// - Verify the invariant for a null pointer descriptor |
|
53 |
// - Construct a TPtr object over a buffer with length and maxlength, verify Length, |
|
54 |
// MaxLength and data are correct. |
|
55 |
// - Construct a TPtr object over a buffer with maxlength, verify Length, MaxLength |
|
56 |
// and Ptr are correct. |
|
57 |
// - Construct a TPtr object and assign a string to it. Verify Length, MaxLength and |
|
58 |
// the string data are correct. |
|
59 |
// - Construct a TPtr object and assign a buffer to it. Verify Length, MaxLength and |
|
60 |
// the data are correct. |
|
61 |
// - Construct a TPtr object and assign a descriptor to it. Verify Length, MaxLength |
|
62 |
// and the data are correct. |
|
63 |
// - Check the available user heap space and check for memory leaks by comparing it to |
|
64 |
// the initial value. |
|
65 |
// - Verify the TPtr copy constructor by setting and checking a text string. |
|
66 |
// - For TBufC, TBufC8 and TBufC16 objects: |
|
67 |
// - Construct a default TBufC object. Verify default Length is as expected. |
|
68 |
// - Construct a TBufC object over a string, verify Length and data are correct. |
|
69 |
// - Construct a TBufC object over a TBufC, verify Length and data are correct. |
|
70 |
// - Construct a TBufC object and assign a string to it, verify Length and data |
|
71 |
// are correct. |
|
72 |
// - Construct a TBufC object and assign a descriptor to it, verify Length and data |
|
73 |
// are correct. |
|
74 |
// - Construct a TBufC object and assign a TBufC to it, verify Length and data |
|
75 |
// are correct. |
|
76 |
// - Check the available user heap space and check for memory leaks by comparing it to |
|
77 |
// the initial value. |
|
78 |
// - For HBufC, HBufC8 and HBufC16 objects: |
|
79 |
// - Create a new descriptor using the New() method, verify non-NULL return value. |
|
80 |
// - Construct a HBufC object and assign a string to it, verify Length and data |
|
81 |
// are correct. |
|
82 |
// - Construct a HBufC object and assign a descriptor to it, verify Length and data |
|
83 |
// are correct. |
|
84 |
// - Construct a HBufC object and assign a HBufC to it, verify Length and data |
|
85 |
// are correct. |
|
86 |
// - Construct a HBufC object and call ReAlloc method, verify Length and data are |
|
87 |
// correct. |
|
88 |
// - Check the available user heap space and check for memory leaks by comparing it to |
|
89 |
// the initial value. |
|
90 |
// - Test ASCII destination with Unicode source. Verify string results are as expected. |
|
91 |
// - For TLitC, TLitC8 and TLitC16 objects: |
|
92 |
// - Verify member operators. |
|
93 |
// - Assign and validate literal values |
|
94 |
// - For TBuf, TBuf8 and TBuf16 objects, test TDes derived objects that return TPtrs. |
|
95 |
// - Extract and verify the left portion of the descriptor (LeftTPtr). |
|
96 |
// - Extract and verify the right portion of the descriptor (RightTPtr). |
|
97 |
// - Extract and verify the middle portion of the descriptor (MidTPtr). |
|
98 |
// - For TPtr, TPtr8 and TPtr16 objects, test TDes derived objects that return TPtrs. |
|
99 |
// - Extract and verify the left portion of the descriptor (LeftTPtr). |
|
100 |
// - Extract and verify the right portion of the descriptor (RightTPtr). |
|
101 |
// - Extract and verify the middle portion of the descriptor (MidTPtr). |
|
102 |
// Platforms/Drives/Compatibility: |
|
103 |
// All |
|
104 |
// Assumptions/Requirement/Pre-requisites: |
|
105 |
// Failures and causes: |
|
106 |
// Base Port information: |
|
107 |
// |
|
108 |
// |
|
109 |
||
110 |
#include <e32test.h> |
|
111 |
||
112 |
LOCAL_D RTest test(_L("T_DES")); |
|
113 |
||
114 |
template<class T,class S, class L, class R> |
|
115 |
class TestTDes |
|
116 |
{ |
|
117 |
public: |
|
118 |
TestTDes(); // Test class constructor. |
|
119 |
void Test1(); |
|
120 |
void Test2(); |
|
121 |
void Test3(); |
|
122 |
void Test4(); |
|
123 |
void Test5(); |
|
124 |
void Test6(); |
|
125 |
void Test7(); |
|
126 |
void Test8(); |
|
127 |
void Test9(); |
|
128 |
void Test10(); |
|
129 |
void Test11(); |
|
130 |
void Test12(); |
|
131 |
void Test13(); |
|
132 |
void Test14(); |
|
133 |
void Test15(); |
|
134 |
void Test16(); |
|
135 |
void Test17(); |
|
136 |
void Test18(); |
|
137 |
void TestA(); |
|
138 |
void TestB(); |
|
139 |
void TestC(); |
|
140 |
void TestD(); |
|
141 |
void TestE(); |
|
142 |
void TestF(); |
|
143 |
void TestG(); |
|
144 |
void TestH(); |
|
145 |
void TestI(); |
|
146 |
void TestJ(); |
|
147 |
void TestK(); |
|
148 |
void TestL(); |
|
149 |
void TestM(); |
|
150 |
void TestN(); |
|
151 |
void TestO(); |
|
152 |
void TestP(); |
|
153 |
void test_TPtrC(); // Test TPtrC classes |
|
154 |
void test_TPtr(); // Test TPtr classes |
|
155 |
void test_TBuf(); // Test TBuf classes |
|
156 |
void test_TBufC(); // Test TBufC classes |
|
157 |
void test_HBufC(); // Test HBufC classes |
|
158 |
void test_TBufReturningModifiable(); |
|
159 |
void test_TPtrReturningModifiable(); |
|
160 |
void test_TDesReturningModifiable(const T& a, R& b); |
|
161 |
void testHeapSpace(TInt); |
|
162 |
}; |
|
163 |
||
164 |
template <class T, class S, class L, class R> |
|
165 |
GLDEF_C TestTDes<T,S,L,R>::TestTDes() |
|
166 |
// |
|
167 |
// Constructor |
|
168 |
// |
|
169 |
{} |
|
170 |
||
171 |
template <class T,class S,class L,class R> |
|
172 |
GLDEF_C void TestTDes<T,S,L,R>::testHeapSpace(TInt startAvail) |
|
173 |
// |
|
174 |
// Test no memory leakage has occured |
|
175 |
// |
|
176 |
{ |
|
177 |
||
178 |
test.Next(_L("Testing for memory leaks")); |
|
179 |
TInt endAvail,temp; |
|
180 |
endAvail=User::Available(temp); |
|
181 |
test(endAvail==startAvail); |
|
182 |
} |
|
183 |
||
184 |
template <class T, class S, class L, class R> |
|
185 |
GLDEF_C void TestTDes<T,S,L,R>::Test1() |
|
186 |
// |
|
187 |
// Constructs a view over a constant string |
|
188 |
// |
|
189 |
{ |
|
190 |
||
191 |
T a(_TL("ABc")); |
|
192 |
a.__DbgTestInvariant(); |
|
193 |
test(a.Length()==3); |
|
194 |
test(*a.Ptr()=='A'); |
|
195 |
test(*(a.Ptr()+1)=='B'); |
|
196 |
test(*(a.Ptr()+2)=='c'); |
|
197 |
} |
|
198 |
||
199 |
template<class T, class S, class L, class R> |
|
200 |
GLDEF_C void TestTDes<T,S,L,R>::Test2() |
|
201 |
// |
|
202 |
// Constructs a view over a descriptor |
|
203 |
// |
|
204 |
{ |
|
205 |
||
206 |
T aDes(_TL("ABc")); |
|
207 |
aDes.__DbgTestInvariant(); |
|
208 |
T b(aDes); |
|
209 |
b.__DbgTestInvariant(); |
|
210 |
test(b.Length()==aDes.Length()); |
|
211 |
test(*b.Ptr()==*aDes.Ptr()); |
|
212 |
test(*(b.Ptr()+1)==*(aDes.Ptr()+1)); |
|
213 |
test(*(b.Ptr()+2)==*(aDes.Ptr()+2)); |
|
214 |
} |
|
215 |
||
216 |
template<class T, class S, class L, class R> |
|
217 |
GLDEF_C void TestTDes<T,S,L,R>::Test3() |
|
218 |
// |
|
219 |
// Constructs a view over a length specified buffer |
|
220 |
// |
|
221 |
{ |
|
222 |
||
223 |
S* aBuf = _TL("ABCDEF"); |
|
224 |
T aDes(aBuf,6); |
|
225 |
aDes.__DbgTestInvariant(); |
|
226 |
test(aDes.Length()==6); |
|
227 |
for(S count=0; count<aDes.Length(); count++) |
|
228 |
test(*(aDes.Ptr()+count)==('A' + count)); |
|
229 |
test(aDes.Ptr()==aBuf); |
|
230 |
} |
|
231 |
||
232 |
template<class T, class S, class L, class R> |
|
233 |
GLDEF_C void TestTDes<T,S,L,R>::Test4() |
|
234 |
// |
|
235 |
// Constructs a r/w view over a buffer with length & maxlength |
|
236 |
// |
|
237 |
{ |
|
238 |
||
239 |
S* aBuf; |
|
240 |
aBuf=_TL("LMNOPQ"); |
|
241 |
T aDesW(aBuf,6,0x0A); |
|
242 |
aDesW.__DbgTestInvariant(); |
|
243 |
test(aDesW.Length()==6); |
|
244 |
for(S count=0; count<aDesW.Length(); count++) |
|
245 |
test(*(aDesW.Ptr()+count)==('L' + count)); |
|
246 |
test(aDesW.Ptr()==aBuf); |
|
247 |
test(aDesW.MaxLength()==0x0A); |
|
248 |
} |
|
249 |
||
250 |
template<class T, class S, class L, class R> |
|
251 |
GLDEF_C void TestTDes<T,S,L,R>::Test5() |
|
252 |
// |
|
253 |
// Constructs a r/w view over a buffer with maxlength |
|
254 |
// |
|
255 |
{ |
|
256 |
||
257 |
S* aBuf; |
|
258 |
aBuf=_TL("ZYXWVU"); |
|
259 |
T aDesW(aBuf,0x06); |
|
260 |
aDesW.__DbgTestInvariant(); |
|
261 |
test(aDesW.Length()==0); |
|
262 |
test(aDesW.MaxLength()==0x06); |
|
263 |
test(aDesW.Ptr()==aBuf); |
|
264 |
} |
|
265 |
||
266 |
template<class T, class S, class L, class R> |
|
267 |
GLDEF_C void TestTDes<T,S,L,R>::Test6() |
|
268 |
// |
|
269 |
// Constructs a r/w view over a LcbBase with maxlength |
|
270 |
// |
|
271 |
{ |
|
272 |
// Cant use yet, see calling function |
|
273 |
} |
|
274 |
||
275 |
template<class T, class S, class L, class R> |
|
276 |
GLDEF_C void TestTDes<T,S,L,R>::Test7() |
|
277 |
// |
|
278 |
// Constructs a default TBuf view |
|
279 |
// |
|
280 |
{ |
|
281 |
||
282 |
T aBuf; |
|
283 |
aBuf.__DbgTestInvariant(); |
|
284 |
test(aBuf.Length()==0); |
|
285 |
test(aBuf.MaxLength()==0x40); |
|
286 |
} |
|
287 |
||
288 |
template<class T, class S, class L, class R> |
|
289 |
GLDEF_C void TestTDes<T,S,L,R>::Test8() |
|
290 |
// |
|
291 |
// Constructs a TBuf view with length |
|
292 |
// |
|
293 |
{ |
|
294 |
||
295 |
T aBuf(10); |
|
296 |
aBuf.__DbgTestInvariant(); |
|
297 |
test(aBuf.Length()==10); |
|
298 |
test(aBuf.MaxLength()==0x40); |
|
299 |
} |
|
300 |
||
301 |
template<class T, class S, class L, class R> |
|
302 |
GLDEF_C void TestTDes<T,S,L,R>::Test9() |
|
303 |
// |
|
304 |
// Constructs a TBuf view over a string |
|
305 |
// |
|
306 |
{ |
|
307 |
||
308 |
T aBuf(_TL("ABCDEF")); |
|
309 |
aBuf.__DbgTestInvariant(); |
|
310 |
test(aBuf.Length()==6); |
|
311 |
test(aBuf.MaxLength()==0x40); |
|
312 |
for(S count=0;count<aBuf.Length();count++) |
|
313 |
test(*(aBuf.Ptr()+count)==('A' + count)); |
|
314 |
} |
|
315 |
||
316 |
template<class T, class S, class L, class R> |
|
317 |
GLDEF_C void TestTDes<T,S,L,R>::Test10() |
|
318 |
// |
|
319 |
// Constructs a TBuf view over a descriptor |
|
320 |
// |
|
321 |
{ |
|
322 |
||
323 |
R aDesR(_TL("ABCDEF")); |
|
324 |
aDesR.__DbgTestInvariant(); |
|
325 |
T aBuf(aDesR); |
|
326 |
aBuf.__DbgTestInvariant(); |
|
327 |
test(aBuf.MaxLength()==0x40); |
|
328 |
test(aBuf.Length()==aDesR.Length()); |
|
329 |
test(aBuf.Length()==6); |
|
330 |
for(S count=0;count<aBuf.Length();count++) |
|
331 |
{ |
|
332 |
test(*(aBuf.Ptr()+count)==('A' + count)); |
|
333 |
test(*(aBuf.Ptr()+count)==*(aDesR.Ptr()+count)); |
|
334 |
} |
|
335 |
} |
|
336 |
||
337 |
template<class T, class S, class L, class R> |
|
338 |
GLDEF_C void TestTDes<T,S,L,R>::Test11() |
|
339 |
// |
|
340 |
// Constructs a TBuf view over a buffer |
|
341 |
// |
|
342 |
{ |
|
343 |
||
344 |
T aBuf(_TL("ABCDEF")); |
|
345 |
aBuf.__DbgTestInvariant(); |
|
346 |
T bBuf(aBuf); |
|
347 |
bBuf.__DbgTestInvariant(); |
|
348 |
test(bBuf.MaxLength()==aBuf.MaxLength()); |
|
349 |
test(bBuf.MaxLength()==0x40); |
|
350 |
test(bBuf.Length()==aBuf.Length()); |
|
351 |
test(bBuf.Length()==6); |
|
352 |
for(S count=0;count<bBuf.Length();count++) |
|
353 |
{ |
|
354 |
test(*(bBuf.Ptr()+count)==('A' + count)); |
|
355 |
test(*(bBuf.Ptr()+count)==*(aBuf.Ptr()+count)); |
|
356 |
} |
|
357 |
} |
|
358 |
||
359 |
template<class T,class S,class L,class R> |
|
360 |
GLDEF_C void TestTDes<T,S,L,R>::Test12() |
|
361 |
// |
|
362 |
// Exercise the default TBufC constructor |
|
363 |
// |
|
364 |
{ |
|
365 |
||
366 |
T buf; |
|
367 |
buf.__DbgTestInvariant(); |
|
368 |
test(buf.Length()==0); |
|
369 |
} |
|
370 |
||
371 |
template<class T,class S,class L,class R> |
|
372 |
GLDEF_C void TestTDes<T,S,L,R>::Test13() |
|
373 |
// |
|
374 |
// Constructor over a string |
|
375 |
// |
|
376 |
{ |
|
377 |
||
378 |
S* pString=(_TL("12")); |
|
379 |
T buf(pString); |
|
380 |
buf.__DbgTestInvariant(); |
|
381 |
test(buf.Length()==2); |
|
382 |
test(*(buf.Ptr())=='1'); |
|
383 |
test(*(buf.Ptr()+1)=='2'); |
|
384 |
} |
|
385 |
||
386 |
template<class T,class S,class L,class R> |
|
387 |
GLDEF_C void TestTDes<T,S,L,R>::Test14() |
|
388 |
// |
|
389 |
// Constructor over a TDesC (TPtrC) |
|
390 |
// |
|
391 |
{ |
|
392 |
||
393 |
R des(_TL("Test 14")); |
|
394 |
des.__DbgTestInvariant(); |
|
395 |
T buf(des); |
|
396 |
buf.__DbgTestInvariant(); |
|
397 |
test(buf.Length()==7); |
|
398 |
test(buf.Length()==des.Length()); |
|
399 |
test(*(buf.Ptr())=='T'); |
|
400 |
test(*(buf.Ptr()+1)=='e'); |
|
401 |
test(*(buf.Ptr()+2)=='s'); |
|
402 |
test(*(buf.Ptr()+3)=='t'); |
|
403 |
test(*(buf.Ptr()+4)==' '); |
|
404 |
test(*(buf.Ptr()+5)=='1'); |
|
405 |
test(*(buf.Ptr()+6)=='4'); |
|
406 |
} |
|
407 |
||
408 |
||
409 |
template<class T,class S,class L,class R> |
|
410 |
GLDEF_C void TestTDes<T,S,L,R>::Test15() |
|
411 |
// |
|
412 |
// Constructor over a TBufC |
|
413 |
// |
|
414 |
{ |
|
415 |
||
416 |
T oldBuf(_TL("Test 15")); |
|
417 |
oldBuf.__DbgTestInvariant(); |
|
418 |
T newBuf(oldBuf); |
|
419 |
newBuf.__DbgTestInvariant(); |
|
420 |
test(newBuf.Length()==8); |
|
421 |
test(newBuf.Length()==oldBuf.Length()); |
|
422 |
test(*(newBuf.Ptr())=='T'); |
|
423 |
test(*(newBuf.Ptr()+1)=='e'); |
|
424 |
test(*(newBuf.Ptr()+2)=='s'); |
|
425 |
test(*(newBuf.Ptr()+3)=='t'); |
|
426 |
test(*(newBuf.Ptr()+4)==' '); |
|
427 |
test(*(newBuf.Ptr()+5)==' '); |
|
428 |
test(*(newBuf.Ptr()+6)=='1'); |
|
429 |
test(*(newBuf.Ptr()+7)=='5'); |
|
430 |
} |
|
431 |
||
432 |
template<class T,class S,class L,class R> |
|
433 |
GLDEF_C void TestTDes<T,S,L,R>::Test16() |
|
434 |
// |
|
435 |
// New operator - without leave |
|
436 |
// |
|
437 |
{ |
|
438 |
||
439 |
T* pBuf=T::New(0x40); |
|
440 |
test(pBuf!=NULL); |
|
441 |
pBuf->__DbgTestInvariant(); |
|
442 |
User::Free(pBuf); |
|
443 |
} |
|
444 |
||
445 |
template<class T,class S,class L,class R> |
|
446 |
GLDEF_C void TestTDes<T,S,L,R>::Test17() |
|
447 |
// |
|
448 |
// NewL operator - forcing a leave |
|
449 |
// |
|
450 |
{ |
|
451 |
||
452 |
/* |
|
453 |
||
454 |
Reinstate if some method is found of forcing alloc fail |
|
455 |
This test no longer works due to heap growing functionality of E32 057 |
|
456 |
||
457 |
T* pBuf; |
|
458 |
TInt temp; |
|
459 |
TInt available=User::Available(temp); |
|
460 |
TAny* pDummy=User::Alloc(available); |
|
461 |
TRAPD(ret,pBuf=T::NewL(0x40)) |
|
462 |
test(ret==KErrNoMemory); |
|
463 |
User::Free(pDummy); |
|
464 |
*/ |
|
465 |
} |
|
466 |
||
467 |
template<class T,class S,class L,class R> |
|
468 |
GLDEF_C void TestTDes<T,S,L,R>::Test18() |
|
469 |
// |
|
470 |
// NewL operator - forcing success |
|
471 |
// |
|
472 |
{ |
|
473 |
||
474 |
T* pBuf=NULL; |
|
475 |
TRAPD(ret,pBuf=T::NewL(0x40)) |
|
476 |
test(ret==0); |
|
477 |
test(pBuf!=NULL); |
|
478 |
pBuf->__DbgTestInvariant(); |
|
479 |
User::Free(pBuf); |
|
480 |
} |
|
481 |
||
482 |
template<class T, class S, class L, class R> |
|
483 |
GLDEF_C void TestTDes<T,S,L,R>::TestA() |
|
484 |
// |
|
485 |
// String Assignment |
|
486 |
// |
|
487 |
{ |
|
488 |
||
489 |
S myBuf[7]; |
|
490 |
Mem::Copy(myBuf,_TL("ABCDEF"),7*sizeof(S)); |
|
491 |
T aDes(myBuf,0x06,0x06); |
|
492 |
aDes=_TL("ZYXWVU"); |
|
493 |
aDes.__DbgTestInvariant(); |
|
494 |
test(aDes.Length()==6); |
|
495 |
test(aDes.MaxLength()==0x06); |
|
496 |
S count=0; |
|
497 |
for(;count<aDes.Length(); count++) |
|
498 |
{ |
|
499 |
test(*(aDes.Ptr()+count)==('Z'-count)); |
|
500 |
} |
|
501 |
aDes=_TL("123"); |
|
502 |
aDes.__DbgTestInvariant(); |
|
503 |
test(aDes.Length()==3); |
|
504 |
test(aDes.MaxLength()==0x06); |
|
505 |
for(count=0; count<aDes.Length(); count++) |
|
506 |
{ |
|
507 |
test(*(aDes.Ptr()+count)==('1'+count)); |
|
508 |
} |
|
509 |
} |
|
510 |
||
511 |
||
512 |
template<class T, class S, class L, class R> |
|
513 |
GLDEF_C void TestTDes<T,S,L,R>::TestB() |
|
514 |
// DesW Assignment |
|
515 |
{ |
|
516 |
S aBuf[11]; |
|
517 |
S bBuf[11]; |
|
518 |
||
519 |
Mem::Copy(aBuf,_TL("ZYXWVUTSRQ"),11*sizeof(S)); |
|
520 |
Mem::Copy(bBuf,_TL("ABCDEFGHIJ"),11*sizeof(S)); |
|
521 |
T aDes(aBuf,0x0A,0x0A); |
|
522 |
T bDes(bBuf,0x0A); |
|
523 |
bDes=aDes; |
|
524 |
aDes.__DbgTestInvariant(); |
|
525 |
bDes.__DbgTestInvariant(); |
|
526 |
test(aDes.Length()==bDes.Length()); |
|
527 |
test(aDes.MaxLength()==0x0A); |
|
528 |
test(bDes.MaxLength()==0x0A); |
|
529 |
for(S count=0; count<bDes.Length(); count++) |
|
530 |
{ |
|
531 |
test(*(aDes.Ptr()+count)==*(bDes.Ptr()+count)); |
|
532 |
} |
|
533 |
} |
|
534 |
||
535 |
||
536 |
||
537 |
template<class T, class S, class L, class R> |
|
538 |
GLDEF_C void TestTDes<T,S,L,R>::TestC() |
|
539 |
// DesC Assignment |
|
540 |
{ |
|
541 |
S aBuf[11]; |
|
542 |
R aDesR(_TL("1234567890")); |
|
543 |
Mem::Copy(aBuf,_TL("ABCDEFGHIJ"),11*sizeof(S)); |
|
544 |
T aDes(aBuf,0x0A,0x0A); |
|
545 |
aDes=aDesR; |
|
546 |
aDes.__DbgTestInvariant(); |
|
547 |
test(aDes.Length()==aDesR.Length()); |
|
548 |
test(aDes.MaxLength()==0x0A); |
|
549 |
for(S count=0; count<aDes.Length(); count++) |
|
550 |
{ |
|
551 |
test(*(aDes.Ptr()+count)==*(aDesR.Ptr()+count)); |
|
552 |
} |
|
553 |
} |
|
554 |
||
555 |
||
556 |
template<class T, class S, class L, class R> |
|
557 |
GLDEF_C void TestTDes<T,S,L,R>::TestD() |
|
558 |
// TBuf string Assignment |
|
559 |
{ |
|
560 |
T aBuf; |
|
561 |
aBuf=(_TL("ABCDEF")); |
|
562 |
aBuf.__DbgTestInvariant(); |
|
563 |
test(aBuf.Length()==6); |
|
564 |
test(aBuf.MaxLength()==0x40); |
|
565 |
for(S count=0; count<aBuf.Length(); count++) |
|
566 |
{ |
|
567 |
test(*(aBuf.Ptr()+count)==('A'+count)); |
|
568 |
} |
|
569 |
} |
|
570 |
||
571 |
||
572 |
template<class T, class S, class L, class R> |
|
573 |
GLDEF_C void TestTDes<T,S,L,R>::TestE() |
|
574 |
// TBuf descriptor Assignment |
|
575 |
{ |
|
576 |
R aDesR(_TL("ABCDEF")); |
|
577 |
T aBuf; |
|
578 |
aBuf=aDesR; |
|
579 |
aBuf.__DbgTestInvariant(); |
|
580 |
test(aBuf.MaxLength()==0x40); |
|
581 |
test(aBuf.Length()==aDesR.Length()); |
|
582 |
test(aBuf.Length()==6); |
|
583 |
for(S count=0;count<aBuf.Length();count++) |
|
584 |
{ |
|
585 |
test(*(aBuf.Ptr()+count)==('A' + count)); |
|
586 |
test(*(aBuf.Ptr()+count)==*(aDesR.Ptr()+count)); |
|
587 |
} |
|
588 |
} |
|
589 |
||
590 |
||
591 |
template<class T, class S, class L, class R> |
|
592 |
GLDEF_C void TestTDes<T,S,L,R>::TestF() |
|
593 |
// TBuf buffer Assignment |
|
594 |
{ |
|
595 |
T aBuf(_TL("ABCDEF")); |
|
596 |
T bBuf; |
|
597 |
bBuf=aBuf; |
|
598 |
bBuf.__DbgTestInvariant(); |
|
599 |
test(bBuf.MaxLength()==aBuf.MaxLength()); |
|
600 |
test(bBuf.MaxLength()==0x40); |
|
601 |
test(bBuf.Length()==aBuf.Length()); |
|
602 |
test(bBuf.Length()==6); |
|
603 |
for(S count=0;count<bBuf.Length();count++) |
|
604 |
{ |
|
605 |
test(*(bBuf.Ptr()+count)==('A' + count)); |
|
606 |
test(*(bBuf.Ptr()+count)==*(aBuf.Ptr()+count)); |
|
607 |
} |
|
608 |
} |
|
609 |
||
610 |
||
611 |
template<class T, class S, class L, class R> |
|
612 |
GLDEF_C void TestTDes<T,S,L,R>::TestG() |
|
613 |
// TBufC string assignment test |
|
614 |
{ |
|
615 |
S* pString=_TL("TestG"); |
|
616 |
T buf; |
|
617 |
||
618 |
test(buf.Length()==0); |
|
619 |
buf=pString; |
|
620 |
buf.__DbgTestInvariant(); |
|
621 |
test(buf.Length()==5); |
|
622 |
test(*(buf.Ptr())=='T'); |
|
623 |
test(*(buf.Ptr()+1)=='e'); |
|
624 |
test(*(buf.Ptr()+2)=='s'); |
|
625 |
test(*(buf.Ptr()+3)=='t'); |
|
626 |
test(*(buf.Ptr()+4)=='G'); |
|
627 |
} |
|
628 |
||
629 |
||
630 |
template<class T, class S, class L, class R> |
|
631 |
GLDEF_C void TestTDes<T,S,L,R>::TestH() |
|
632 |
// TBufC descriptor assignment |
|
633 |
{ |
|
634 |
R des(_TL("TestH")); |
|
635 |
T buf; |
|
636 |
||
637 |
test(buf.Length()==0); |
|
638 |
buf=des; |
|
639 |
buf.__DbgTestInvariant(); |
|
640 |
test(buf.Length()==5); |
|
641 |
test(buf.Length()==des.Length()); |
|
642 |
test(*(buf.Ptr())=='T'); |
|
643 |
test(*(buf.Ptr()+1)=='e'); |
|
644 |
test(*(buf.Ptr()+2)=='s'); |
|
645 |
test(*(buf.Ptr()+3)=='t'); |
|
646 |
test(*(buf.Ptr()+4)=='H'); |
|
647 |
} |
|
648 |
||
649 |
template<class T, class S, class L, class R> |
|
650 |
GLDEF_C void TestTDes<T,S,L,R>::TestI() |
|
651 |
// TBufC TBufC assignment |
|
652 |
{ |
|
653 |
T oldBuf(_TL("TEsti")); |
|
654 |
T newBuf; |
|
655 |
||
656 |
test(newBuf.Length()==0); |
|
657 |
newBuf=oldBuf; |
|
658 |
newBuf.__DbgTestInvariant(); |
|
659 |
test(newBuf.Length()==5); |
|
660 |
test(newBuf.Length()==oldBuf.Length()); |
|
661 |
test(*(newBuf.Ptr())=='T'); |
|
662 |
test(*(newBuf.Ptr()+1)=='E'); |
|
663 |
test(*(newBuf.Ptr()+2)=='s'); |
|
664 |
test(*(newBuf.Ptr()+3)=='t'); |
|
665 |
test(*(newBuf.Ptr()+4)=='i'); |
|
666 |
} |
|
667 |
||
668 |
template<class T,class S,class L,class R> |
|
669 |
GLDEF_C void TestTDes<T,S,L,R>::TestJ() |
|
670 |
// |
|
671 |
// HBufC string assignment |
|
672 |
// |
|
673 |
{ |
|
674 |
||
675 |
S* pString=_TL("tEStJ"); |
|
676 |
T* pBuf=NULL; |
|
677 |
TRAPD(ret,pBuf=T::NewL(0x40)) |
|
678 |
test(ret==0); |
|
679 |
test(pBuf!=NULL); |
|
680 |
*pBuf=pString; |
|
681 |
pBuf->__DbgTestInvariant(); |
|
682 |
test(pBuf->Length()==5); |
|
683 |
test(*(pBuf->Ptr())=='t'); |
|
684 |
test(*(pBuf->Ptr()+1)=='E'); |
|
685 |
test(*(pBuf->Ptr()+2)=='S'); |
|
686 |
test(*(pBuf->Ptr()+3)=='t'); |
|
687 |
test(*(pBuf->Ptr()+4)=='J'); |
|
688 |
User::Free(pBuf); |
|
689 |
} |
|
690 |
||
691 |
template<class T,class S,class L,class R> |
|
692 |
GLDEF_C void TestTDes<T,S,L,R>::TestK() |
|
693 |
// |
|
694 |
// HBufC descriptor assignment |
|
695 |
// |
|
696 |
{ |
|
697 |
||
698 |
R des(_TL("TestK")); |
|
699 |
T* pBuf=NULL; |
|
700 |
TRAPD(ret,pBuf=T::NewL(0x40)) |
|
701 |
test(ret==0); |
|
702 |
test(pBuf!=NULL); |
|
703 |
*pBuf=des; |
|
704 |
pBuf->__DbgTestInvariant(); |
|
705 |
test(pBuf->Length()==5); |
|
706 |
test(pBuf->Length()==des.Length()); |
|
707 |
test(*(pBuf->Ptr())=='T'); |
|
708 |
test(*(pBuf->Ptr()+1)=='e'); |
|
709 |
test(*(pBuf->Ptr()+2)=='s'); |
|
710 |
test(*(pBuf->Ptr()+3)=='t'); |
|
711 |
test(*(pBuf->Ptr()+4)=='K'); |
|
712 |
User::Free(pBuf); |
|
713 |
} |
|
714 |
||
715 |
template<class T,class S,class L,class R> |
|
716 |
GLDEF_C void TestTDes<T,S,L,R>::TestL() |
|
717 |
// |
|
718 |
// HBufC HBufC assignment |
|
719 |
// |
|
720 |
{ |
|
721 |
||
722 |
S* pString=_TL("testl"); |
|
723 |
T* pOldBuf=NULL; |
|
724 |
T* pNewBuf=NULL; |
|
725 |
TRAPD(ret,pOldBuf=T::NewL(0x40)) |
|
726 |
test(ret==0); |
|
727 |
TRAP(ret,pNewBuf=T::NewL(0x40)) |
|
728 |
test(ret==0); |
|
729 |
test(pNewBuf!=NULL); |
|
730 |
test(pOldBuf!=NULL); |
|
731 |
*pOldBuf=pString; |
|
732 |
*pNewBuf=*pOldBuf; |
|
733 |
pOldBuf->__DbgTestInvariant(); |
|
734 |
pNewBuf->__DbgTestInvariant(); |
|
735 |
test(pNewBuf->Length()==5); |
|
736 |
test(pOldBuf->Length()==pNewBuf->Length()); |
|
737 |
test(*(pNewBuf->Ptr())=='t'); |
|
738 |
test(*(pNewBuf->Ptr()+1)=='e'); |
|
739 |
test(*(pNewBuf->Ptr()+2)=='s'); |
|
740 |
test(*(pNewBuf->Ptr()+3)=='t'); |
|
741 |
test(*(pNewBuf->Ptr()+4)=='l'); |
|
742 |
User::Free(pOldBuf); |
|
743 |
User::Free(pNewBuf); |
|
744 |
// |
|
745 |
TRAP(ret,pOldBuf=T::NewMaxL(0x40)) |
|
746 |
test(ret==0); |
|
747 |
TRAP(ret,pNewBuf=T::NewMaxL(0x40)) |
|
748 |
test(ret==0); |
|
749 |
test(pNewBuf!=NULL); |
|
750 |
test(pOldBuf!=NULL); |
|
751 |
pOldBuf->__DbgTestInvariant(); |
|
752 |
pNewBuf->__DbgTestInvariant(); |
|
753 |
test(pNewBuf->Length()==0x40); |
|
754 |
test(pOldBuf->Length()==0x40); |
|
755 |
pNewBuf->Des().Zero(); |
|
756 |
pOldBuf->Des().Zero(); |
|
757 |
pOldBuf->__DbgTestInvariant(); |
|
758 |
pNewBuf->__DbgTestInvariant(); |
|
759 |
test(pNewBuf->Length()==0); |
|
760 |
test(pOldBuf->Length()==0); |
|
761 |
*pOldBuf=pString; |
|
762 |
*pNewBuf=*pOldBuf; |
|
763 |
pOldBuf->__DbgTestInvariant(); |
|
764 |
pNewBuf->__DbgTestInvariant(); |
|
765 |
test(pNewBuf->Length()==5); |
|
766 |
test(pOldBuf->Length()==pNewBuf->Length()); |
|
767 |
test(*(pNewBuf->Ptr())=='t'); |
|
768 |
test(*(pNewBuf->Ptr()+1)=='e'); |
|
769 |
test(*(pNewBuf->Ptr()+2)=='s'); |
|
770 |
test(*(pNewBuf->Ptr()+3)=='t'); |
|
771 |
test(*(pNewBuf->Ptr()+4)=='l'); |
|
772 |
User::Free(pOldBuf); |
|
773 |
User::Free(pNewBuf); |
|
774 |
} |
|
775 |
||
776 |
template<class T,class S,class L,class R> |
|
777 |
GLDEF_C void TestTDes<T,S,L,R>::TestM() |
|
778 |
// |
|
779 |
// HBufC ReAlloc |
|
780 |
// |
|
781 |
{ |
|
782 |
||
783 |
S* pString=_TL("TESTM"); |
|
784 |
T* pBuf; |
|
785 |
pBuf=T::NewL(0x40); |
|
786 |
*pBuf=pString; |
|
787 |
pBuf->ReAlloc(0x40); |
|
788 |
test(pBuf!=NULL); |
|
789 |
pBuf->__DbgTestInvariant(); |
|
790 |
test(pBuf->Length()==5); |
|
791 |
test(*(pBuf->Ptr())=='T'); |
|
792 |
test(*(pBuf->Ptr()+1)=='E'); |
|
793 |
test(*(pBuf->Ptr()+2)=='S'); |
|
794 |
test(*(pBuf->Ptr()+3)=='T'); |
|
795 |
test(*(pBuf->Ptr()+4)=='M'); |
|
796 |
User::Free(pBuf); |
|
797 |
} |
|
798 |
||
799 |
template<class T,class S,class L,class R> |
|
800 |
GLDEF_C void TestTDes<T,S,L,R>::TestN() |
|
801 |
// |
|
802 |
// HBufC ReAllocL - forcing a leave |
|
803 |
// |
|
804 |
{ |
|
805 |
||
806 |
/* |
|
807 |
||
808 |
Reinstate if some method is found of forcing alloc fail |
|
809 |
This test no longer works due to heap growing functionality of E32 057 |
|
810 |
||
811 |
S* pString=_TL("tEStJ"); |
|
812 |
T* pBuf; |
|
813 |
TInt available, temp; |
|
814 |
TAny* pDummy; |
|
815 |
pBuf=T::NewL(0x40); |
|
816 |
test(pBuf!=NULL); |
|
817 |
*pBuf=pString; |
|
818 |
available=User::Available(temp); |
|
819 |
pDummy=User::Alloc(available); |
|
820 |
TRAPD(ret,pBuf->ReAllocL(0x50)) |
|
821 |
test(ret==KErrNoMemory); |
|
822 |
User::Free(pDummy); |
|
823 |
User::Free(pBuf); |
|
824 |
*/ |
|
825 |
} |
|
826 |
||
827 |
template<class T,class S,class L,class R> |
|
828 |
GLDEF_C void TestTDes<T,S,L,R>::TestO() |
|
829 |
// HBufC ReAllocL - forcing success |
|
830 |
{ |
|
831 |
||
832 |
S* pString=_TL("tEStJ"); |
|
833 |
T* pBuf; |
|
834 |
pBuf=T::NewL(0x40); |
|
835 |
test(pBuf!=0); |
|
836 |
*pBuf=pString; |
|
837 |
TRAPD(ret,pBuf->ReAllocL(0x40)) |
|
838 |
test(ret==0); |
|
839 |
test(pBuf!=NULL); |
|
840 |
pBuf->__DbgTestInvariant(); |
|
841 |
test(pBuf->Length()==5); |
|
842 |
test(*(pBuf->Ptr())=='t'); |
|
843 |
test(*(pBuf->Ptr()+1)=='E'); |
|
844 |
test(*(pBuf->Ptr()+2)=='S'); |
|
845 |
test(*(pBuf->Ptr()+3)=='t'); |
|
846 |
test(*(pBuf->Ptr()+4)=='J'); |
|
847 |
User::Free(pBuf); |
|
848 |
} |
|
849 |
||
850 |
template<class T,class S,class L,class R> |
|
851 |
GLDEF_C void TestTDes<T,S,L,R>::TestP() |
|
852 |
// Invariant for null pointer descriptor |
|
853 |
// Added to reproduce DEF023302 |
|
854 |
{ |
|
855 |
T p(NULL, 0); |
|
856 |
p.__DbgTestInvariant(); |
|
857 |
} |
|
858 |
||
859 |
GLDEF_C void TestCopy16() |
|
860 |
// Test TPtr16 copy constructor |
|
861 |
{ |
|
862 |
TBuf16<0x20> buf(_S16("Paddington Station")); |
|
863 |
TPtr16 ptr1((TText16*)buf.Ptr(),buf.Length(),buf.MaxLength()); |
|
864 |
ptr1.__DbgTestInvariant(); |
|
865 |
TPtr16 ptr2(ptr1); |
|
866 |
ptr2.__DbgTestInvariant(); |
|
867 |
ptr2[11]='B'; |
|
868 |
ptr2[12]='e'; |
|
869 |
ptr2[13]='a'; |
|
870 |
ptr2[14]='r'; |
|
871 |
ptr2[15]=' '; |
|
872 |
ptr1.SetLength(15); |
|
873 |
ptr2.Append(_L16(" acid")); |
|
874 |
test(ptr1==_L16("Paddington Bear")); |
|
875 |
test(ptr2==_L16("Paddington Bear on acid")); |
|
876 |
} |
|
877 |
||
878 |
GLDEF_C void Test16To8() |
|
879 |
// Test ASCII dest with Unicode source |
|
880 |
{ |
|
881 |
TBuf8<0x20> buf(_S8("Paddington Station")); |
|
882 |
TPtr8 ptr1((TText8*)buf.Ptr(),buf.Length(),buf.MaxLength()); |
|
883 |
ptr1.__DbgTestInvariant(); |
|
884 |
TPtr8 ptr2(ptr1); |
|
885 |
ptr2.__DbgTestInvariant(); |
|
886 |
ptr2[11]='B'; |
|
887 |
ptr2[12]='e'; |
|
888 |
ptr2[13]='a'; |
|
889 |
ptr2[14]='r'; |
|
890 |
ptr2[15]=' '; |
|
891 |
ptr1.SetLength(15); |
|
892 |
ptr1.__DbgTestInvariant(); |
|
893 |
ptr2.Append(_L16(" acid")); |
|
894 |
ptr2.__DbgTestInvariant(); |
|
895 |
test(ptr1==_L8("Paddington Bear")); |
|
896 |
test(ptr2==_L8("Paddington Bear on acid")); |
|
897 |
} |
|
898 |
||
899 |
||
900 |
GLDEF_C void TestCopy8() |
|
901 |
// Test TPtr8 copy constructor |
|
902 |
{ |
|
903 |
TBuf8<0x20> buf(_S8("Paddington Station")); |
|
904 |
TPtr8 ptr1((TText8*)buf.Ptr(),buf.Length(),buf.MaxLength()); |
|
905 |
TPtr8 ptr2(ptr1); |
|
906 |
ptr2[11]='B'; |
|
907 |
ptr2[12]='e'; |
|
908 |
ptr2[13]='a'; |
|
909 |
ptr2[14]='r'; |
|
910 |
ptr2[15]=' '; |
|
911 |
ptr1.SetLength(15); |
|
912 |
ptr2.Append(_L8(" acid")); |
|
913 |
ptr1.__DbgTestInvariant(); |
|
914 |
ptr2.__DbgTestInvariant(); |
|
915 |
test(ptr1==_L8("Paddington Bear")); |
|
916 |
test(ptr2==_L8("Paddington Bear on acid")); |
|
917 |
} |
|
918 |
||
919 |
GLDEF_C void TestCopy() |
|
920 |
// Test TPtr copy constructor |
|
921 |
{ |
|
922 |
TBuf<0x20> buf(_S("Paddington Station")); |
|
923 |
TPtr ptr1((TText*)buf.Ptr(),buf.Length(),buf.MaxLength()); |
|
924 |
TPtr ptr2(ptr1); |
|
925 |
ptr2[11]='B'; |
|
926 |
ptr2[12]='e'; |
|
927 |
ptr2[13]='a'; |
|
928 |
ptr2[14]='r'; |
|
929 |
ptr2[15]=' '; |
|
930 |
ptr1.SetLength(15); |
|
931 |
ptr2.Append(_L(" acid")); |
|
932 |
ptr1.__DbgTestInvariant(); |
|
933 |
ptr2.__DbgTestInvariant(); |
|
934 |
test(ptr1==_L("Paddington Bear")); |
|
935 |
test(ptr2==_L("Paddington Bear on acid")); |
|
936 |
} |
|
937 |
||
938 |
template<class T, class S, class L, class R> |
|
939 |
GLDEF_C void TestTDes<T,S,L,R>::test_TPtrC() |
|
940 |
// |
|
941 |
// Test the TDesC class special member functions |
|
942 |
// |
|
943 |
{ |
|
944 |
||
945 |
test.Start(_L("Invariant for null pointer descriptor")); |
|
946 |
TestP(); |
|
947 |
test.Next(_L("R/O view over constant string")); |
|
948 |
Test1(); |
|
949 |
test.Next(_L("R/O view over constant descriptor")); |
|
950 |
Test2(); |
|
951 |
test.Next(_L("R/O view over constant buffer with length")); |
|
952 |
Test3(); |
|
953 |
} |
|
954 |
||
955 |
template<class T, class S, class L, class R> |
|
956 |
GLDEF_C void TestTDes<T,S,L,R>::test_TPtr() |
|
957 |
// |
|
958 |
// Test the TPtr class special member functions |
|
959 |
// |
|
960 |
{ |
|
961 |
||
962 |
test.Start(_L("Invariant for null pointer descriptor")); |
|
963 |
TestP(); |
|
964 |
test.Next(_L("R/W view over buffer with length & maxlength")); |
|
965 |
Test4(); |
|
966 |
test.Next(_L("R/W view over buffer with maxlength")); |
|
967 |
Test5(); |
|
968 |
// Skipped the following test because Colly hasn't |
|
969 |
// written the templates yet for the TBufC8 & 16 classes |
|
970 |
// test.Next(_L("R/W view over LcbBase with maxlength")); |
|
971 |
// Test6(); |
|
972 |
test.Next(_L("String assignment")); |
|
973 |
TestA(); |
|
974 |
test.Next(_L("DesW assignment")); |
|
975 |
TestB(); |
|
976 |
test.Next(_L("DesC assignment")); |
|
977 |
TestC(); |
|
978 |
} |
|
979 |
||
980 |
template<class T, class S, class L, class R> |
|
981 |
GLDEF_C void TestTDes<T,S,L,R>::test_TBuf() |
|
982 |
// |
|
983 |
// Test the TBuf class special member functions |
|
984 |
// |
|
985 |
{ |
|
986 |
||
987 |
test.Start(_L("TBuf default view, no params")); |
|
988 |
Test7(); |
|
989 |
test.Next(_L("TBuf view with a length")); |
|
990 |
Test8(); |
|
991 |
test.Next(_L("TBuf view over a string")); |
|
992 |
Test9(); |
|
993 |
test.Next(_L("TBuf view over a descriptor")); |
|
994 |
Test10(); |
|
995 |
test.Next(_L("TBuf view over a buffer")); |
|
996 |
Test11(); |
|
997 |
test.Next(_L("String assignment")); |
|
998 |
TestD(); |
|
999 |
test.Next(_L("Descriptor assignment")); |
|
1000 |
TestE(); |
|
1001 |
test.Next(_L("Buffer assignment")); |
|
1002 |
TestF(); |
|
1003 |
} |
|
1004 |
||
1005 |
template<class T,class S,class L,class R> |
|
1006 |
GLDEF_C void TestTDes<T,S,L,R>::test_TBufC() |
|
1007 |
// |
|
1008 |
// Test the TBufC class methods |
|
1009 |
// |
|
1010 |
{ |
|
1011 |
||
1012 |
test.Start(_L("Default constructor")); |
|
1013 |
Test12(); |
|
1014 |
test.Next(_L("With a string")); |
|
1015 |
Test13(); |
|
1016 |
test.Next(_L("With a Descriptor (TPtrC)")); |
|
1017 |
Test14(); |
|
1018 |
test.Next(_L("With a TBufC")); |
|
1019 |
Test15(); |
|
1020 |
test.Next(_L("String assignment")); |
|
1021 |
TestG(); |
|
1022 |
test.Next(_L("Descriptor assignment (TPtrC)")); |
|
1023 |
TestH(); |
|
1024 |
test.Next(_L("TBufC assignment")); |
|
1025 |
TestI(); |
|
1026 |
} |
|
1027 |
||
1028 |
template<class T,class S,class L,class R> |
|
1029 |
GLDEF_C void TestTDes<T,S,L,R>::test_HBufC() |
|
1030 |
// |
|
1031 |
// Test the HBufC class methods. |
|
1032 |
// |
|
1033 |
{ |
|
1034 |
||
1035 |
test.Start(_L("New")); |
|
1036 |
Test16(); |
|
1037 |
test.Next(_L("NewL - forcing a leave")); |
|
1038 |
Test17(); |
|
1039 |
test.Next(_L("NewL - showing success")); |
|
1040 |
Test18(); |
|
1041 |
test.Next(_L("String assignment")); |
|
1042 |
TestJ(); |
|
1043 |
test.Next(_L("Descriptor assignment")); |
|
1044 |
TestK(); |
|
1045 |
test.Next(_L("HBufC assignment")); |
|
1046 |
TestL(); |
|
1047 |
test.Next(_L("ReAlloc")); |
|
1048 |
TestM(); |
|
1049 |
test.Next(_L("ReAllocL - forcing a leave")); |
|
1050 |
TestN(); |
|
1051 |
test.Next(_L("ReAllocL - showing success")); |
|
1052 |
TestO(); |
|
1053 |
} |
|
1054 |
||
1055 |
template<class T,class S,class L,class R> |
|
1056 |
GLDEF_C void TestTDes<T,S,L,R>::test_TBufReturningModifiable() |
|
1057 |
{ |
|
1058 |
T a; |
|
1059 |
R b(0,0); |
|
1060 |
a.Copy(_TL("abcdefg")); |
|
1061 |
test_TDesReturningModifiable(a,b); |
|
1062 |
} |
|
1063 |
||
1064 |
template<class T,class S,class L,class R> |
|
1065 |
GLDEF_C void TestTDes<T,S,L,R>::test_TPtrReturningModifiable() |
|
1066 |
{ |
|
1067 |
S* aBuf; |
|
1068 |
aBuf=_TL("abcdefg"); |
|
1069 |
T a(aBuf,7,7); |
|
1070 |
R b(0,0); |
|
1071 |
test_TDesReturningModifiable(a,b); |
|
1072 |
} |
|
1073 |
||
1074 |
template<class T,class S,class L,class R> |
|
1075 |
GLDEF_C void TestTDes<T,S,L,R>::test_TDesReturningModifiable(const T& a, R& b) |
|
1076 |
{ |
|
1077 |
test.Start(_L("Test TDes derived objects that return TPtrs")); |
|
1078 |
||
1079 |
test.Next(_L("LeftTPtr")); |
|
1080 |
b.Set(a.LeftTPtr(3)); |
|
1081 |
b.__DbgTestInvariant(); |
|
1082 |
test(b == a.Left(3)); |
|
1083 |
||
1084 |
b.Set(a.LeftTPtr(0)); |
|
1085 |
b.__DbgTestInvariant(); |
|
1086 |
test(b == a.Left(0)); |
|
1087 |
||
1088 |
b.Set(a.LeftTPtr(7)); |
|
1089 |
b.__DbgTestInvariant(); |
|
1090 |
test(b == a.Left(7)); |
|
1091 |
||
1092 |
b = a.LeftTPtr(42); |
|
1093 |
b.__DbgTestInvariant(); |
|
1094 |
test(b == a.Left(7)); |
|
1095 |
||
1096 |
test.Next(_L("RightTPtr")); |
|
1097 |
b.Set(a.RightTPtr(5)); |
|
1098 |
b.__DbgTestInvariant(); |
|
1099 |
test(b == a.Right(5)); |
|
1100 |
||
1101 |
b.Set(a.RightTPtr(7)); |
|
1102 |
b.__DbgTestInvariant(); |
|
1103 |
test(b == a.Right(7)); |
|
1104 |
||
1105 |
b.Set(a.RightTPtr(0)); |
|
1106 |
b.__DbgTestInvariant(); |
|
1107 |
test(b == a.Right(0)); |
|
1108 |
||
1109 |
b.Set(a.RightTPtr(42)); |
|
1110 |
b.__DbgTestInvariant(); |
|
1111 |
test(b == a.Right(42)); |
|
1112 |
||
1113 |
test.Next(_L("MidTPtr")); |
|
1114 |
b.Set(a.MidTPtr(5)); |
|
1115 |
b.__DbgTestInvariant(); |
|
1116 |
test(b == a.Mid(5)); |
|
1117 |
||
1118 |
b.Set(a.MidTPtr(7)); |
|
1119 |
b.__DbgTestInvariant(); |
|
1120 |
test(b == a.Mid(7)); |
|
1121 |
||
1122 |
b.Set(a.MidTPtr(0)); |
|
1123 |
b.__DbgTestInvariant(); |
|
1124 |
test(b == a.Mid(0)); |
|
1125 |
||
1126 |
test.Next(_L("MidTPtr (2 parms)")); |
|
1127 |
b.Set(a.MidTPtr(4,3)); |
|
1128 |
b.__DbgTestInvariant(); |
|
1129 |
test(b == a.Mid(4,3)); |
|
1130 |
test(b == a.Mid(4)); |
|
1131 |
||
1132 |
b.Set(a.MidTPtr(0,0)); |
|
1133 |
b.__DbgTestInvariant(); |
|
1134 |
test(b == a.Mid(0,0)); |
|
1135 |
||
1136 |
b.Set(a.MidTPtr(3,2)); |
|
1137 |
b.__DbgTestInvariant(); |
|
1138 |
test(b == a.Mid(3,2)); |
|
1139 |
||
1140 |
b.Set(a.MidTPtr(7,0)); |
|
1141 |
b.__DbgTestInvariant(); |
|
1142 |
test(b == a.Mid(7,0)); |
|
1143 |
} |
|
1144 |
||
1145 |
LOCAL_C void testAssignTPtr() |
|
1146 |
// |
|
1147 |
// Test assigning TPtr's. |
|
1148 |
// |
|
1149 |
{ |
|
1150 |
||
1151 |
TBufC<0x20> x(_S("Hello")); |
|
1152 |
TPtr p=x.Des(); |
|
1153 |
p+=_L(" World"); |
|
1154 |
test(p==_L("Hello World")); |
|
1155 |
test(x==_L("Hello World")); |
|
1156 |
p.SetLength(5); |
|
1157 |
test(p==_L("Hello")); |
|
1158 |
test(x==_L("Hello")); |
|
1159 |
TBufC<0x20> y(_S("ByeBye")); |
|
1160 |
TPtr q=y.Des(); |
|
1161 |
q.Set(p); |
|
1162 |
test(q==p); |
|
1163 |
q+=_L(" World"); |
|
1164 |
test(q==_L("Hello World")); |
|
1165 |
test(x==_L("Hello World")); |
|
1166 |
test(y==_L("ByeBye")); |
|
1167 |
q.Set((TText*)x.Ptr(),x.Length(),x.Des().MaxLength()); |
|
1168 |
test(q==_L("Hello World")); |
|
1169 |
test(q.MaxLength()==0x20); |
|
1170 |
q.SetLength(1); |
|
1171 |
test(q==_L("H")); |
|
1172 |
test(x==_L("Hello World")); |
|
1173 |
} |
|
1174 |
||
1175 |
LOCAL_C void testTPtrLocateReverse() |
|
1176 |
// |
|
1177 |
// Test locating in reverse on an empty TPtr |
|
1178 |
// |
|
1179 |
{ |
|
1180 |
||
1181 |
TPtrC a; |
|
1182 |
test(a.LocateReverse('0')==KErrNotFound); |
|
1183 |
test(a.LocateReverseF('0')==KErrNotFound); |
|
1184 |
} |
|
1185 |
||
1186 |
_LIT8(KLitTest1_8,"1"); |
|
1187 |
_LIT8(KLitTest12_8,"12"); |
|
1188 |
_LIT8(KLitTest123_8,"123"); |
|
1189 |
_LIT8(KLitTest1234_8,"1234"); |
|
1190 |
_LIT8(KLitTestalpha_8,"abcdefghijklmnopqrstuvwxyz"); |
|
1191 |
||
1192 |
LOCAL_C const TDesC8& testByRef8(TRefByValue<const TDesC8> aRef) |
|
1193 |
{ |
|
1194 |
return aRef; |
|
1195 |
} |
|
1196 |
||
1197 |
LOCAL_C void testTLitC8() |
|
1198 |
{ |
|
1199 |
test.Start(_L("All members")); |
|
1200 |
test (_L8("")==KNullDesC8); // operator const TDesC8& |
|
1201 |
test (KNullDesC8()==TPtrC8()); // operator() |
|
1202 |
const TDesC8* pNull=&KNullDesC8; // operator& |
|
1203 |
test (pNull->Compare(_L8(""))==0); |
|
1204 |
test (&testByRef8(KNullDesC8)==&KNullDesC8); // operator const TRefByValue<const TDesC8> |
|
1205 |
// |
|
1206 |
test.Next(_L("Literal values")); |
|
1207 |
const TDesC8& t1=KLitTest1_8; |
|
1208 |
test (t1.Length()==1); |
|
1209 |
test (t1[0]=='1'); |
|
1210 |
test (t1==_L8("1")); |
|
1211 |
const TDesC8& t12=KLitTest12_8; |
|
1212 |
test (t12.Length()==2); |
|
1213 |
test (t12[0]=='1'); |
|
1214 |
test (t12==_L8("12")); |
|
1215 |
const TDesC8& t123=KLitTest123_8; |
|
1216 |
test (t123.Length()==3); |
|
1217 |
test (t123[0]=='1'); |
|
1218 |
test (t123==_L8("123")); |
|
1219 |
const TDesC8& t1234=KLitTest1234_8; |
|
1220 |
test (t1234.Length()==4); |
|
1221 |
test (t1234[0]=='1'); |
|
1222 |
test (t1234==_L8("1234")); |
|
1223 |
const TDesC8& talpha=KLitTestalpha_8; |
|
1224 |
test (talpha.Length()==26); |
|
1225 |
test (talpha[0]=='a'); |
|
1226 |
test (talpha==_L8("abcdefghijklmnopqrstuvwxyz")); |
|
1227 |
// |
|
1228 |
test.End(); |
|
1229 |
} |
|
1230 |
||
1231 |
_LIT16(KLitTest1_16,"1"); |
|
1232 |
_LIT16(KLitTest12_16,"12"); |
|
1233 |
_LIT16(KLitTest123_16,"123"); |
|
1234 |
_LIT16(KLitTest1234_16,"1234"); |
|
1235 |
_LIT16(KLitTestalpha_16,"abcdefghijklmnopqrstuvwxyz"); |
|
1236 |
||
1237 |
LOCAL_C const TDesC16& testByRef16(TRefByValue<const TDesC16> aRef) |
|
1238 |
{ |
|
1239 |
return aRef; |
|
1240 |
} |
|
1241 |
||
1242 |
LOCAL_C void testTLitC16() |
|
1243 |
{ |
|
1244 |
test.Start(_L("All members")); |
|
1245 |
test (_L16("")==KNullDesC16); // operator const TDesC16& |
|
1246 |
test (KNullDesC16()==TPtrC16()); // operator() |
|
1247 |
const TDesC16* pNull=&KNullDesC16; // operator& |
|
1248 |
test (pNull->Compare(_L16(""))==0); |
|
1249 |
test (&testByRef16(KNullDesC16)==&KNullDesC16); // operator const TRefByValue<const TDesC16> |
|
1250 |
// |
|
1251 |
test.Next(_L("Literal values")); |
|
1252 |
const TDesC16& t1=KLitTest1_16; |
|
1253 |
test (t1.Length()==1); |
|
1254 |
test (t1[0]=='1'); |
|
1255 |
test (t1==_L16("1")); |
|
1256 |
const TDesC16& t12=KLitTest12_16; |
|
1257 |
test (t12.Length()==2); |
|
1258 |
test (t12[0]=='1'); |
|
1259 |
test (t12==_L16("12")); |
|
1260 |
const TDesC16& t123=KLitTest123_16; |
|
1261 |
test (t123.Length()==3); |
|
1262 |
test (t123[0]=='1'); |
|
1263 |
test (t123==_L16("123")); |
|
1264 |
const TDesC16& t1234=KLitTest1234_16; |
|
1265 |
test (t1234.Length()==4); |
|
1266 |
test (t1234[0]=='1'); |
|
1267 |
test (t1234==_L16("1234")); |
|
1268 |
const TDesC16& talpha=KLitTestalpha_16; |
|
1269 |
test (talpha.Length()==26); |
|
1270 |
test (talpha[0]=='a'); |
|
1271 |
test (talpha==_L16("abcdefghijklmnopqrstuvwxyz")); |
|
1272 |
// |
|
1273 |
test.End(); |
|
1274 |
} |
|
1275 |
||
1276 |
_LIT(KLitTest1,"1"); |
|
1277 |
_LIT(KLitTest12,"12"); |
|
1278 |
_LIT(KLitTest123,"123"); |
|
1279 |
_LIT(KLitTest1234,"1234"); |
|
1280 |
_LIT(KLitTestalpha,"abcdefghijklmnopqrstuvwxyz"); |
|
1281 |
||
1282 |
LOCAL_C const TDesC& testByRef(TRefByValue<const TDesC> aRef) |
|
1283 |
{ |
|
1284 |
return aRef; |
|
1285 |
} |
|
1286 |
||
1287 |
LOCAL_C void testTLitC() |
|
1288 |
{ |
|
1289 |
test.Start(_L("All members")); |
|
1290 |
test (_L("")==KNullDesC); // operator const TDesC& |
|
1291 |
test (KNullDesC()==TPtrC()); // operator() |
|
1292 |
const TDesC* pNull=&KNullDesC; // operator& |
|
1293 |
test (pNull->Compare(_L(""))==0); |
|
1294 |
test (&testByRef(KNullDesC)==&KNullDesC); // operator const TRefByValue<const TDesC> |
|
1295 |
#if defined(_UNICODE) |
|
1296 |
test (_L16("")==KNullDesC); // operator const TDesC& |
|
1297 |
test (KNullDesC()==TPtrC16()); // operator() |
|
1298 |
const TDesC16* pNull16=&KNullDesC; // operator& |
|
1299 |
test (pNull16->Compare(_L16(""))==0); |
|
1300 |
test (&testByRef16(KNullDesC)==&KNullDesC); // operator const TRefByValue<const TDesC> |
|
1301 |
#else |
|
1302 |
test (_L8("")==KNullDesC); // operator const TDesC& |
|
1303 |
test (KNullDesC()==TPtrC8()); // operator() |
|
1304 |
const TDesC8* pNull8=&KNullDesC; // operator& |
|
1305 |
test (pNull8->Compare(_L8(""))==0); |
|
1306 |
test (&testByRef8(KNullDesC)==&KNullDesC); // operator const TRefByValue<const TDesC> |
|
1307 |
#endif |
|
1308 |
// |
|
1309 |
test.Next(_L("Literal values")); |
|
1310 |
const TDesC& t1=KLitTest1; |
|
1311 |
test (t1.Length()==1); |
|
1312 |
test (t1[0]=='1'); |
|
1313 |
test (t1==_L("1")); |
|
1314 |
const TDesC& t12=KLitTest12; |
|
1315 |
test (t12.Length()==2); |
|
1316 |
test (t12[0]=='1'); |
|
1317 |
test (t12==_L("12")); |
|
1318 |
const TDesC& t123=KLitTest123; |
|
1319 |
test (t123.Length()==3); |
|
1320 |
test (t123[0]=='1'); |
|
1321 |
test (t123==_L("123")); |
|
1322 |
const TDesC& t1234=KLitTest1234; |
|
1323 |
test (t1234.Length()==4); |
|
1324 |
test (t1234[0]=='1'); |
|
1325 |
test (t1234==_L("1234")); |
|
1326 |
const TDesC& talpha=KLitTestalpha; |
|
1327 |
test (talpha.Length()==26); |
|
1328 |
test (talpha[0]=='a'); |
|
1329 |
test (talpha==_L("abcdefghijklmnopqrstuvwxyz")); |
|
1330 |
// |
|
1331 |
test.End(); |
|
1332 |
} |
|
1333 |
||
1334 |
LOCAL_C void testLiteral() |
|
1335 |
{ |
|
1336 |
test.Next(_L("class TLitC8")); |
|
1337 |
testTLitC8(); |
|
1338 |
test.Next(_L("class TLitC16")); |
|
1339 |
testTLitC16(); |
|
1340 |
test.Next(_L("class TLitC")); |
|
1341 |
testTLitC(); |
|
1342 |
} |
|
1343 |
||
1344 |
/** |
|
1345 |
@SYMTestCaseID TI18N-TDESC-CIT-4012 |
|
1346 |
@SYMTestCaseDesc Check surrogate function |
|
1347 |
@SYMTestPriority High |
|
1348 |
@SYMTestActions Test Match, Locate, FindCorruptSurrogate, Match2 |
|
1349 |
@SYMTestExpectedResults It works as function specifies |
|
1350 |
@SYMREQ REQ12064, REQ12065 |
|
1351 |
*/ |
|
1352 |
||
1353 |
LOCAL_C void testSurrogateAwareInterfaces() |
|
1354 |
{ |
|
1355 |
test.Next(_L("new TDesC interfaces")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1356 |
TInt count; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1357 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1358 |
// string 1: all BMP characters |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1359 |
_LIT(KBmpString1, "abcdcf"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1360 |
TBuf16<128> s01(KBmpString1); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1361 |
test(s01.FindCorruptSurrogate() == KErrNotFound); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1362 |
test(s01.Locate2('f') == 5); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1363 |
test(s01.LocateReverse2('c') == 4); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1364 |
test(s01.Match(_L("*cdc*")) == 2); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1365 |
test(s01.Match2(_L("*bcdc*")) == 1); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1366 |
test(s01.Match2(_L("*c?c*")) == 2); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1367 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1368 |
// string 2: all non-BMP characters |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1369 |
_LIT(KSurrogateString1, "\xD840\xDDAA\xD840\xDDAB\xD840\xDDAC\xD840\xDDAD\xD840\xDDAE\xD840\xDDAF"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1370 |
TBuf16<128> s02(KSurrogateString1); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1371 |
for (count=0; count<=11; count++) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1372 |
test(s02.FindCorruptSurrogate() == KErrNotFound); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1373 |
test(s02.Locate2(0x201AE) == 8); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1374 |
test(s02.LocateReverse2(0x201AC) == 4); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1375 |
test(s02.Match2(_L("*\xD840\xDDAB\xD840\xDDAC*")) == 2); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1376 |
test(s02.Match2(_L("*\xD840\xDDBB*")) == KErrNotFound); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1377 |
test(s02.Match2(_L("*\xD840\xDDAD*")) == 6); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1378 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1379 |
// string 3: mixed |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1380 |
_LIT(KMixedString1, "ab\xD840\xDDAD e\xD801\xDC27"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1381 |
TBuf16<128> s03(KMixedString1); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1382 |
test(s03.FindCorruptSurrogate() == KErrNotFound); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1383 |
test(s03.Locate2(0x10427) == 6); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1384 |
test(s03.Locate2('e') == 5); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1385 |
test(s03.LocateF2(0x1044F) == 6); // lower case=U+1044F(D801, DC4F), upper case=U+10427(D801, DC27), title case=U+10427 |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1386 |
TBuf16<128> s03a; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1387 |
s03a.CopyLC2(s03); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1388 |
s03a.Append2(0x21000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1389 |
TBuf16<128> s03b; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1390 |
s03b.Copy(s03); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1391 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1392 |
s03b.AppendFill2(0x21000, 2); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1393 |
test(s03a != s03b); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1394 |
test(s03.Match2(_L("*b\xD840\xDDAD*")) == 1); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1395 |
test(s03.Match2(_L("* e*")) == 4); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1396 |
test(s03.Match2(_L("*\xD840\xDDAD?*")) == 2); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1397 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1398 |
// string 4: mixed, with corrupt surrogate |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1399 |
_LIT(KCorruptString1, "ab\xD840\xDDAD e\xDDAD\xD840"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1400 |
TBuf16<128> s04(KCorruptString1); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1401 |
test(s04.FindCorruptSurrogate() == 6); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1402 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1403 |
// string 5: fill |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1404 |
_LIT(KOddString5, "0123456"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1405 |
TBuf16<128> s05(KOddString5); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1406 |
s05.Fill2(0x21000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1407 |
test(s05 == _L("\xD844\xDC00\xD844\xDC00\xD844\xDC00\xD844")); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1408 |
s05.Fill2(' '); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1409 |
test(s05 == _L(" ")); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1410 |
s05.AppendFill2(0x22222, 2); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1411 |
s05.AppendFill2(0x22222, 3); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1412 |
test(s05 == _L(" \xD848\xDE22\xD848\xDE22\xD848")); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1413 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1414 |
// string 6: locate |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1415 |
// from Unicode 5.0, CaseFolding.txt |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1416 |
// 10400; C; 10428; # DESERET CAPITAL LETTER LONG I |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1417 |
// 0x10400's fold is 0x10428 |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1418 |
TCharF f06(0x10400); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1419 |
test(f06 == 0x10428); // just to ensure the property is correct |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1420 |
// 0x10400: D801, DC00 |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1421 |
// 0x10428: D801, DC28 |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1422 |
_LIT(KMixedString6, "ab\xD801\xDC00 e\xD801\xDC27"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1423 |
TBuf16<128> s06(KMixedString6); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1424 |
TInt pos6 = s06.LocateReverseF2(0x10428); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1425 |
test(pos6 == 2); |
0 | 1426 |
} |
1427 |
||
1428 |
||
1429 |
#ifndef _DEBUG |
|
1430 |
#pragma warning (disable: 4702)// Unreachable code |
|
1431 |
#pragma warning (disable: 4701)// Local variable used without being initialized |
|
1432 |
#pragma warning (disable: 4710)// Function not expanded |
|
1433 |
#endif |
|
1434 |
||
1435 |
GLDEF_C TInt E32Main() |
|
1436 |
// |
|
1437 |
// Test the TDes type. |
|
1438 |
// |
|
1439 |
{ |
|
1440 |
test.Title(); |
|
1441 |
// |
|
1442 |
TInt startAvail,temp; |
|
1443 |
startAvail=User::Available(temp); |
|
1444 |
// |
|
1445 |
test.Start(_L("Assigning TPtr's")); |
|
1446 |
testAssignTPtr(); |
|
1447 |
// |
|
1448 |
test.Next(_L("Locate reverse on empty TPtr")); |
|
1449 |
testTPtrLocateReverse(); |
|
1450 |
// |
|
1451 |
test.Next(_L("class TBuf<0x40>")); |
|
1452 |
TestTDes<TBuf<0x40>,TText,TUint, TPtrC> jj; |
|
1453 |
jj.test_TBuf(); |
|
1454 |
jj.testHeapSpace(startAvail); |
|
1455 |
test.End(); |
|
1456 |
// |
|
1457 |
test.Next(_L("class TBuf8<0x40>")); |
|
1458 |
TestTDes<TBuf8<0x40>,TUint8,TUint8, TPtrC8> ii; |
|
1459 |
ii.test_TBuf(); |
|
1460 |
ii.testHeapSpace(startAvail); |
|
1461 |
test.End(); |
|
1462 |
// |
|
1463 |
test.Next(_L("class TBuf16<0x40>")); |
|
1464 |
TestTDes<TBuf16<0x40>,TUint16,TUint16, TPtrC16> hh; |
|
1465 |
hh.test_TBuf(); |
|
1466 |
hh.testHeapSpace(startAvail); |
|
1467 |
test.End(); |
|
1468 |
// |
|
1469 |
test.Next(_L("class TPtrC")); |
|
1470 |
TestTDes<TPtrC,TText,TUint, TPtrC> dd; |
|
1471 |
dd.test_TPtrC(); |
|
1472 |
dd.testHeapSpace(startAvail); |
|
1473 |
test.End(); |
|
1474 |
// |
|
1475 |
test.Next(_L("class TPtrC8")); |
|
1476 |
TestTDes<TPtrC8,TUint8,TUint8, TPtrC8> cc; |
|
1477 |
cc.test_TPtrC(); |
|
1478 |
cc.testHeapSpace(startAvail); |
|
1479 |
test.End(); |
|
1480 |
// |
|
1481 |
test.Next(_L("class TPtrC16")); |
|
1482 |
TestTDes<TPtrC16,TUint16,TUint16, TPtrC16> bb; |
|
1483 |
bb.test_TPtrC(); |
|
1484 |
bb.testHeapSpace(startAvail); |
|
1485 |
test.End(); |
|
1486 |
// |
|
1487 |
test.Next(_L("class TPtr")); |
|
1488 |
TestTDes<TPtr,TText,TUint, TPtrC> gg; |
|
1489 |
gg.test_TPtr(); |
|
1490 |
gg.testHeapSpace(startAvail); |
|
1491 |
test.Next(_L("Copy constructor")); |
|
1492 |
TestCopy(); |
|
1493 |
test.End(); |
|
1494 |
// |
|
1495 |
test.Next(_L("class TPtr8")); |
|
1496 |
TestTDes<TPtr8,TUint8,TUint8, TPtrC8> ff; |
|
1497 |
ff.test_TPtr(); |
|
1498 |
ff.testHeapSpace(startAvail); |
|
1499 |
test.Next(_L("Copy constructor")); |
|
1500 |
TestCopy8(); |
|
1501 |
test.End(); |
|
1502 |
// |
|
1503 |
test.Next(_L("class TPtr16")); |
|
1504 |
TestTDes<TPtr16,TUint16,TUint16, TPtrC16> ee; |
|
1505 |
ee.test_TPtr(); |
|
1506 |
ee.testHeapSpace(startAvail); |
|
1507 |
test.Next(_L("Copy constructor")); |
|
1508 |
TestCopy16(); |
|
1509 |
test.End(); |
|
1510 |
// |
|
1511 |
test.Next(_L("class TBufC")); |
|
1512 |
TestTDes<TBufC<0x40>, TText, TUint16, TPtrC> kk; |
|
1513 |
kk.test_TBufC(); |
|
1514 |
kk.testHeapSpace(startAvail); |
|
1515 |
test.End(); |
|
1516 |
// |
|
1517 |
test.Next(_L("class TBufC8")); |
|
1518 |
TestTDes<TBufC8<0x40>, TUint8, TUint8, TPtrC8> ll; |
|
1519 |
ll.test_TBufC(); |
|
1520 |
ll.testHeapSpace(startAvail); |
|
1521 |
test.End(); |
|
1522 |
// |
|
1523 |
test.Next(_L("class TBufC16")); |
|
1524 |
TestTDes<TBufC16<0x40>, TUint16, TUint16, TPtrC16> mm; |
|
1525 |
mm.test_TBufC(); |
|
1526 |
mm.testHeapSpace(startAvail); |
|
1527 |
test.End(); |
|
1528 |
// |
|
1529 |
test.Next(_L("class HBufC")); |
|
1530 |
TestTDes<HBufC, TText, TUint, TPtrC> nn; |
|
1531 |
nn.test_HBufC(); |
|
1532 |
nn.testHeapSpace(startAvail); |
|
1533 |
test.End(); |
|
1534 |
// |
|
1535 |
test.Next(_L("class HBufC8")); |
|
1536 |
TestTDes<HBufC8, TUint8, TUint8, TPtrC8> oo; |
|
1537 |
oo.test_HBufC(); |
|
1538 |
oo.testHeapSpace(startAvail); |
|
1539 |
test.End(); |
|
1540 |
||
1541 |
test.Next(_L("Test Unicode to Ascii stuff")); |
|
1542 |
Test16To8(); |
|
1543 |
// |
|
1544 |
test.Next(_L("class HBufC16")); |
|
1545 |
TestTDes<HBufC16, TUint16, TUint16, TPtrC16> pp; |
|
1546 |
pp.test_HBufC(); |
|
1547 |
pp.testHeapSpace(startAvail); |
|
1548 |
test.End(); |
|
1549 |
// |
|
1550 |
testLiteral(); |
|
1551 |
// |
|
1552 |
test.Next(_L("class TBuf returning TPtr")); |
|
1553 |
TestTDes<TBuf<0x40>, TText, TUint, TPtr> qq; |
|
1554 |
qq.test_TBufReturningModifiable(); |
|
1555 |
test.End(); |
|
1556 |
||
1557 |
test.Next(_L("class TBuf8 returning TPtr8")); |
|
1558 |
TestTDes<TBuf8<0x40>, TText8, TUint8, TPtr8> rr; |
|
1559 |
rr.test_TBufReturningModifiable(); |
|
1560 |
test.End(); |
|
1561 |
||
1562 |
test.Next(_L("class TBuf16 returning TPtr16")); |
|
1563 |
TestTDes<TBuf16<0x40>, TText16, TUint16, TPtr16> ss; |
|
1564 |
ss.test_TBufReturningModifiable(); |
|
1565 |
test.End(); |
|
1566 |
||
1567 |
test.Next(_L("class TPtr returning TPtr")); |
|
1568 |
TestTDes<TPtr, TText, TUint, TPtr> tt; |
|
1569 |
tt.test_TPtrReturningModifiable(); |
|
1570 |
test.End(); |
|
1571 |
||
1572 |
test.Next(_L("class TPtr8 returning TPtr8")); |
|
1573 |
TestTDes<TPtr8, TText8, TUint8, TPtr8> uu; |
|
1574 |
uu.test_TPtrReturningModifiable(); |
|
1575 |
test.End(); |
|
1576 |
||
1577 |
test.Next(_L("class TPtr16 returning TPtr16")); |
|
1578 |
TestTDes<TPtr16, TText16, TUint16, TPtr16> vv; |
|
1579 |
vv.test_TPtrReturningModifiable(); |
|
1580 |
test.End(); |
|
1581 |
||
1582 |
testSurrogateAwareInterfaces(); |
|
1583 |
test.End(); |
|
1584 |
||
1585 |
return(KErrNone); |
|
1586 |
} |
|
1587 |
#pragma warning (default: 4702)// Unreachable code |
|
1588 |
#pragma warning (default: 4701)// Local variable used without being initialized |
|
1589 |
#pragma warning (default: 4710)// Function not expanded |
|
1590 |
||
1591 |