diff --git a/test/SmartPtr/SmartPtr.vcproj b/test/SmartPtr/SmartPtr.vcproj index c3ea06b..a827a49 100644 --- a/test/SmartPtr/SmartPtr.vcproj +++ b/test/SmartPtr/SmartPtr.vcproj @@ -161,6 +161,14 @@ + + + Counted_WeakPtr; +typedef ::Loki::StrongPtr< Counted, true > Counted_StrongPtr; + +typedef ::Loki::StrongPtr< Counted, false, ::Loki::TwoRefLinks > Linked_WeakPtr; +typedef ::Loki::StrongPtr< Counted, true, ::Loki::TwoRefLinks > Linked_StrongPtr; + +typedef ::Loki::StrongPtr< Counted, false, ::Loki::LockableTwoRefCounts > + Lockable_WeakPtr; +typedef ::Loki::StrongPtr< Counted, true, ::Loki::LockableTwoRefCounts > + Lockable_StrongPtr; -typedef Loki::StrongPtr< Counted, false > Counted_WeakPtr; -typedef Loki::StrongPtr< Counted, true > Counted_StrongPtr; // ---------------------------------------------------------------------------- @@ -313,20 +322,51 @@ typedef Loki::StrongPtr< const BaseClass, false, TwoRefCounts, DisallowConversio void DoWeakLeakTest( void ) { + const unsigned int ctorCount = Counted::GetCtorCount(); + const unsigned int dtorCount = Counted::GetDtorCount(); assert( Counted::AllDestroyed() ); - assert( Counted::GetCtorCount() == 0 ); - assert( Counted::GetDtorCount() == 0 ); - Counted_WeakPtr pWeakInt; + { - Counted_StrongPtr pStrongInt( new Counted ); - pWeakInt = pStrongInt; - assert( Counted::ExtraConstructions() ); - assert( Counted::GetCtorCount() == 1 ); - assert( Counted::GetDtorCount() == 0 ); + Counted_WeakPtr pWeakInt; + { + Counted_StrongPtr pStrongInt( new Counted ); + pWeakInt = pStrongInt; + assert( Counted::ExtraConstructions() ); + assert( Counted::GetCtorCount() == ctorCount + 1 ); + assert( Counted::GetDtorCount() == dtorCount ); + } + assert( Counted::AllDestroyed() ); + assert( Counted::GetCtorCount() == ctorCount + 1 ); + assert( Counted::GetDtorCount() == dtorCount + 1 ); + } + + { + Lockable_WeakPtr pWeakInt; + { + Lockable_StrongPtr pStrongInt( new Counted ); + pWeakInt = pStrongInt; + assert( Counted::ExtraConstructions() ); + assert( Counted::GetCtorCount() == ctorCount + 2 ); + assert( Counted::GetDtorCount() == dtorCount + 1 ); + } + assert( Counted::AllDestroyed() ); + assert( Counted::GetCtorCount() == ctorCount + 2 ); + assert( Counted::GetDtorCount() == dtorCount + 2 ); + } + + { + Linked_WeakPtr pWeakInt; + { + Linked_StrongPtr pStrongInt( new Counted ); + pWeakInt = pStrongInt; + assert( Counted::ExtraConstructions() ); + assert( Counted::GetCtorCount() == ctorCount + 3 ); + assert( Counted::GetDtorCount() == dtorCount + 2 ); + } + assert( Counted::AllDestroyed() ); + assert( Counted::GetCtorCount() == ctorCount + 3 ); + assert( Counted::GetDtorCount() == dtorCount + 3 ); } - assert( Counted::AllDestroyed() ); - assert( Counted::GetCtorCount() == 1 ); - assert( Counted::GetDtorCount() == 1 ); } // ----------------------------------------------------------------------------