1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/buffer/t_rbuf.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,567 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\buffer\t_rbuf.cpp
1.18 +// Overview:
1.19 +// Test methods of the RBuf16, RBuf8, RBuf template class.
1.20 +// API Information:
1.21 +// RBuf16, RBuf8, RBuf.
1.22 +// Details:
1.23 +// For RBuf8, RBuf16 and RBuf objects:
1.24 +// - Test the Create and CreateMax methods by verifying the return value of
1.25 +// KErrNone, the initial length and max length. Perform basic write and read
1.26 +// operations and verify the results.
1.27 +// - Test the CreateL and CreateMaxL methods by verifying the return value of
1.28 +// KErrNone. Also force a heap error and verify return value of KErrNoMemory.
1.29 +// - Test the Create(const TDesC_& aDesc) and Create(const TDesCX_ aDesc,
1.30 +// TInt aMaxLength) methods by verifying the return value of KErrNone. Verify
1.31 +// initial length, max length and initialisation.
1.32 +// - Test the CreateL(const TDesC_& aDesc) and CreateMaxL(const TDesCX_ aDesc,
1.33 +// TInt aMaxLength) methods by verifying the return value of KErrNone. Also
1.34 +// force a heap error and verify return value of KErrNoMemory.
1.35 +// - Test the Swap method by creating two initialised objects, calling Swap
1.36 +// and confirming the results as expected.
1.37 +// - Test the Assign method by performing an assign from a variety of sources
1.38 +// and verifying the results are as expected.
1.39 +// - Test the ReAlloc method in a variety of scenarios that decrease memory,
1.40 +// increase memory and zero-length memory. Verify that the results are as
1.41 +// expected.
1.42 +// - Test the ReAllocL by verifying the return value of KErrNone. Also force
1.43 +// a heap error and verify return value of KErrNoMemory. Verify that the
1.44 +// object is the same as before the failed ReAllocL call.
1.45 +// - Test the CleanupClosePushL method via CleanupStack::PopAndDestroy().
1.46 +// - Force the CleanupClosePushL to leave to check cleanup of RBuf.
1.47 +// Platforms/Drives/Compatibility:
1.48 +// All
1.49 +// Assumptions/Requirement/Pre-requisites:
1.50 +// Failures and causes:
1.51 +// Base Port information:
1.52 +//
1.53 +//
1.54 +
1.55 +#include <e32test.h>
1.56 +#include <e32math.h>
1.57 +#include "u32std.h"
1.58 +
1.59 +LOCAL_D RTest test(_L("T_RBUF"));
1.60 +
1.61 +#undef _TS
1.62 +#define _TS(a) ((const TTEXT*)RTest::String(sizeof(TTEXT),(TText8*)a,(TText16*)L ## a))
1.63 +
1.64 +/**
1.65 +Tests the following methods.
1.66 + - TInt Create(TInt aMaxLength);
1.67 + - TInt CreateMax(TInt aMaxLength);
1.68 +*/
1.69 +template<class RBUF>
1.70 +LOCAL_C void TestCreate(RBUF*)
1.71 +{
1.72 + RBUF rBuf;
1.73 +
1.74 + test.Next(_L("Create(TInt aMaxLength) method"));
1.75 +
1.76 + test(rBuf.Create(19)==KErrNone); //Create RBuf as EPtr type
1.77 + test(rBuf.Length()==0);
1.78 + test(rBuf.MaxLength()==19);
1.79 + rBuf.SetLength(2);
1.80 + rBuf[1] = 1; //Try basic write & ...
1.81 + test(rBuf[1] == 1); //... read
1.82 + rBuf.Close();
1.83 +
1.84 + test(rBuf.Create(0)==KErrNone); //Create zero length RBuf as EPtr type
1.85 + test(rBuf.Length()==0);
1.86 + test(rBuf.MaxLength()==0);
1.87 + rBuf.Close();
1.88 +
1.89 + test.Next(_L("CreateMax(TInt aMaxLength) method"));
1.90 +
1.91 + test(rBuf.CreateMax(20)==KErrNone); //Create RBuf as EPtr type
1.92 + test(rBuf.Length()==20);
1.93 + test(rBuf.MaxLength()==20);
1.94 + rBuf[1] = 1;
1.95 + test(rBuf[1] == 1);
1.96 + rBuf.Close();
1.97 +}
1.98 +
1.99 +/**
1.100 +Tests the following methods.
1.101 + - void CreateL(TInt aMaxLength);
1.102 + - void CreateMaxL(TInt aMaxLength);
1.103 +*/
1.104 +template<class RBUF>
1.105 +LOCAL_C void TestCreateLeaving(RBUF*)
1.106 +{
1.107 + RBUF rBuf;
1.108 +
1.109 + test.Next(_L("CreateL(TInt aMaxLength) method"));
1.110 +
1.111 + TRAPD(ret, rBuf.CreateL(20)); //Create RBuf as EPtr type
1.112 + test(KErrNone == ret);
1.113 + rBuf.Close();
1.114 +
1.115 +#if defined(_DEBUG)
1.116 + __UHEAP_FAILNEXT(1); //Set the next alloc to fail
1.117 + TRAP(ret, rBuf.CreateL(10));
1.118 + test(KErrNoMemory == ret); // It fails due to __UHEAP_FAILNEXT(1);
1.119 +#endif //_DEBUG
1.120 +
1.121 + test.Next(_L("CreateMaxL(TInt aMaxLength) method"));
1.122 +
1.123 + TRAP(ret, rBuf.CreateMaxL(20)); //Create RBuf as EPtr type
1.124 + test(KErrNone == ret);
1.125 + rBuf.Close();
1.126 +
1.127 +#if defined(_DEBUG)
1.128 + __UHEAP_FAILNEXT(1); //Set the next alloc to fail
1.129 + TRAP(ret, rBuf.CreateMaxL(10));
1.130 + test(KErrNoMemory == ret); // It fails due to __UHEAP_FAILNEXT(1);
1.131 +#endif //_DEBUG
1.132 +}
1.133 +
1.134 +/**
1.135 +Tests the following methods.
1.136 + - TInt Create(const TDesC_& aDesc);
1.137 + - TInt Create(const TDesC_& aDesc, TInt aMaxLength));
1.138 +*/
1.139 +template<class RBUF, class TBUF, class TTEXT>
1.140 +LOCAL_C void TestCreateFromDes(RBUF*)
1.141 +{
1.142 + RBUF rBuf;
1.143 + TBUF des (_TS("012345"));
1.144 +
1.145 + test.Next(_L("Create(const TDesC_& aDesc) method"));
1.146 +
1.147 + test(rBuf.Create(des)==KErrNone); //Create RBuf as EPtr type
1.148 + test(rBuf == des);
1.149 + rBuf.Close();
1.150 +
1.151 + test.Next(_L("Create(const TDesCX_ aDesc, TInt aMaxLength) method"));
1.152 +
1.153 + test(rBuf.Create(des, des.Length())==KErrNone); //Create RBuf as EPtr type
1.154 + test(rBuf==des);
1.155 + rBuf.Close();
1.156 +
1.157 + test(rBuf.Create(des, des.Length()-2)==KErrNone); //Create RBuf as EPtr type
1.158 + test(rBuf.Length()==4);
1.159 + test(rBuf.MaxLength()==4);
1.160 + test(rBuf[0] == (TTEXT)('0'));
1.161 + test(rBuf[3] == (TTEXT)('3'));
1.162 + test(rBuf<des);
1.163 + rBuf.Close();
1.164 +
1.165 + test(rBuf.Create(des, des.Length()+2)==KErrNone); //Create RBuf as EPtr type
1.166 + test(rBuf.Length()==6);
1.167 + test(rBuf.MaxLength()==8);
1.168 + test(rBuf==des);
1.169 + rBuf.Close();
1.170 +}
1.171 +
1.172 +/**
1.173 +Tests the following methods.
1.174 + - void CreateL(const TDesC_& aDesc);
1.175 + - void CreateMaxL(const TDesC_& aDesc, TInt aMaxLength);
1.176 +*/
1.177 +template<class RBUF, class TBUF, class TTEXT>
1.178 +LOCAL_C void TestCreateFromDesLeaving(RBUF*)
1.179 +{
1.180 + RBUF rBuf;
1.181 + TBUF des (_TS("123456"));
1.182 +
1.183 + test.Next(_L("CreateL(const TDesC_& aDesc) method"));
1.184 +
1.185 + TRAPD(ret, rBuf.CreateL(des)); //Create RBuf as EPtr type
1.186 + test(KErrNone == ret);
1.187 + rBuf.Close();
1.188 +
1.189 +#if defined(_DEBUG)
1.190 + __UHEAP_FAILNEXT(1); //Set the next alloc to fail
1.191 + TRAP(ret, rBuf.CreateL(des));
1.192 + test(KErrNoMemory == ret); // This will fail due to __UHEAP_FAILNEXT(1);
1.193 +#endif //(_DEBUG)
1.194 +
1.195 + test.Next(_L("CreateL(const TDesC_& aDesc, TInt aMaxLength) method"));
1.196 +
1.197 + TRAP(ret, rBuf.CreateL(des, des.Length())); //Create RBuf as EPtr type
1.198 + test(KErrNone == ret);
1.199 + rBuf.Close();
1.200 +
1.201 +#if defined(_DEBUG)
1.202 + __UHEAP_FAILNEXT(1); //Set the next alloc to fail
1.203 + TRAP(ret, rBuf.CreateL(des, des.Length()));
1.204 + test(KErrNoMemory == ret); // It fails due to __UHEAP_FAILNEXT(1);
1.205 +#endif //(_DEBUG)
1.206 +}
1.207 +
1.208 +/**
1.209 +Tests the following methods:
1.210 + - TInt Assign(const RBuf_& rBuf);
1.211 + - TInt Assign(TUint* aHeapCell, TInt aMaxLength);
1.212 + - TInt Assign(TUint* aHeapCell, TInt aLength, TInt aMaxLength);
1.213 + - TInt Assign(HBufC& aHBuf);
1.214 + - RBuf(HBufC_&) constructor.
1.215 +*/
1.216 +template<class RBUF, class TBUF, class TTEXT, class HBUF>
1.217 +LOCAL_C void TestAssign(RBUF*)
1.218 +{
1.219 + RBUF rBuf;
1.220 + TBUF des (_TS("123456"));
1.221 + RBUF rBuf2;
1.222 +
1.223 + test.Next(_L("Assign(const RBuf_& aRBuf) method"));
1.224 +
1.225 + rBuf2.Create(des);
1.226 + rBuf.Assign(rBuf2);
1.227 + test(rBuf==rBuf2);
1.228 + rBuf.Close();
1.229 +
1.230 + test.Next(_L("Assign(TUint* aHeapCell, TInt aLength, TInt aMaxLength ) method"));
1.231 +
1.232 + TTEXT* heap = (TTEXT*)User::Alloc(24*(TInt)sizeof(TTEXT)); //Allocate 48 bytes for 24 long RBuf16
1.233 + rBuf.Assign(heap, 12,24);
1.234 + test(rBuf.Length() == 12);
1.235 + test(rBuf.MaxLength() == 24);
1.236 + rBuf.Close();
1.237 +
1.238 + heap = NULL;
1.239 + rBuf.Assign(heap, 0,0);
1.240 + test(rBuf.Length() == 0);
1.241 + test(rBuf.MaxLength() == 0);
1.242 + rBuf.Close();
1.243 +
1.244 + test.Next(_L("Assign(TUint* aHeapCell, TInt aMaxLength ) method"));
1.245 +
1.246 + heap = (TTEXT*)User::Alloc(24*(TInt)sizeof(TTEXT)); //Allocate 48 bytes for 24 long RBuf16
1.247 + rBuf.Assign(heap, 24);
1.248 + test(rBuf.Length() == 0);
1.249 + test(rBuf.MaxLength() == 24);
1.250 + rBuf.Close();
1.251 +
1.252 + test.Next(_L("Assign(HBufC_* aHBuf) method"));
1.253 +
1.254 + HBUF* hBuf = HBUF::NewMax(11);
1.255 + rBuf.Assign(hBuf); //Create RBuf as EBufCPtr type
1.256 + test(rBuf.Length() == 11);
1.257 + test(rBuf.MaxLength() >= 11); //There could me more allocated memory - see HBufC8::Des()
1.258 + rBuf.Close();
1.259 +
1.260 + test.Next(_L("RBuf_(HBufC_* aHBuf) constructor"));
1.261 +
1.262 + hBuf = HBUF::NewMax(12); //Create RBuf as EBufCPtr
1.263 + RBUF rBuf3(hBuf);
1.264 + test(rBuf3.Length() == 12);
1.265 + test(rBuf3.MaxLength() >= 12);
1.266 + rBuf3.Close();
1.267 +
1.268 + hBuf = HBUF::NewMax(0);
1.269 + RBUF rBuf4(hBuf); //The length of aHBuf is zero
1.270 + test(rBuf4.Length() == 0);
1.271 + rBuf4.Close();
1.272 +
1.273 + hBuf = NULL; //aHBuf is NULL
1.274 + RBUF rBuf5(hBuf);
1.275 + test(rBuf5.Length() == 0);
1.276 + test(rBuf5.MaxLength() == 0);
1.277 + rBuf5.Close();
1.278 +}
1.279 +
1.280 +/**
1.281 +Tests the following methods.
1.282 + - TInt ReAlloc(TInt aMaxLength);
1.283 +*/
1.284 +template<class RBUF, class TBUF, class TTEXT, class HBUF>
1.285 +LOCAL_C void TestReAlloc(RBUF*)
1.286 +{
1.287 + RBUF rBuf;
1.288 +
1.289 + TBUF des (_TS("0123456"));
1.290 +
1.291 +
1.292 + test.Next(_L("ReAlloc(TInt aMaxLength) method"));
1.293 +
1.294 + //reallocate EPtr type - decrease memory
1.295 + test(rBuf.Create(des)==KErrNone); //Create as EPtr
1.296 + rBuf.SetLength(3);
1.297 + test(rBuf.ReAlloc(3)==KErrNone); //ReAlloc to EPtr
1.298 + test(rBuf.MaxLength()>=3);
1.299 + test(rBuf.Length()==3);
1.300 + test(rBuf[0] == (TTEXT)('0'));
1.301 + test(rBuf[2] == (TTEXT)('2'));
1.302 + rBuf.Close();
1.303 +
1.304 + //reallocate EPtr type - increase memory
1.305 + test(rBuf.Create(des,des.MaxLength())==KErrNone); //Create as EPtr
1.306 + test(rBuf.ReAlloc(15)==KErrNone); //ReAlloc to EPtr
1.307 + test(rBuf.MaxLength()==15);
1.308 + test(rBuf.Length()==7);
1.309 + test(rBuf[0] == (TTEXT)('0'));
1.310 + test(rBuf[6] == (TTEXT)('6'));
1.311 + rBuf.Close();
1.312 +
1.313 +
1.314 + //reallocate EBufCPtr type - decrease memory
1.315 + HBUF* hBuf = HBUF::NewMax(9);
1.316 + *hBuf = _TS("012345678");
1.317 + rBuf.Assign(hBuf); //Create as EBufCPtr
1.318 + rBuf.SetLength(5);
1.319 + test(rBuf.ReAlloc(5)==KErrNone); //ReAlloc to EBufCPtr
1.320 + test(rBuf.MaxLength()>=5);//There could be more allocated memory - see HBufC8::Des()
1.321 + test(rBuf.Length()==5);
1.322 + test(rBuf[0] == (TTEXT)('0'));
1.323 + test(rBuf[4] == (TTEXT)('4'));
1.324 + rBuf.Close();
1.325 +
1.326 + //reallocate EBufCPtr type - increase memory
1.327 + hBuf = HBUF::NewMax(9);
1.328 + *hBuf = _TS("012345678");
1.329 + rBuf.Assign(hBuf); //Create as EBufCPtr
1.330 + test(rBuf.ReAlloc(15)==KErrNone); //ReAlloc to EBufCPtr
1.331 + test(rBuf.MaxLength()>=15);//There could be more allocated memory - see HBufC8::Des()
1.332 + test(rBuf.Length()==9);
1.333 + test(rBuf[0] == (TTEXT)('0'));
1.334 + test(rBuf[8] == (TTEXT)('8'));
1.335 + rBuf.Close();
1.336 +
1.337 + //reallocate EPtr type - to zero-length
1.338 + test(rBuf.Create(des)==KErrNone); //Create as EPtr
1.339 + rBuf.SetLength(0);
1.340 + test(rBuf.ReAlloc(0)==KErrNone); //ReAlloc to EPtr
1.341 + test(rBuf.MaxLength()==0);
1.342 + test(rBuf.Length()==0);
1.343 + rBuf.Close();
1.344 +
1.345 + //reallocate EBufCPtr type to zero-length
1.346 + hBuf = HBUF::NewMax(9);
1.347 + *hBuf = _TS("012345678");
1.348 + rBuf.Assign(hBuf); //Create as EBufCPtr
1.349 + rBuf.SetLength(0);
1.350 + test(rBuf.ReAlloc(0)==KErrNone); //ReAlloc to EPtr
1.351 + test(rBuf.MaxLength()==0);
1.352 + test(rBuf.Length()==0);
1.353 + rBuf.Close();
1.354 +
1.355 + //reallocate from zero-length
1.356 + rBuf.Create(0); //Create as EPtr
1.357 + test(rBuf.ReAlloc(9)==KErrNone); //ReAlloc to EPtr
1.358 + test(rBuf.MaxLength()==9);
1.359 + test(rBuf.Length()==0);
1.360 + rBuf.Close();
1.361 +
1.362 + //reallocate from zero-length EBufCPtr to EPtr
1.363 + struct dummy // make it look like RBuf16
1.364 + {
1.365 + TInt iLength;
1.366 + TInt iMaxLength;
1.367 + HBUF* iEBufCPtrType; //Pointer to buffer data
1.368 + };
1.369 +
1.370 + // reference rBuf as our dummy..
1.371 + dummy &drBuf = (dummy&) rBuf;
1.372 + rBuf.Assign(HBUF::NewL(0)); //Create as EBufCPtr
1.373 + test(EBufCPtr == (drBuf.iLength>>KShiftDesType));
1.374 + rBuf.Close(); // the actual behavior causes memory leaks, so we should close it first.
1.375 + test(rBuf.ReAlloc(13)==KErrNone); // ReAlloc changes it from EBufCPtr to EPtr
1.376 + test(EPtr == (drBuf.iLength>>KShiftDesType));
1.377 + test(rBuf.MaxLength() == 13);
1.378 + test(rBuf.Length() == 0);
1.379 + rBuf.Close();
1.380 +
1.381 + //reallocate from zero-length to zero-length
1.382 + rBuf.Create(0); //Create as EPtr
1.383 + test(rBuf.ReAlloc(0)==KErrNone); //ReAlloc to EPtr
1.384 + test(rBuf.Length() == 0);
1.385 + test(rBuf.MaxLength() == 0);
1.386 + rBuf.Close();
1.387 +
1.388 +}
1.389 +
1.390 +/**
1.391 +Tests the following methods.
1.392 + - TInt ReAllocL(TInt aMaxLength);
1.393 +*/
1.394 +template<class RBUF, class TBUF, class TTEXT>
1.395 +LOCAL_C void TestReAllocLeaving(RBUF*)
1.396 +{
1.397 + RBUF rBuf;
1.398 +
1.399 + TBUF des(_TS("01"));
1.400 +
1.401 + test.Next(_L("ReAllocL(TInt aMaxLength) method"));
1.402 +
1.403 + test(rBuf.Create(des) ==KErrNone);
1.404 + TRAPD(ret, rBuf.ReAllocL(6)); //ReAlloc buffer
1.405 + test(KErrNone == ret);
1.406 +
1.407 +#if defined(_DEBUG)
1.408 + __UHEAP_FAILNEXT(1);
1.409 + TRAP(ret, rBuf.ReAllocL(100)); //Realloc buffer. This should fail.
1.410 + test(KErrNoMemory == ret);
1.411 +#endif //(_DEBUG)
1.412 +
1.413 + test(rBuf.MaxLength()==6); //Check RBuf is the same as before ...
1.414 + test(rBuf.Length()==2); //... ReAlloc that failed.
1.415 + test(rBuf[0] == (TTEXT)('0'));
1.416 + test(rBuf[1] == (TTEXT)('1'));
1.417 + rBuf.Close();
1.418 +}
1.419 +
1.420 +/**
1.421 +Tests the following methods.
1.422 + - void Swap(RBuf_& aBuf);
1.423 +*/
1.424 +template<class RBUF, class TBUF, class TTEXT>
1.425 +LOCAL_C void TestSwap(RBUF*)
1.426 +{
1.427 + RBUF rBuf1, rBuf2;
1.428 + TBUF des1(_TS("12"));
1.429 + TBUF des2 (_TS("345678"));
1.430 +
1.431 + test.Next(_L("Swap(RBuf_& aRBuf) method"));
1.432 +
1.433 + test(rBuf1.Create(des1) ==KErrNone);
1.434 + test(rBuf2.Create(des2) ==KErrNone);
1.435 +
1.436 + rBuf1.Swap(rBuf2);
1.437 +
1.438 + test(rBuf1==des2);
1.439 + test(rBuf2==des1);
1.440 +
1.441 + rBuf1.Close();
1.442 + rBuf2.Close();
1.443 +}
1.444 +
1.445 +/**
1.446 +Test assignemnt operator.
1.447 +*/
1.448 +template<class RBUF, class TBUF, class TBUFC, class TTEXT>
1.449 +LOCAL_C void TestAssignmentOperator()
1.450 +{
1.451 + test.Next(_L("Assignment operator"));
1.452 +
1.453 + TBUF tdes(_TS("Modifiable descriptor"));
1.454 + TBUFC tdesc(_TS("Non-modifiable descriptor"));
1.455 +
1.456 + RBUF rbuf, rbuf2;
1.457 + rbuf.Create(32);
1.458 + rbuf2.Create(32);
1.459 + rbuf2.Copy(_TS("Buffer descriptor"), 17);
1.460 +
1.461 + rbuf = tdesc; test(rbuf == tdesc);
1.462 + rbuf = tdes; test(rbuf == tdes);
1.463 + rbuf = rbuf2; test(rbuf == rbuf2);
1.464 +
1.465 + rbuf2.Close();
1.466 + rbuf.Close();
1.467 +}
1.468 +
1.469 +/**
1.470 +Tests the following methods.
1.471 + - void CleanupClosePushL();
1.472 +*/
1.473 +template<class RBUF> LOCAL_C void TestCleanupClosePushL(RBUF*)
1.474 +{
1.475 + RBUF rBuf;
1.476 +
1.477 + test.Next(_L("CleanupClosePushL() method"));
1.478 + test(KErrNone == rBuf.Create(10));
1.479 + rBuf.CleanupClosePushL();
1.480 + CleanupStack::PopAndDestroy();
1.481 +}
1.482 +
1.483 +/**
1.484 +This function will intentionally leave to check cleanup of RBuf.
1.485 +To be called in debug build only. Otherwise will panic.
1.486 +*/
1.487 +template<class RBUF> LOCAL_C void TestRBufCleanupL(RBUF*)
1.488 +{
1.489 + RBUF rBuf;
1.490 +
1.491 + test.Next(_L("Test cleanup of RBuf"));
1.492 + test(KErrNone == rBuf.Create(10));
1.493 + rBuf.CleanupClosePushL();
1.494 +
1.495 + __UHEAP_FAILNEXT(1);
1.496 + TInt* ptr = (TInt*)User::AllocL(20); //This should leave
1.497 + *ptr = 0; //Avoid compiler warning
1.498 + User::Panic(_L("Should not reach this line"),0);
1.499 +}
1.500 +
1.501 +GLDEF_C TInt E32Main()
1.502 + {
1.503 + RBuf8* r8=0;
1.504 + RBuf16* r16=0;
1.505 + RBuf* r=0;
1.506 +
1.507 + CTrapCleanup* trapHandler=CTrapCleanup::New();
1.508 + test(trapHandler!=NULL);
1.509 +
1.510 + test.Title();
1.511 + test.Start(_L("Testing RBuf8, RBuf16 & RBuf classes"));
1.512 +
1.513 + __UHEAP_MARK;
1.514 +
1.515 + test.Start(_L("Testing class RBuf8 ..."));
1.516 + TestCreate<RBuf8>(r8);
1.517 + TestCreateLeaving<RBuf8>(r8);
1.518 + TestCreateFromDes<RBuf8,TBuf8<11>,TText8>(r8);
1.519 + TestCreateFromDesLeaving<RBuf8,TBuf8<11>,TText8>(r8);
1.520 + TestSwap<RBuf8,TBuf8<11>,TText8>(r8);
1.521 + TestAssign<RBuf8,TBuf8<11>,TText8,HBufC8>(r8);
1.522 + TestReAlloc<RBuf8,TBuf8<11>,TText8,HBufC8>(r8);
1.523 + TestReAllocLeaving<RBuf8,TBuf8<11>,TText8>(r8);
1.524 + TestAssignmentOperator<RBuf8,TBuf8<32>,TBufC8<32>,TText8>();
1.525 + TRAPD(ret,TestCleanupClosePushL<RBuf8>(r8)); test(ret==KErrNone);
1.526 +#if defined(_DEBUG)
1.527 + TRAP(ret, TestRBufCleanupL<RBuf8>(r8)); test(KErrNoMemory == ret);
1.528 +#endif //(_DEBUG)
1.529 + test.End();
1.530 +
1.531 + test.Start(_L("Testing class RBuf16 ..."));
1.532 + TestCreate<RBuf16>(r16);
1.533 + TestCreateLeaving<RBuf16>(r16);
1.534 + TestCreateFromDes<RBuf16,TBuf16<11>,TText16>(r16);
1.535 + TestCreateFromDesLeaving<RBuf16,TBuf16<11>,TText16>(r16);
1.536 + TestSwap<RBuf16,TBuf16<11>,TText16>(r16);
1.537 + TestAssign<RBuf16,TBuf16<11>,TText16,HBufC16>(r16);
1.538 + TestReAlloc<RBuf16,TBuf16<11>,TText16,HBufC16>(r16);
1.539 + TestReAllocLeaving<RBuf16,TBuf16<11>,TText16>(r16);
1.540 + TestAssignmentOperator<RBuf16,TBuf16<32>,TBufC16<32>,TText16>();
1.541 + TRAP(ret,TestCleanupClosePushL<RBuf16>(r16)); test(ret==KErrNone);
1.542 +#if defined(_DEBUG)
1.543 + TRAP(ret, TestRBufCleanupL<RBuf16>(r16)); test(KErrNoMemory == ret);
1.544 +#endif //(_DEBUG)
1.545 + test.End();
1.546 +
1.547 + test.Start(_L("Testing class RBuf ..."));
1.548 + TestCreate<RBuf>(r);
1.549 + TestCreateLeaving<RBuf>(r);
1.550 + TestCreateFromDes<RBuf,TBuf<11>,TText>(r);
1.551 + TestCreateFromDesLeaving<RBuf,TBuf<11>,TText>(r);
1.552 + TestSwap<RBuf,TBuf<11>,TText>(r);
1.553 + TestAssign<RBuf,TBuf<11>,TText,HBufC>(r);
1.554 + TestReAlloc<RBuf,TBuf<11>,TText,HBufC>(r);
1.555 + TestReAllocLeaving<RBuf,TBuf<11>,TText>(r);
1.556 + TestAssignmentOperator<RBuf,TBuf<32>,TBufC<32>,TText>();
1.557 + TRAP(ret,TestCleanupClosePushL<RBuf>(r)); test(ret==KErrNone);
1.558 +#if defined(_DEBUG)
1.559 + TRAP(ret, TestRBufCleanupL<RBuf>(r)); test(KErrNoMemory == ret);
1.560 +#endif //(_DEBUG)
1.561 + test.End();
1.562 +
1.563 + __UHEAP_MARKEND;
1.564 +
1.565 + test.End();
1.566 +
1.567 + delete trapHandler;
1.568 + return(KErrNone);
1.569 + }
1.570 +