text
stringlengths
0
2.2M
ASSERT(sizeof(myMostDerived) == Z.numBytesInUse());
}
ASSERT(1 == counter);
ASSERT(0 == Z.numBytesInUse());
counter = 0; // reset counter
}
if (verbose) printf("\nTesting with my_Pool\n");
{
int allocCounter = 0;
my_Pool myAlloc(&allocCounter);
if (verbose) printf("\tTesting single inheritance with derived "
"class pointer\n");
myChild *pC = 0;
{
pC = new(z) myChild(&counter);
ASSERT(0 == counter);
ASSERT(0 == allocCounter);
ASSERT(sizeof(myChild) == Z.numBytesInUse());
bslma::RawDeleterProctor<myChild, my_Pool> proctor(pC,
&myAlloc);
ASSERT(0 == counter);
ASSERT(0 == allocCounter);
ASSERT(sizeof(myChild) == Z.numBytesInUse());
}
ASSERT(1 == counter);
ASSERT(1 == allocCounter);
ASSERT(sizeof(myChild) == Z.numBytesInUse());
z.deallocate(pC);
ASSERT(0 == Z.numBytesInUse());
counter = 0; // reset counter
allocCounter = 0; // reset counter
if (verbose) printf("\tTesting single inheritance with base "
"class pointer\n");
myParent *pP = 0;
{
pP = new(z) myChild(&counter);
ASSERT(0 == counter);
ASSERT(0 == allocCounter);
ASSERT(sizeof(myChild) == Z.numBytesInUse());
bslma::RawDeleterProctor<myParent, my_Pool> proctor(pP,
&myAlloc);
ASSERT(0 == counter);
ASSERT(0 == allocCounter);
ASSERT(sizeof(myChild) == Z.numBytesInUse());
}
ASSERT(1 == counter);
ASSERT(1 == allocCounter);
ASSERT(sizeof(myChild) == Z.numBytesInUse());
z.deallocate(pP);
ASSERT(0 == Z.numBytesInUse());
counter = 0; // reset counter
allocCounter = 0; // reset counter
if (verbose) printf("\tTesting multiple inheritance with derived "
"class pointer\n");
myMostDerived *pMD;
{
pMD = new(z) myMostDerived(&counter);
ASSERT(0 == counter);
ASSERT(0 == allocCounter);
ASSERT(sizeof(myMostDerived) == Z.numBytesInUse());
bslma::RawDeleterProctor<myMostDerived, my_Pool>
proctor(pMD, &myAlloc);
ASSERT(0 == counter);
ASSERT(0 == allocCounter);
ASSERT(sizeof(myMostDerived) == Z.numBytesInUse());
}
ASSERT(1 == counter);
ASSERT(1 == allocCounter);
ASSERT(Z.numBytesInUse() == sizeof(myMostDerived));
z.deallocate(pMD);
ASSERT(0 == Z.numBytesInUse());
}
}break;
case 2: {
// --------------------------------------------------------------------
// HELPER CLASS TEST
//
// Concerns:
// 1) The helper class 'my_Class' properly increments its counter at
// destruction.
// 2) The helper class 'my_Pool' properly increments its counter when
// its 'deallocate' method is called.
//
// Plan: