pair.test.cc

Go to the documentation of this file.
00001 /*
00002    The lestes compiler suite
00003    Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy
00004    Copyright (C) 2002, 2003, 2004, 2005 Petr Zika
00005    Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala
00006    Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina
00007    Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda
00008    Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar
00009    Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas
00010 
00011    This program is free software; you can redistribute it and/or modify
00012    it under the terms of the GNU General Public License as published by
00013    the Free Software Foundation; version 2 of the License.
00014 
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019 
00020    See the full text of the GNU General Public License version 2, and
00021    the limitations in the file doc/LICENSE.
00022 
00023    By accepting the license the licensee waives any and all claims
00024    against the copyright holder(s) related in whole or in part to the
00025    work, its use, and/or the inability to use it.
00026  
00027  */
00028 /*!
00029  * \file
00030  * \brief unit test for lestes/std/ptr.hh
00031  *
00032  * \author TMA
00033  * \author Rudo, added tests for pair::create( ::std::pair & )
00034  */
00035 #include <lestes/common.hh> 
00036 #include <lestes/std/pair.hh> 
00037 #include <utility>
00038 
00039 using namespace ::lestes::std;
00040 
00041 int main()
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:22:46 2007 for lestes by doxygen 1.5.1-20070107