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());
|
const bsls::Types::Int64 NUM_ALLOC2 = testAllocator.numAllocations();
|
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, V4, V4);
|
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_ALLOC2 == testAllocator.numAllocations());
|
if (verbose) printf("Trait selection testing.\n");
|
{
|
my_ClassDef rawBuf;
|
my_ClassFussy *objPtr = rawBuf.as<my_ClassFussy>();
|
setToGarbage(&rawBuf);
|
Util::construct(objPtr, TA, VF);
|
ASSERT(5 == rawBuf.d_value);
|
ASSERT(0 == rawBuf.d_allocator_p);
|
if (veryVerbose) { P_(rawBuf.d_value); PP(rawBuf.d_allocator_p); }
|
}
|
{
|
my_ClassDef rawBuf;
|
my_ClassFussy *objPtr = rawBuf.as<my_ClassFussy>();
|
setToGarbage(&rawBuf);
|
const int CVI = my_ClassFussy::s_conversionConstructorInvocations;
|
const int VF = 3;
|
Util::construct(objPtr, TA, VF);
|
ASSERT(CVI < my_ClassFussy::s_conversionConstructorInvocations);
|
ASSERT(3 == rawBuf.d_value);
|
ASSERT(0 == rawBuf.d_allocator_p);
|
if (veryVerbose) { P_(rawBuf.d_value); PP(rawBuf.d_allocator_p); }
|
}
|
} break;
|
case 5: {
|
// --------------------------------------------------------------------
|
// TESTING MOVE CONSTRUCTION
|
//
|
// Concerns:
|
//: 1 The 'construct' function with 'MovableRef' parameter properly
|
//: forwards the allocator to the object constructor when
|
//: appropriate.
|
//:
|
//: 2 The 'construct' function with 'MovableRef' parameter uses
|
//: 'memcpy' instead of constructor call for bitwise copyable
|
//: objects.
|
//
|
// Plan:
|
//: 1 Using special types, construct copies of pre-initialized objects
|
//: into uninitialized buffers using move construction, passing
|
//: allocators of both types 'bslma::Allocator *' and 'void *' types,
|
//: and verify that the value and allocator of the copy are as
|
//: expected. Ensure that the expected overload of move
|
//: constructor (or copy constructor) is invoked. (C-1,2)
|
//
|
// Testing:
|
// construct(TYPE *addr, Allocator *a, MovableRef<TYPE> orig)
|
// construct(TYPE *addr, void *a, MovableRef<TYPE> orig)
|
// --------------------------------------------------------------------
|
if (verbose) printf("\nTESTING MOVE CONSTRUCTION"
|
"\n=========================\n");
|
typedef TestDriver< TrivialTestType> T;
|
typedef TestDriver< NonTrivialTestType> NT;
|
typedef TestDriver< BslmaAllocTestType> BAT;
|
typedef TestDriver< ArgTAllocTestType> ATT;
|
typedef TestDriver< MoveOnlyTrivialTestType> MOT;
|
typedef TestDriver<MoveOnlyNonTrivialTestType> MONT;
|
typedef TestDriver<MoveOnlyBslmaAllocTestType> MOBAT;
|
typedef TestDriver< MoveOnlyArgTAllocTestType> MOATT;
|
typedef TestDriver< CopyOnlyTrivialTestType> COT;
|
typedef TestDriver<CopyOnlyNonTrivialTestType> CONT;
|
typedef TestDriver<CopyOnlyBslmaAllocTestType> COBAT;
|
typedef TestDriver< CopyOnlyArgTAllocTestType> COATT;
|
// Legend
|
// ------
|
// CP - copy constructor
|
// MV - move constructor
|
// CP_B - copy constructor with bslma allocator
|
// MV_B - move constructor with bslma allocator
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.