aTestObj7 = cow_wrapper_client3( 7 );
CPPUNIT_ASSERT_EQUAL(7, aTestObj7.queryUnmodified());
aTestObj8.modify( 8 );
CPPUNIT_ASSERT_EQUAL(8, aTestObj8.queryUnmodified());
aTestObj9.modify( 9 );
CPPUNIT_ASSERT_EQUAL(9, aTestObj9.queryUnmodified());
} // all three temporaries are dead now
void testRefCounting()
{ // add scope to ensure appropriate number of calls to // the reference counting policy have been made
{ // if any incrementing/decrementing occurs a failure // will occur
cow_wrapper_client5 aTestObj1(1);
cow_wrapper_client5 aTestObj2( std::move( aTestObj1 ) );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj2.use_count()", static_cast<sal_uInt32>(1), aTestObj2.use_count() );
// the following should increment
BogusRefCountPolicy::s_bShouldIncrement = true;
cow_wrapper_client5 aTestObj3( aTestObj2 );
CPPUNIT_ASSERT_MESSAGE("s_bShouldIncrement == 0",
!BogusRefCountPolicy::s_bShouldIncrement );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj3.use_count()", static_cast<sal_uInt32>(2), aTestObj3.use_count() );
{
cow_wrapper_client5 aTestObj4; // the following should decrement the lvalue and then increment the rvalue
BogusRefCountPolicy::s_bShouldIncrement = true;
BogusRefCountPolicy::s_bShouldDecrement = true;
aTestObj4 = aTestObj2;
CPPUNIT_ASSERT_MESSAGE("s_bShouldIncrement == 0",
!BogusRefCountPolicy::s_bShouldIncrement );
CPPUNIT_ASSERT_MESSAGE("s_bShouldDecrement == 0",
!BogusRefCountPolicy::s_bShouldDecrement );
// only decrement the lvalue before assignment
BogusRefCountPolicy::s_bShouldDecrement = true;
aTestObj4 = cow_wrapper_client5( 4 );
CPPUNIT_ASSERT_MESSAGE("s_bShouldIncrement == 0",
!BogusRefCountPolicy::s_bShouldIncrement );
// only one call should be made to the ref counting policy's // decrementing function at the end of the scope
BogusRefCountPolicy::s_bShouldDecrement = true;
}
CPPUNIT_ASSERT_MESSAGE("s_bShouldDecrement == 0",
!BogusRefCountPolicy::s_bShouldDecrement );
// only decrement the lvalue before assignment
BogusRefCountPolicy::s_bShouldDecrement = true;
aTestObj3 = std::move( aTestObj5 );
CPPUNIT_ASSERT_MESSAGE("s_bShouldDecrement == 0",
!BogusRefCountPolicy::s_bShouldDecrement);
// one call should be made to the ref-counting policy's // decrementing function at the end of the scope. Only // aTestObj3 still holds a valid instance
BogusRefCountPolicy::s_nEndOfScope = 1;
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("s_EndOfScope", static_cast<sal_uInt32>(0), BogusRefCountPolicy::s_nEndOfScope );
}
// Change the following lines only, if you add, remove or rename // member functions of the current class, // because these macros are need by auto register mechanism.
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.11Bemerkung:
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.