text
stringlengths
0
2.2M
// CP_A - copy constructor with an argument tag
// MV_A - move constructor with an argument tag
if (verbose) printf("\tWithout allocators\n");
// CP MV CP_B MV_B CP_A MV_A EXP_ALLOCATOR
// == == ==== ==== ==== ==== ==============
T::testCase5NoAlloc(0, 1, 0, 0, 0, 0, T::DEFAULT );
NT::testCase5NoAlloc(0, 1, 0, 0, 0, 0, NT::DEFAULT );
BAT::testCase5NoAlloc(0, 1, 0, 0, 0, 0, BAT::DEFAULT );
ATT::testCase5NoAlloc(0, 1, 0, 0, 0, 0, ATT::DEFAULT );
MOT::testCase5NoAlloc(0, 1, 0, 0, 0, 0, MOT::DEFAULT );
MONT::testCase5NoAlloc(0, 1, 0, 0, 0, 0, MONT::DEFAULT );
MOBAT::testCase5NoAlloc(0, 1, 0, 0, 0, 0, MOBAT::DEFAULT );
MOATT::testCase5NoAlloc(0, 1, 0, 0, 0, 0, MOATT::DEFAULT );
COT::testCase5NoAlloc(1, 0, 0, 0, 0, 0, COT::DEFAULT );
CONT::testCase5NoAlloc(1, 0, 0, 0, 0, 0, CONT::DEFAULT );
COBAT::testCase5NoAlloc(1, 0, 0, 0, 0, 0, COBAT::DEFAULT );
COATT::testCase5NoAlloc(1, 0, 0, 0, 0, 0, COATT::DEFAULT );
if (verbose) printf("\tWith allocators\n");
// CP MV CP_B MV_B CP_A MV_A EXP_ALLOCATOR
// == == ==== ==== ==== ==== ===============
T::testCase5Alloc( 0, 1, 0, 0, 0, 0, T::DEFAULT );
NT::testCase5Alloc( 0, 1, 0, 0, 0, 0, NT::DEFAULT );
BAT::testCase5Alloc( 0, 0, 0, 1, 0, 0, BAT::SUPPLIED);
ATT::testCase5Alloc( 0, 0, 0, 0, 0, 1, ATT::SUPPLIED);
MOT::testCase5Alloc( 0, 1, 0, 0, 0, 0, MOT::DEFAULT );
MONT::testCase5Alloc( 0, 1, 0, 0, 0, 0, MONT::DEFAULT );
MOBAT::testCase5Alloc( 0, 0, 0, 1, 0, 0, MOBAT::SUPPLIED);
MOATT::testCase5Alloc( 0, 0, 0, 0, 0, 1, MOATT::SUPPLIED);
COT::testCase5Alloc( 1, 0, 0, 0, 0, 0, COT::DEFAULT );
CONT::testCase5Alloc( 1, 0, 0, 0, 0, 0, CONT::DEFAULT );
COBAT::testCase5Alloc( 0, 0, 1, 0, 0, 0, COBAT::SUPPLIED);
COATT::testCase5Alloc( 0, 0, 0, 0, 1, 0, COATT::SUPPLIED);
} break;
case 4: {
// --------------------------------------------------------------------
// TESTING 'copyConstruct'
//
// Concerns:
//: 1 That the copy constructor properly forwards the allocator
//: when appropriate.
//:
//: 2 That the copy constructor uses 'memcpy' when appropriate.
//
// Plan:
//: 1 Construct a copy of pre-initialized objects into an
//: uninitialized buffer, passing allocators of both types
//: 'bslma::Allocator *' and 'void *' types, and verify that the
//: values and allocator of the copy are as expected. Using a fussy
//: type that has the BitwiseCopyable trait, ensure that the copy
//: constructor is not invoked.
//
// Testing:
// copyConstruct(T *dst, const T& src, *a)
// --------------------------------------------------------------------
if (verbose) printf("\nTESTING 'copyConstruct'"
"\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;
// my_Class Expected
// # Operation Val Alloc
// = ============================== === =====
TEST_OP(1, construct(objPtr, TA, V1), 1, 0);
TEST_OP(2, construct(objPtr, TA, V2), 2, TA);
TEST_OP(1, construct(objPtr, XA, V1), 1, 0);
TEST_OP(2, construct(objPtr, XA, V2), 2, 0);
if (verbose) printf("Exception testing.\n");
if (verbose) printf("\t...pair with allocators\n");
BSLMA_TESTALLOCATOR_EXCEPTION_TEST_BEGIN(testAllocator) {
my_ClassDef rawBuf[2];
my_PairAA_4_4 *objPtr = rawBuf[0].as<my_PairAA_4_4>();
Util::construct(objPtr, TA, PAAV4V4);
ASSERT(4 == rawBuf[0].d_value);
ASSERT(TA == rawBuf[0].d_allocator_p);
ASSERT(4 == rawBuf[1].d_value);
ASSERT(TA == rawBuf[1].d_allocator_p);
objPtr->~my_PairAA_4_4();
} BSLMA_TESTALLOCATOR_EXCEPTION_TEST_END
if (verbose) printf("\t...constructing pair with IsPair\n");
// Testing that 'TA' is not passed to the pair constructor and the
// default allocator is used instead.
const bsls::Types::Int64 NUM_ALLOC1 = testAllocator.numAllocations();