|
1 // Copyright (c) 2004-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_rbuf.cpp |
|
15 // Overview: |
|
16 // Test methods of the RBuf16, RBuf8, RBuf template class. |
|
17 // API Information: |
|
18 // RBuf16, RBuf8, RBuf. |
|
19 // Details: |
|
20 // For RBuf8, RBuf16 and RBuf objects: |
|
21 // - Test the Create and CreateMax methods by verifying the return value of |
|
22 // KErrNone, the initial length and max length. Perform basic write and read |
|
23 // operations and verify the results. |
|
24 // - Test the CreateL and CreateMaxL methods by verifying the return value of |
|
25 // KErrNone. Also force a heap error and verify return value of KErrNoMemory. |
|
26 // - Test the Create(const TDesC_& aDesc) and Create(const TDesCX_ aDesc, |
|
27 // TInt aMaxLength) methods by verifying the return value of KErrNone. Verify |
|
28 // initial length, max length and initialisation. |
|
29 // - Test the CreateL(const TDesC_& aDesc) and CreateMaxL(const TDesCX_ aDesc, |
|
30 // TInt aMaxLength) methods by verifying the return value of KErrNone. Also |
|
31 // force a heap error and verify return value of KErrNoMemory. |
|
32 // - Test the Swap method by creating two initialised objects, calling Swap |
|
33 // and confirming the results as expected. |
|
34 // - Test the Assign method by performing an assign from a variety of sources |
|
35 // and verifying the results are as expected. |
|
36 // - Test the ReAlloc method in a variety of scenarios that decrease memory, |
|
37 // increase memory and zero-length memory. Verify that the results are as |
|
38 // expected. |
|
39 // - Test the ReAllocL by verifying the return value of KErrNone. Also force |
|
40 // a heap error and verify return value of KErrNoMemory. Verify that the |
|
41 // object is the same as before the failed ReAllocL call. |
|
42 // - Test the CleanupClosePushL method via CleanupStack::PopAndDestroy(). |
|
43 // - Force the CleanupClosePushL to leave to check cleanup of RBuf. |
|
44 // Platforms/Drives/Compatibility: |
|
45 // All |
|
46 // Assumptions/Requirement/Pre-requisites: |
|
47 // Failures and causes: |
|
48 // Base Port information: |
|
49 // |
|
50 // |
|
51 |
|
52 #include <e32test.h> |
|
53 #include <e32math.h> |
|
54 #include "u32std.h" |
|
55 |
|
56 LOCAL_D RTest test(_L("T_RBUF")); |
|
57 |
|
58 #undef _TS |
|
59 #define _TS(a) ((const TTEXT*)RTest::String(sizeof(TTEXT),(TText8*)a,(TText16*)L ## a)) |
|
60 |
|
61 /** |
|
62 Tests the following methods. |
|
63 - TInt Create(TInt aMaxLength); |
|
64 - TInt CreateMax(TInt aMaxLength); |
|
65 */ |
|
66 template<class RBUF> |
|
67 LOCAL_C void TestCreate(RBUF*) |
|
68 { |
|
69 RBUF rBuf; |
|
70 |
|
71 test.Next(_L("Create(TInt aMaxLength) method")); |
|
72 |
|
73 test(rBuf.Create(19)==KErrNone); //Create RBuf as EPtr type |
|
74 test(rBuf.Length()==0); |
|
75 test(rBuf.MaxLength()==19); |
|
76 rBuf.SetLength(2); |
|
77 rBuf[1] = 1; //Try basic write & ... |
|
78 test(rBuf[1] == 1); //... read |
|
79 rBuf.Close(); |
|
80 |
|
81 test(rBuf.Create(0)==KErrNone); //Create zero length RBuf as EPtr type |
|
82 test(rBuf.Length()==0); |
|
83 test(rBuf.MaxLength()==0); |
|
84 rBuf.Close(); |
|
85 |
|
86 test.Next(_L("CreateMax(TInt aMaxLength) method")); |
|
87 |
|
88 test(rBuf.CreateMax(20)==KErrNone); //Create RBuf as EPtr type |
|
89 test(rBuf.Length()==20); |
|
90 test(rBuf.MaxLength()==20); |
|
91 rBuf[1] = 1; |
|
92 test(rBuf[1] == 1); |
|
93 rBuf.Close(); |
|
94 } |
|
95 |
|
96 /** |
|
97 Tests the following methods. |
|
98 - void CreateL(TInt aMaxLength); |
|
99 - void CreateMaxL(TInt aMaxLength); |
|
100 */ |
|
101 template<class RBUF> |
|
102 LOCAL_C void TestCreateLeaving(RBUF*) |
|
103 { |
|
104 RBUF rBuf; |
|
105 |
|
106 test.Next(_L("CreateL(TInt aMaxLength) method")); |
|
107 |
|
108 TRAPD(ret, rBuf.CreateL(20)); //Create RBuf as EPtr type |
|
109 test(KErrNone == ret); |
|
110 rBuf.Close(); |
|
111 |
|
112 #if defined(_DEBUG) |
|
113 __UHEAP_FAILNEXT(1); //Set the next alloc to fail |
|
114 TRAP(ret, rBuf.CreateL(10)); |
|
115 test(KErrNoMemory == ret); // It fails due to __UHEAP_FAILNEXT(1); |
|
116 #endif //_DEBUG |
|
117 |
|
118 test.Next(_L("CreateMaxL(TInt aMaxLength) method")); |
|
119 |
|
120 TRAP(ret, rBuf.CreateMaxL(20)); //Create RBuf as EPtr type |
|
121 test(KErrNone == ret); |
|
122 rBuf.Close(); |
|
123 |
|
124 #if defined(_DEBUG) |
|
125 __UHEAP_FAILNEXT(1); //Set the next alloc to fail |
|
126 TRAP(ret, rBuf.CreateMaxL(10)); |
|
127 test(KErrNoMemory == ret); // It fails due to __UHEAP_FAILNEXT(1); |
|
128 #endif //_DEBUG |
|
129 } |
|
130 |
|
131 /** |
|
132 Tests the following methods. |
|
133 - TInt Create(const TDesC_& aDesc); |
|
134 - TInt Create(const TDesC_& aDesc, TInt aMaxLength)); |
|
135 */ |
|
136 template<class RBUF, class TBUF, class TTEXT> |
|
137 LOCAL_C void TestCreateFromDes(RBUF*) |
|
138 { |
|
139 RBUF rBuf; |
|
140 TBUF des (_TS("012345")); |
|
141 |
|
142 test.Next(_L("Create(const TDesC_& aDesc) method")); |
|
143 |
|
144 test(rBuf.Create(des)==KErrNone); //Create RBuf as EPtr type |
|
145 test(rBuf == des); |
|
146 rBuf.Close(); |
|
147 |
|
148 test.Next(_L("Create(const TDesCX_ aDesc, TInt aMaxLength) method")); |
|
149 |
|
150 test(rBuf.Create(des, des.Length())==KErrNone); //Create RBuf as EPtr type |
|
151 test(rBuf==des); |
|
152 rBuf.Close(); |
|
153 |
|
154 test(rBuf.Create(des, des.Length()-2)==KErrNone); //Create RBuf as EPtr type |
|
155 test(rBuf.Length()==4); |
|
156 test(rBuf.MaxLength()==4); |
|
157 test(rBuf[0] == (TTEXT)('0')); |
|
158 test(rBuf[3] == (TTEXT)('3')); |
|
159 test(rBuf<des); |
|
160 rBuf.Close(); |
|
161 |
|
162 test(rBuf.Create(des, des.Length()+2)==KErrNone); //Create RBuf as EPtr type |
|
163 test(rBuf.Length()==6); |
|
164 test(rBuf.MaxLength()==8); |
|
165 test(rBuf==des); |
|
166 rBuf.Close(); |
|
167 } |
|
168 |
|
169 /** |
|
170 Tests the following methods. |
|
171 - void CreateL(const TDesC_& aDesc); |
|
172 - void CreateMaxL(const TDesC_& aDesc, TInt aMaxLength); |
|
173 */ |
|
174 template<class RBUF, class TBUF, class TTEXT> |
|
175 LOCAL_C void TestCreateFromDesLeaving(RBUF*) |
|
176 { |
|
177 RBUF rBuf; |
|
178 TBUF des (_TS("123456")); |
|
179 |
|
180 test.Next(_L("CreateL(const TDesC_& aDesc) method")); |
|
181 |
|
182 TRAPD(ret, rBuf.CreateL(des)); //Create RBuf as EPtr type |
|
183 test(KErrNone == ret); |
|
184 rBuf.Close(); |
|
185 |
|
186 #if defined(_DEBUG) |
|
187 __UHEAP_FAILNEXT(1); //Set the next alloc to fail |
|
188 TRAP(ret, rBuf.CreateL(des)); |
|
189 test(KErrNoMemory == ret); // This will fail due to __UHEAP_FAILNEXT(1); |
|
190 #endif //(_DEBUG) |
|
191 |
|
192 test.Next(_L("CreateL(const TDesC_& aDesc, TInt aMaxLength) method")); |
|
193 |
|
194 TRAP(ret, rBuf.CreateL(des, des.Length())); //Create RBuf as EPtr type |
|
195 test(KErrNone == ret); |
|
196 rBuf.Close(); |
|
197 |
|
198 #if defined(_DEBUG) |
|
199 __UHEAP_FAILNEXT(1); //Set the next alloc to fail |
|
200 TRAP(ret, rBuf.CreateL(des, des.Length())); |
|
201 test(KErrNoMemory == ret); // It fails due to __UHEAP_FAILNEXT(1); |
|
202 #endif //(_DEBUG) |
|
203 } |
|
204 |
|
205 /** |
|
206 Tests the following methods: |
|
207 - TInt Assign(const RBuf_& rBuf); |
|
208 - TInt Assign(TUint* aHeapCell, TInt aMaxLength); |
|
209 - TInt Assign(TUint* aHeapCell, TInt aLength, TInt aMaxLength); |
|
210 - TInt Assign(HBufC& aHBuf); |
|
211 - RBuf(HBufC_&) constructor. |
|
212 */ |
|
213 template<class RBUF, class TBUF, class TTEXT, class HBUF> |
|
214 LOCAL_C void TestAssign(RBUF*) |
|
215 { |
|
216 RBUF rBuf; |
|
217 TBUF des (_TS("123456")); |
|
218 RBUF rBuf2; |
|
219 |
|
220 test.Next(_L("Assign(const RBuf_& aRBuf) method")); |
|
221 |
|
222 rBuf2.Create(des); |
|
223 rBuf.Assign(rBuf2); |
|
224 test(rBuf==rBuf2); |
|
225 rBuf.Close(); |
|
226 |
|
227 test.Next(_L("Assign(TUint* aHeapCell, TInt aLength, TInt aMaxLength ) method")); |
|
228 |
|
229 TTEXT* heap = (TTEXT*)User::Alloc(24*(TInt)sizeof(TTEXT)); //Allocate 48 bytes for 24 long RBuf16 |
|
230 rBuf.Assign(heap, 12,24); |
|
231 test(rBuf.Length() == 12); |
|
232 test(rBuf.MaxLength() == 24); |
|
233 rBuf.Close(); |
|
234 |
|
235 heap = NULL; |
|
236 rBuf.Assign(heap, 0,0); |
|
237 test(rBuf.Length() == 0); |
|
238 test(rBuf.MaxLength() == 0); |
|
239 rBuf.Close(); |
|
240 |
|
241 test.Next(_L("Assign(TUint* aHeapCell, TInt aMaxLength ) method")); |
|
242 |
|
243 heap = (TTEXT*)User::Alloc(24*(TInt)sizeof(TTEXT)); //Allocate 48 bytes for 24 long RBuf16 |
|
244 rBuf.Assign(heap, 24); |
|
245 test(rBuf.Length() == 0); |
|
246 test(rBuf.MaxLength() == 24); |
|
247 rBuf.Close(); |
|
248 |
|
249 test.Next(_L("Assign(HBufC_* aHBuf) method")); |
|
250 |
|
251 HBUF* hBuf = HBUF::NewMax(11); |
|
252 rBuf.Assign(hBuf); //Create RBuf as EBufCPtr type |
|
253 test(rBuf.Length() == 11); |
|
254 test(rBuf.MaxLength() >= 11); //There could me more allocated memory - see HBufC8::Des() |
|
255 rBuf.Close(); |
|
256 |
|
257 test.Next(_L("RBuf_(HBufC_* aHBuf) constructor")); |
|
258 |
|
259 hBuf = HBUF::NewMax(12); //Create RBuf as EBufCPtr |
|
260 RBUF rBuf3(hBuf); |
|
261 test(rBuf3.Length() == 12); |
|
262 test(rBuf3.MaxLength() >= 12); |
|
263 rBuf3.Close(); |
|
264 |
|
265 hBuf = HBUF::NewMax(0); |
|
266 RBUF rBuf4(hBuf); //The length of aHBuf is zero |
|
267 test(rBuf4.Length() == 0); |
|
268 rBuf4.Close(); |
|
269 |
|
270 hBuf = NULL; //aHBuf is NULL |
|
271 RBUF rBuf5(hBuf); |
|
272 test(rBuf5.Length() == 0); |
|
273 test(rBuf5.MaxLength() == 0); |
|
274 rBuf5.Close(); |
|
275 } |
|
276 |
|
277 /** |
|
278 Tests the following methods. |
|
279 - TInt ReAlloc(TInt aMaxLength); |
|
280 */ |
|
281 template<class RBUF, class TBUF, class TTEXT, class HBUF> |
|
282 LOCAL_C void TestReAlloc(RBUF*) |
|
283 { |
|
284 RBUF rBuf; |
|
285 |
|
286 TBUF des (_TS("0123456")); |
|
287 |
|
288 |
|
289 test.Next(_L("ReAlloc(TInt aMaxLength) method")); |
|
290 |
|
291 //reallocate EPtr type - decrease memory |
|
292 test(rBuf.Create(des)==KErrNone); //Create as EPtr |
|
293 rBuf.SetLength(3); |
|
294 test(rBuf.ReAlloc(3)==KErrNone); //ReAlloc to EPtr |
|
295 test(rBuf.MaxLength()>=3); |
|
296 test(rBuf.Length()==3); |
|
297 test(rBuf[0] == (TTEXT)('0')); |
|
298 test(rBuf[2] == (TTEXT)('2')); |
|
299 rBuf.Close(); |
|
300 |
|
301 //reallocate EPtr type - increase memory |
|
302 test(rBuf.Create(des,des.MaxLength())==KErrNone); //Create as EPtr |
|
303 test(rBuf.ReAlloc(15)==KErrNone); //ReAlloc to EPtr |
|
304 test(rBuf.MaxLength()==15); |
|
305 test(rBuf.Length()==7); |
|
306 test(rBuf[0] == (TTEXT)('0')); |
|
307 test(rBuf[6] == (TTEXT)('6')); |
|
308 rBuf.Close(); |
|
309 |
|
310 |
|
311 //reallocate EBufCPtr type - decrease memory |
|
312 HBUF* hBuf = HBUF::NewMax(9); |
|
313 *hBuf = _TS("012345678"); |
|
314 rBuf.Assign(hBuf); //Create as EBufCPtr |
|
315 rBuf.SetLength(5); |
|
316 test(rBuf.ReAlloc(5)==KErrNone); //ReAlloc to EBufCPtr |
|
317 test(rBuf.MaxLength()>=5);//There could be more allocated memory - see HBufC8::Des() |
|
318 test(rBuf.Length()==5); |
|
319 test(rBuf[0] == (TTEXT)('0')); |
|
320 test(rBuf[4] == (TTEXT)('4')); |
|
321 rBuf.Close(); |
|
322 |
|
323 //reallocate EBufCPtr type - increase memory |
|
324 hBuf = HBUF::NewMax(9); |
|
325 *hBuf = _TS("012345678"); |
|
326 rBuf.Assign(hBuf); //Create as EBufCPtr |
|
327 test(rBuf.ReAlloc(15)==KErrNone); //ReAlloc to EBufCPtr |
|
328 test(rBuf.MaxLength()>=15);//There could be more allocated memory - see HBufC8::Des() |
|
329 test(rBuf.Length()==9); |
|
330 test(rBuf[0] == (TTEXT)('0')); |
|
331 test(rBuf[8] == (TTEXT)('8')); |
|
332 rBuf.Close(); |
|
333 |
|
334 //reallocate EPtr type - to zero-length |
|
335 test(rBuf.Create(des)==KErrNone); //Create as EPtr |
|
336 rBuf.SetLength(0); |
|
337 test(rBuf.ReAlloc(0)==KErrNone); //ReAlloc to EPtr |
|
338 test(rBuf.MaxLength()==0); |
|
339 test(rBuf.Length()==0); |
|
340 rBuf.Close(); |
|
341 |
|
342 //reallocate EBufCPtr type to zero-length |
|
343 hBuf = HBUF::NewMax(9); |
|
344 *hBuf = _TS("012345678"); |
|
345 rBuf.Assign(hBuf); //Create as EBufCPtr |
|
346 rBuf.SetLength(0); |
|
347 test(rBuf.ReAlloc(0)==KErrNone); //ReAlloc to EPtr |
|
348 test(rBuf.MaxLength()==0); |
|
349 test(rBuf.Length()==0); |
|
350 rBuf.Close(); |
|
351 |
|
352 //reallocate from zero-length |
|
353 rBuf.Create(0); //Create as EPtr |
|
354 test(rBuf.ReAlloc(9)==KErrNone); //ReAlloc to EPtr |
|
355 test(rBuf.MaxLength()==9); |
|
356 test(rBuf.Length()==0); |
|
357 rBuf.Close(); |
|
358 |
|
359 //reallocate from zero-length EBufCPtr to EPtr |
|
360 struct dummy // make it look like RBuf16 |
|
361 { |
|
362 TInt iLength; |
|
363 TInt iMaxLength; |
|
364 HBUF* iEBufCPtrType; //Pointer to buffer data |
|
365 }; |
|
366 |
|
367 // reference rBuf as our dummy.. |
|
368 dummy &drBuf = (dummy&) rBuf; |
|
369 rBuf.Assign(HBUF::NewL(0)); //Create as EBufCPtr |
|
370 test(EBufCPtr == (drBuf.iLength>>KShiftDesType)); |
|
371 rBuf.Close(); // the actual behavior causes memory leaks, so we should close it first. |
|
372 test(rBuf.ReAlloc(13)==KErrNone); // ReAlloc changes it from EBufCPtr to EPtr |
|
373 test(EPtr == (drBuf.iLength>>KShiftDesType)); |
|
374 test(rBuf.MaxLength() == 13); |
|
375 test(rBuf.Length() == 0); |
|
376 rBuf.Close(); |
|
377 |
|
378 //reallocate from zero-length to zero-length |
|
379 rBuf.Create(0); //Create as EPtr |
|
380 test(rBuf.ReAlloc(0)==KErrNone); //ReAlloc to EPtr |
|
381 test(rBuf.Length() == 0); |
|
382 test(rBuf.MaxLength() == 0); |
|
383 rBuf.Close(); |
|
384 |
|
385 } |
|
386 |
|
387 /** |
|
388 Tests the following methods. |
|
389 - TInt ReAllocL(TInt aMaxLength); |
|
390 */ |
|
391 template<class RBUF, class TBUF, class TTEXT> |
|
392 LOCAL_C void TestReAllocLeaving(RBUF*) |
|
393 { |
|
394 RBUF rBuf; |
|
395 |
|
396 TBUF des(_TS("01")); |
|
397 |
|
398 test.Next(_L("ReAllocL(TInt aMaxLength) method")); |
|
399 |
|
400 test(rBuf.Create(des) ==KErrNone); |
|
401 TRAPD(ret, rBuf.ReAllocL(6)); //ReAlloc buffer |
|
402 test(KErrNone == ret); |
|
403 |
|
404 #if defined(_DEBUG) |
|
405 __UHEAP_FAILNEXT(1); |
|
406 TRAP(ret, rBuf.ReAllocL(100)); //Realloc buffer. This should fail. |
|
407 test(KErrNoMemory == ret); |
|
408 #endif //(_DEBUG) |
|
409 |
|
410 test(rBuf.MaxLength()==6); //Check RBuf is the same as before ... |
|
411 test(rBuf.Length()==2); //... ReAlloc that failed. |
|
412 test(rBuf[0] == (TTEXT)('0')); |
|
413 test(rBuf[1] == (TTEXT)('1')); |
|
414 rBuf.Close(); |
|
415 } |
|
416 |
|
417 /** |
|
418 Tests the following methods. |
|
419 - void Swap(RBuf_& aBuf); |
|
420 */ |
|
421 template<class RBUF, class TBUF, class TTEXT> |
|
422 LOCAL_C void TestSwap(RBUF*) |
|
423 { |
|
424 RBUF rBuf1, rBuf2; |
|
425 TBUF des1(_TS("12")); |
|
426 TBUF des2 (_TS("345678")); |
|
427 |
|
428 test.Next(_L("Swap(RBuf_& aRBuf) method")); |
|
429 |
|
430 test(rBuf1.Create(des1) ==KErrNone); |
|
431 test(rBuf2.Create(des2) ==KErrNone); |
|
432 |
|
433 rBuf1.Swap(rBuf2); |
|
434 |
|
435 test(rBuf1==des2); |
|
436 test(rBuf2==des1); |
|
437 |
|
438 rBuf1.Close(); |
|
439 rBuf2.Close(); |
|
440 } |
|
441 |
|
442 /** |
|
443 Test assignemnt operator. |
|
444 */ |
|
445 template<class RBUF, class TBUF, class TBUFC, class TTEXT> |
|
446 LOCAL_C void TestAssignmentOperator() |
|
447 { |
|
448 test.Next(_L("Assignment operator")); |
|
449 |
|
450 TBUF tdes(_TS("Modifiable descriptor")); |
|
451 TBUFC tdesc(_TS("Non-modifiable descriptor")); |
|
452 |
|
453 RBUF rbuf, rbuf2; |
|
454 rbuf.Create(32); |
|
455 rbuf2.Create(32); |
|
456 rbuf2.Copy(_TS("Buffer descriptor"), 17); |
|
457 |
|
458 rbuf = tdesc; test(rbuf == tdesc); |
|
459 rbuf = tdes; test(rbuf == tdes); |
|
460 rbuf = rbuf2; test(rbuf == rbuf2); |
|
461 |
|
462 rbuf2.Close(); |
|
463 rbuf.Close(); |
|
464 } |
|
465 |
|
466 /** |
|
467 Tests the following methods. |
|
468 - void CleanupClosePushL(); |
|
469 */ |
|
470 template<class RBUF> LOCAL_C void TestCleanupClosePushL(RBUF*) |
|
471 { |
|
472 RBUF rBuf; |
|
473 |
|
474 test.Next(_L("CleanupClosePushL() method")); |
|
475 test(KErrNone == rBuf.Create(10)); |
|
476 rBuf.CleanupClosePushL(); |
|
477 CleanupStack::PopAndDestroy(); |
|
478 } |
|
479 |
|
480 /** |
|
481 This function will intentionally leave to check cleanup of RBuf. |
|
482 To be called in debug build only. Otherwise will panic. |
|
483 */ |
|
484 template<class RBUF> LOCAL_C void TestRBufCleanupL(RBUF*) |
|
485 { |
|
486 RBUF rBuf; |
|
487 |
|
488 test.Next(_L("Test cleanup of RBuf")); |
|
489 test(KErrNone == rBuf.Create(10)); |
|
490 rBuf.CleanupClosePushL(); |
|
491 |
|
492 __UHEAP_FAILNEXT(1); |
|
493 TInt* ptr = (TInt*)User::AllocL(20); //This should leave |
|
494 *ptr = 0; //Avoid compiler warning |
|
495 User::Panic(_L("Should not reach this line"),0); |
|
496 } |
|
497 |
|
498 GLDEF_C TInt E32Main() |
|
499 { |
|
500 RBuf8* r8=0; |
|
501 RBuf16* r16=0; |
|
502 RBuf* r=0; |
|
503 |
|
504 CTrapCleanup* trapHandler=CTrapCleanup::New(); |
|
505 test(trapHandler!=NULL); |
|
506 |
|
507 test.Title(); |
|
508 test.Start(_L("Testing RBuf8, RBuf16 & RBuf classes")); |
|
509 |
|
510 __UHEAP_MARK; |
|
511 |
|
512 test.Start(_L("Testing class RBuf8 ...")); |
|
513 TestCreate<RBuf8>(r8); |
|
514 TestCreateLeaving<RBuf8>(r8); |
|
515 TestCreateFromDes<RBuf8,TBuf8<11>,TText8>(r8); |
|
516 TestCreateFromDesLeaving<RBuf8,TBuf8<11>,TText8>(r8); |
|
517 TestSwap<RBuf8,TBuf8<11>,TText8>(r8); |
|
518 TestAssign<RBuf8,TBuf8<11>,TText8,HBufC8>(r8); |
|
519 TestReAlloc<RBuf8,TBuf8<11>,TText8,HBufC8>(r8); |
|
520 TestReAllocLeaving<RBuf8,TBuf8<11>,TText8>(r8); |
|
521 TestAssignmentOperator<RBuf8,TBuf8<32>,TBufC8<32>,TText8>(); |
|
522 TRAPD(ret,TestCleanupClosePushL<RBuf8>(r8)); test(ret==KErrNone); |
|
523 #if defined(_DEBUG) |
|
524 TRAP(ret, TestRBufCleanupL<RBuf8>(r8)); test(KErrNoMemory == ret); |
|
525 #endif //(_DEBUG) |
|
526 test.End(); |
|
527 |
|
528 test.Start(_L("Testing class RBuf16 ...")); |
|
529 TestCreate<RBuf16>(r16); |
|
530 TestCreateLeaving<RBuf16>(r16); |
|
531 TestCreateFromDes<RBuf16,TBuf16<11>,TText16>(r16); |
|
532 TestCreateFromDesLeaving<RBuf16,TBuf16<11>,TText16>(r16); |
|
533 TestSwap<RBuf16,TBuf16<11>,TText16>(r16); |
|
534 TestAssign<RBuf16,TBuf16<11>,TText16,HBufC16>(r16); |
|
535 TestReAlloc<RBuf16,TBuf16<11>,TText16,HBufC16>(r16); |
|
536 TestReAllocLeaving<RBuf16,TBuf16<11>,TText16>(r16); |
|
537 TestAssignmentOperator<RBuf16,TBuf16<32>,TBufC16<32>,TText16>(); |
|
538 TRAP(ret,TestCleanupClosePushL<RBuf16>(r16)); test(ret==KErrNone); |
|
539 #if defined(_DEBUG) |
|
540 TRAP(ret, TestRBufCleanupL<RBuf16>(r16)); test(KErrNoMemory == ret); |
|
541 #endif //(_DEBUG) |
|
542 test.End(); |
|
543 |
|
544 test.Start(_L("Testing class RBuf ...")); |
|
545 TestCreate<RBuf>(r); |
|
546 TestCreateLeaving<RBuf>(r); |
|
547 TestCreateFromDes<RBuf,TBuf<11>,TText>(r); |
|
548 TestCreateFromDesLeaving<RBuf,TBuf<11>,TText>(r); |
|
549 TestSwap<RBuf,TBuf<11>,TText>(r); |
|
550 TestAssign<RBuf,TBuf<11>,TText,HBufC>(r); |
|
551 TestReAlloc<RBuf,TBuf<11>,TText,HBufC>(r); |
|
552 TestReAllocLeaving<RBuf,TBuf<11>,TText>(r); |
|
553 TestAssignmentOperator<RBuf,TBuf<32>,TBufC<32>,TText>(); |
|
554 TRAP(ret,TestCleanupClosePushL<RBuf>(r)); test(ret==KErrNone); |
|
555 #if defined(_DEBUG) |
|
556 TRAP(ret, TestRBufCleanupL<RBuf>(r)); test(KErrNoMemory == ret); |
|
557 #endif //(_DEBUG) |
|
558 test.End(); |
|
559 |
|
560 __UHEAP_MARKEND; |
|
561 |
|
562 test.End(); |
|
563 |
|
564 delete trapHandler; |
|
565 return(KErrNone); |
|
566 } |
|
567 |