Added tests for StrongPtr comparison operators.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@805 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
015404028e
commit
cc0392d433
2 changed files with 92 additions and 1 deletions
|
@ -32,6 +32,7 @@ extern void DoStrongReleaseTests( void );
|
|||
extern void DoWeakCycleTests( void );
|
||||
extern void DoStrongConstTests( void );
|
||||
extern void DoStrongForwardReferenceTest( void );
|
||||
extern void DoStrongCompareTests( void );
|
||||
|
||||
extern void DoLockedPtrTest( void );
|
||||
extern void DoLockedStorageTest( void );
|
||||
|
@ -1013,6 +1014,7 @@ int main( unsigned int argc, const char * argv[] )
|
|||
DoStrongReleaseTests();
|
||||
DoStrongReleaseTests();
|
||||
DoWeakCycleTests();
|
||||
DoStrongCompareTests();
|
||||
|
||||
DoForwardReferenceTest();
|
||||
DoStrongForwardReferenceTest();
|
||||
|
|
|
@ -970,6 +970,95 @@ void friend_handling2()
|
|||
BaseClass * pNull ;
|
||||
Ptr w1( new BaseClass );
|
||||
ReleaseAll( w1, pNull );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void DoStrongCompareTests( void )
|
||||
{
|
||||
Earth * p1 = new Earth;
|
||||
Earth * p2 = new Earth;
|
||||
Earth_StrongPtr sp1( p1 );
|
||||
Earth_StrongPtr sp2( p2 );
|
||||
const bool isOneLess = ( p1 < p2 );
|
||||
if ( isOneLess )
|
||||
{
|
||||
assert( sp1 < p2 );
|
||||
assert( sp1 < sp2 );
|
||||
assert( sp1 <= p2 );
|
||||
assert( sp1 <= sp2 );
|
||||
assert( sp1 <= p1 );
|
||||
assert( sp1 == p1 );
|
||||
assert( sp1 == sp1 );
|
||||
assert( sp1 != p2 );
|
||||
assert( sp1 != sp2 );
|
||||
assert( sp2 > p1 );
|
||||
assert( sp2 > sp1 );
|
||||
assert( sp2 >= p1 );
|
||||
assert( sp2 >= sp1 );
|
||||
assert( sp2 >= p2 );
|
||||
assert( sp2 == p2 );
|
||||
assert( sp2 == sp2 );
|
||||
assert( sp2 != p1 );
|
||||
assert( sp2 != sp1 );
|
||||
assert( p1 < p2 );
|
||||
assert( p1 < sp2 );
|
||||
assert( p1 <= p2 );
|
||||
assert( p1 <= sp2 );
|
||||
assert( p1 <= sp1 );
|
||||
assert( p1 == p1 );
|
||||
assert( p1 == sp1 );
|
||||
assert( p1 != p2 );
|
||||
assert( p1 != sp2 );
|
||||
assert( p2 > p1 );
|
||||
assert( p2 > sp1 );
|
||||
assert( p2 >= p1 );
|
||||
assert( p2 >= sp1 );
|
||||
assert( p2 >= sp2 );
|
||||
assert( p2 == p2 );
|
||||
assert( p2 == sp2 );
|
||||
assert( p2 != p1 );
|
||||
assert( p2 != sp1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( sp2 < p1 );
|
||||
assert( sp2 < sp1 );
|
||||
assert( sp2 <= p1 );
|
||||
assert( sp2 <= p2 );
|
||||
assert( sp2 <= sp1 );
|
||||
assert( sp2 == p2 );
|
||||
assert( sp2 == sp2 );
|
||||
assert( sp2 != p1 );
|
||||
assert( sp2 != sp1 );
|
||||
assert( sp1 > p2 );
|
||||
assert( sp1 > sp2 );
|
||||
assert( sp1 >= p2 );
|
||||
assert( sp1 >= p1 );
|
||||
assert( sp1 >= sp2 );
|
||||
assert( sp1 == p1 );
|
||||
assert( sp1 == sp1 );
|
||||
assert( sp1 != p2 );
|
||||
assert( sp1 != sp2 );
|
||||
assert( p2 < p1 );
|
||||
assert( p2 < sp1 );
|
||||
assert( p2 <= p1 );
|
||||
assert( p2 <= sp1 );
|
||||
assert( p2 <= sp2 );
|
||||
assert( p2 == p2 );
|
||||
assert( p2 == sp2 );
|
||||
assert( p2 != p1 );
|
||||
assert( p2 != sp1 );
|
||||
assert( p1 > p2 );
|
||||
assert( p1 > sp2 );
|
||||
assert( p1 >= p2 );
|
||||
assert( p1 >= sp2 );
|
||||
assert( p1 >= sp1 );
|
||||
assert( p1 == p1 );
|
||||
assert( p1 == sp1 );
|
||||
assert( p1 != p2 );
|
||||
assert( p1 != sp2 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue