text stringlengths 0 2.2M |
|---|
BSLMA_TESTALLOCATOR_EXCEPTION_TEST_BEGIN(testAllocator) {
|
my_ClassDef rawBuf[2];
|
my_PairBB_4_4 *objPtr = rawBuf[0].as<my_PairBB_4_4>();
|
Util::construct(objPtr, TA, PBBV4V4);
|
ASSERT(4 == rawBuf[0].d_value);
|
ASSERT(DA == rawBuf[0].d_allocator_p);
|
ASSERT(4 == rawBuf[1].d_value);
|
ASSERT(DA == rawBuf[1].d_allocator_p);
|
objPtr->~my_PairBB_4_4();
|
} BSLMA_TESTALLOCATOR_EXCEPTION_TEST_END
|
ASSERT(NUM_ALLOC1 == testAllocator.numAllocations());
|
if (verbose) printf("Trait selection testing.\n");
|
{
|
my_ClassDef rawBuf;
|
my_ClassFussy *objPtr = rawBuf.as<my_ClassFussy>();
|
setToGarbage(&rawBuf);
|
Util::construct(objPtr, XA, VF);
|
ASSERT(5 == rawBuf.d_value);
|
ASSERT(0 == rawBuf.d_allocator_p);
|
if (veryVerbose) { P_(rawBuf.d_value); PP(rawBuf.d_allocator_p); }
|
}
|
} break;
|
case 3: {
|
// --------------------------------------------------------------------
|
// TESTING 'defaultConstruct'
|
//
|
// Concerns:
|
//: 1 That the default constructor properly forwards the allocator
|
//: when appropriate.
|
//:
|
//: 2 That a pair type properly forwards to both its members, in an
|
//: exception-safe manner.
|
//:
|
//: 3 That the default constructor uses memset(..,0,..) when
|
//: appropriate.
|
//
|
// Plan:
|
//: 1 Construct an object into a default state into an uninitialized
|
//: buffer, passing allocators of both types 'bslma::Allocator *' and
|
//: 'void *', and verify that the value and allocator of the object
|
//: are as expected. Using a fussy type that has the
|
//: TrivialDefaultConstructor trait (even though the default
|
//: constructor is not really trivial), ensure that this constructor
|
//: is not invoked.
|
//
|
// Testing:
|
// defaultConstruct(T *dst, *a)
|
// --------------------------------------------------------------------
|
if (verbose) printf("\nTESTING 'defaultConstruct'"
|
"\n==========================\n");
|
bslma::Allocator *const DA = bslma::Default::allocator();
|
bslma::TestAllocator testAllocator(veryVeryVeryVerbose);
|
bslma::TestAllocator *const TA = &testAllocator;
|
int dummyAllocator; // not a 'bslma' allocator
|
int *const XA = &dummyAllocator;
|
if (verbose) printf("Value and allocator testing.\n");
|
// my_Class Expected
|
// # Operation Val Alloc
|
// == ============================= === =====
|
TEST_OP(1, construct(objPtr, TA), 0, 0);
|
TEST_OP(2, construct(objPtr, TA), 0, TA);
|
TEST_OP(1, construct(objPtr, XA), 0, 0);
|
TEST_OP(2, construct(objPtr, XA), 0, 0);
|
// my_Pair first second
|
// #_# Operation Val Alloc Val Alloc
|
// == == ============================= === ===== === =====
|
TEST_PAIROP(1, 1, construct(objPtr, TA), 0, 0, 0, 0);
|
TEST_PAIROP(1, 2, construct(objPtr, TA), 0, 0, 0, 0);
|
TEST_PAIROP(2, 1, construct(objPtr, TA), 0, 0, 0, 0);
|
TEST_PAIROP(2, 2, construct(objPtr, TA), 0, 0, 0, 0);
|
TEST_PAIROP(1, 1, construct(objPtr, XA), 0, 0, 0, 0);
|
TEST_PAIROP(1, 2, construct(objPtr, XA), 0, 0, 0, 0);
|
TEST_PAIROP(2, 1, construct(objPtr, XA), 0, 0, 0, 0);
|
TEST_PAIROP(2, 2, construct(objPtr, XA), 0, 0, 0, 0);
|
// my_PairA first second
|
// #_# Operation Val Alloc Val Alloc
|
// == == ============================= === ===== === =====
|
TEST_PAIRAOP(1, 2, construct(objPtr, TA), 0, 0, 0, TA);
|
TEST_PAIRAOP(2, 2, construct(objPtr, TA), 0, 0, 0, TA);
|
TEST_PAIRAOP(1, 2, construct(objPtr, XA), 0, 0, 0, 0);
|
TEST_PAIRAOP(2, 2, construct(objPtr, XA), 0, 0, 0, 0);
|
// my_PairAA first second
|
// #_# Operation Val Alloc Val Alloc
|
// == == ============================= === ===== === =====
|
TEST_PAIRAAOP(2, 2, construct(objPtr, TA), 0, TA, 0, TA);
|
TEST_PAIRAAOP(2, 2, construct(objPtr, XA), 0, 0, 0, 0);
|
if (verbose) printf("Exception testing.\n");
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.