|
From: <ric...@us...> - 2011-09-08 23:37:33
|
Revision: 1097
http://loki-lib.svn.sourceforge.net/loki-lib/?rev=1097&view=rev
Author: rich_sposato
Date: 2011-09-08 23:37:26 +0000 (Thu, 08 Sep 2011)
Log Message:
-----------
Added tests for DestructiveCopy.
Modified Paths:
--------------
trunk/test/SmartPtr/main.cpp
Modified: trunk/test/SmartPtr/main.cpp
===================================================================
--- trunk/test/SmartPtr/main.cpp 2011-09-07 22:51:17 UTC (rev 1096)
+++ trunk/test/SmartPtr/main.cpp 2011-09-08 23:37:26 UTC (rev 1097)
@@ -1455,6 +1455,44 @@
// ----------------------------------------------------------------------------
+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 @@
}
DoDeepCopyTests();
+ DoDestructiveCopyTest();
DoRefLinkTests();
DoWeakLeakTest();
DoStrongRefCountTests();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|