pair.test.cc File Reference

unit test for lestes/std/ptr.hh More...

#include <lestes/common.hh>
#include <lestes/std/pair.hh>
#include <utility>

Go to the source code of this file.

Functions

int main ()


Detailed Description

unit test for lestes/std/ptr.hh

Author:
TMA

Rudo, added tests for pair::create( ::std::pair & )

Definition in file pair.test.cc.


Function Documentation

int main ( void   ) 

Definition at line 41 of file pair.test.cc.

References lassert.

00042 {
00043         ptr< pair<int,int> > q0 = pair<int,int>::create( 3, 4 );
00044         ptr< pair<int,int> > x0 = pair<int,int>::create( 3, 4 );
00045         ptr< pair<int,int> > y0 = pair<int,int>::create( x0 );
00046         ptr< pair<int,int> > z0 = pair<int,int>::create( );
00047 
00048         lassert(*q0 == *x0);
00049         lassert(*x0 == *q0);
00050         lassert(*y0 == *x0);
00051         lassert(*y0 != *z0);
00052 
00053         ptr< pair< srp <object>, int > > q1 = pair< srp<object>, int >::create( NULL, 4 );
00054         ptr< pair< srp <object>, int > > x1 = pair< srp<object>, int >::create( NULL, 4 );
00055         ptr< pair< srp <object>, int > > y1 = pair< srp<object>, int >::create( x1 );
00056         ptr< pair< srp <object>, int > > z1 = pair< srp<object>, int >::create( );
00057 
00058         lassert(*q1 == *x1);
00059         lassert(*x1 == *q1);
00060         lassert(*y1 == *x1);
00061         lassert(*y1 != *z1);
00062 
00063         ptr< pair< int, srp<object> > > q2 = pair< int, srp<object> >::create( 3, NULL );
00064         ptr< pair< int, srp<object> > > x2 = pair< int, srp<object> >::create( 3, NULL );
00065         ptr< pair< int, srp<object> > > y2 = pair< int, srp<object> >::create( x2 );
00066         ptr< pair< int, srp<object> > > z2 = pair< int, srp<object> >::create( );
00067 
00068         lassert(*q2 == *x2);
00069         lassert(*x2 == *q2);
00070         lassert(*y2 == *x2);
00071         lassert(*y2 != *z2);
00072 
00073         ptr< pair< srp<object>, srp<object> > > r3 = pair< srp<object>, srp <object> >::create( x0, x1 );
00074         ptr< pair< srp<object>, srp<object> > > q3 = pair< srp<object>, srp <object> >::create( NULL, NULL );
00075         ptr< pair< srp<object>, srp<object> > > x3 = pair< srp<object>, srp <object> >::create( NULL, NULL );
00076         ptr< pair< srp<object>, srp<object> > > y3 = pair< srp<object>, srp <object> >::create( x3 );
00077         ptr< pair< srp<object>, srp<object> > > z3 = pair< srp<object>, srp <object> >::create( );
00078 
00079         lassert(*q3 == *x3);
00080         lassert(*x3 == *q3);
00081         lassert(*y3 == *x3);
00082         lassert(*y3 == *z3);
00083 
00084         lassert(*r3 != *q3);
00085 
00086         /* creating from an instance of ::std::pair
00087          *
00088          * WARNING: what follows is brain-damaged and redundant. it tests the thing, however ;-)
00089          */
00090         ptr< pair<int,int> > m1 = pair<int,int>::create( ::std::make_pair(2,3) );
00091         ptr< pair< srp<object>, int > > m2 = pair< srp<object>, int >::create( ::std::make_pair(m1,3) );
00092         ptr< pair< int, srp<object> > > m3 = pair< int, srp<object> >::create( ::std::make_pair(2,m1) );
00093         ptr< pair< srp<object>, srp<object> > > m4 = pair< srp<object>, srp<object> >::create( ::std::make_pair(m2,m3) );
00094 
00095 
00096         return 0;
00097 }


Generated on Mon Feb 12 18:23:46 2007 for lestes by doxygen 1.5.1-20070107