From d6ee790dd6c307a3faa9b2ab66eeb258f8d65117 Mon Sep 17 00:00:00 2001 From: rich_sposato Date: Thu, 8 Sep 2011 23:37:26 +0000 Subject: [PATCH] Added tests for DestructiveCopy. git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@1097 7ec92016-0320-0410-acc4-a06ded1c099a --- test/SmartPtr/main.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/SmartPtr/main.cpp b/test/SmartPtr/main.cpp index f1bea92..16c54fe 100644 --- a/test/SmartPtr/main.cpp +++ b/test/SmartPtr/main.cpp @@ -1455,6 +1455,44 @@ void DoDeepCopyTests( void ) // ---------------------------------------------------------------------------- +typedef Loki::SmartPtr< BaseClass, DestructiveCopy > DestructiveCopyPtr; + +DestructiveCopyPtr MakePointer( void ) +{ + DestructiveCopyPtr p( new BaseClass ); + return p; +} + +// ---------------------------------------------------------------------------- + +void DoDestructiveCopyTest( void ) +{ + cout << "Starting DoDestructiveCopyTest." << endl; + + { + DestructiveCopyPtr p1( new BaseClass ); + assert( p1 ); + DestructiveCopyPtr p2; + assert( !p2 ); + p2 = p1; + assert( !p1 ); + assert( p2 ); + DestructiveCopyPtr p3( p2 ); + assert( p3 ); + assert( !p2 ); + /// @todo The following lines need to be uncommented when bug 3224572 gets fixed. +// DestructiveCopyPtr p4( MakePointer() ); +// assert( p4 ); + } + + assert( BaseClass::AllDestroyed() ); + assert( !BaseClass::ExtraConstructions() ); + assert( !BaseClass::ExtraDestructions() ); + cout << "Finished DoDestructiveCopyTest." << endl; +} + +// ---------------------------------------------------------------------------- + int main( int argc, const char * argv[] ) { bool doThreadTest = false; @@ -1465,6 +1503,7 @@ int main( int argc, const char * argv[] ) } DoDeepCopyTests(); + DoDestructiveCopyTest(); DoRefLinkTests(); DoWeakLeakTest(); DoStrongRefCountTests();