Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

test-smart_pointer.cc

00001 /*
00002 *  Name:      test-smart_pointer.cc
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   Test for smart pointer
00005 *  Date:      $Date: 2003/04/14 00:18:35 $
00006 *  Revision:  $Revision: 1.1 $
00007 *
00008 *  Copyright (C) 1994-2002  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00009 *
00010 *  This program is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
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 *  You should have received a copy of the GNU General Public License
00021 *  along with this program; if not, write to the Free Software
00022 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 *  MA 02111-1307, USA.
00024 */
00025 
00026 #include <memory>
00027 #include <mpcl/memory/alloc_smart_pointer.hh>
00028 #include <mpcl/memory/smart_pointer.hh>
00029 #include <mpcl/util/general-functions.hh>
00030 #include <mpcl/test.h>
00031 #include <vector>
00032 
00033 
00034 using mpcl::memory::TAllocSmartPointer;
00035 using mpcl::memory::TSmartPointer;
00036 using std::allocator;
00037 using std::vector;
00038 
00039 
00040 //
00041 //  L O C A L   T Y P E S
00042 //
00043 
00048 class TMother
00049 {
00050 
00051   protected:
00052 
00053     int   iMother;
00054 
00055 
00056   public:
00057 
00058     TMother (void) :
00059       iMother (0)  {}
00060 
00061 };  // TMother
00062 
00063 
00064 class TFather
00065 {
00066 
00067   protected:
00068 
00069     int&   riValue;
00070 
00071     
00072   public:
00073 
00074     TFather (int& riVALUE) :
00075       riValue (riVALUE)
00076     {
00077       riValue += 1;
00078     }
00079     
00080     virtual ~TFather (void)
00081     {
00082       riValue -= 1;
00083     }
00084 
00085     virtual bool isFather (void) const
00086     {
00087       return true;
00088     }
00089 
00090 };  // class TFather
00091 
00092 
00093 class TSon       :
00094   public TMother ,
00095   public TFather
00096 {
00097 
00098   public:
00099 
00100     int   iAnotherValue;
00101 
00102 
00103   public:
00104 
00105     TSon (int& riVALUE)       :
00106       TMother       ()        ,
00107       TFather       (riVALUE) ,
00108       iAnotherValue (0)
00109     {
00110       riValue += 10;
00111     }
00112     
00113     ~TSon (void)
00114     {
00115       riValue -= 10;
00116     }
00117 
00118     bool isFather (void) const
00119     {
00120       return false;
00121     }
00122 
00123 };  // class TSon
00124 
00125 
00126 //
00127 //  L O C A L   V A R I A B L E S
00128 //
00129 
00130 // <DELETE>
00131 // static int                                           _iValue;
00132 // static TFather*                                      _ptNewFather;
00133 // static allocator<TFather>                       _tFatherAllocator;
00134 // static TAllocSmartPointer<TFather>             _qtFather (_tFatherAllocator);
00135 // </DELETE>
00136 static vector<int*>                       _tIntArray;
00137 static vector<TSmartPointer<int> >        _tIntSmartPointerVector;
00138 static vector<TAllocSmartPointer<int> >   _tIntAllocSmartPointerVector;
00139 
00140 
00141 //
00142 //  L O C A L   F U N C T I O N S
00143 //
00144 
00145 static void _Insert (int* piSOURCE)
00146 {
00147   _tIntArray.push_back (piSOURCE);
00148 }
00149 
00150 
00151 static void _InsertAllocSmartPointer (int* piSOURCE)
00152 {
00153   _tIntAllocSmartPointerVector.push_back (TAllocSmartPointer<int> (piSOURCE));
00154 }
00155 
00156 
00157 static void _InsertSmartPointer (int* piSOURCE)
00158 {
00159   _tIntSmartPointerVector.push_back (TSmartPointer<int> (piSOURCE));
00160 }
00161 
00162 
00163 static TFather* _ReturnPointerToFather (TFather* ptFATHER)
00164 {
00165   return ptFATHER;
00166 }
00167 
00168 
00169 static TAllocSmartPointer<TFather>
00170 _ReturnAllocSmartPointerToFather (TAllocSmartPointer<TFather>& rqtFATHER)
00171 {
00172 
00173 // <FIXME>
00174 //   static allocator<int>                 _tIntAllocator;
00175 //   static int                                 _iValue (0);
00176 //   static int*                                _piNewValue (_tIntAllocator.allocate (1));
00177 //   static TAllocSmartPointer<TFather>   _qtFather (new (_piNewValue) TFather (_iValue));
00178 // </FIXME>
00179 // <DEBUG>
00180 //   if ( !_iValue )
00181 //   {
00182 //     std::cerr << "#_ReturnAllocSmartPointerToFather: new (" << _ptNewFather << ") TFather (" << _iValue << ")" << std::endl;
00183 //     _iValue = 1;
00184 //   }
00185 // </DEBUG>
00186   return rqtFATHER;
00187 
00188 }  // _ReturnAllocSmartPointerToFather()
00189 
00190 
00191 static TSmartPointer<TFather>
00192 _ReturnSmartPointerToFather (TSmartPointer<TFather>& rqtFATHER)
00193 {
00194   return rqtFATHER;
00195 }
00196 
00197 
00198 static TAllocSmartPointer<TFather>&
00199 _ReturnAllocSmartPointerReferenceToFather (TAllocSmartPointer<TFather>& rqtFATHER)
00200 {
00201 
00202 // <DELETE>
00203 //   static allocator<TFather>             _tFatherAllocator;
00204 //   static int                                 _iValue (0);
00205 //   static TFather*                            _ptNewFather (_tFatherAllocator.allocate (1));
00206 //   static TAllocSmartPointer<TFather>   _qtFather ((_tFatherAllocator.construct (_ptNewFather, _iValue), _ptNewFather), _tFatherAllocator);
00207 // </DELETE>
00208 // <DEBUG>
00209 //   if ( !_iValue )
00210 //   {
00211 //     std::cerr << "#_ReturnAllocSmartPointerReferenceToFather: new (" << _ptNewFather << ") TFather (" << _iValue << ")" << std::endl;
00212 //     _iValue = 1;
00213 //   }  
00214 // </DEBUG>
00215   return rqtFATHER;
00216 
00217 }  // _ReturnAllocSmartPointerReferenceToFather()
00218 
00219 
00220 static TSmartPointer<TFather>&
00221 _ReturnSmartPointerReferenceToFather (TSmartPointer<TFather>& rqtFATHER)
00222 {
00223   return rqtFATHER;
00224 }
00225 
00226 
00227 static int _TestAllocators (void)
00228 {
00229 
00230   TEST_INIT ("tests for class 'TAllocSmartPointer'");
00231 
00232   TAllocSmartPointer<int, allocator>   qtInt;
00233   allocator<int>                       tIntAllocator;
00234   int*                                 ptInt = tIntAllocator.allocate (1);
00235 
00236   tIntAllocator.construct (ptInt, 1);
00237   qtInt = ptInt;
00238   TEST_NUMBERS (1, *qtInt);
00239   qtInt = NULL;
00240   
00241   TEST_MEMORY_STATUS;
00242   TEST_RETURN_CODE;
00243 
00244 }  // _TestAllocators()
00245 
00246 
00247 static int _TestAssigns (void)
00248 {
00249 
00250   typedef
00251     TSmartPointer<int>
00252     QTInt;
00253 
00254   typedef
00255     TSmartPointer<const int>
00256     QKTInt;
00257 
00258   TEST_INIT ("tests for assigns");
00259 
00260   int   iValue = 100;
00261 
00262   //
00263   //  Test for destructors and assigns.
00264   //
00265   {
00266     TSmartPointer<TFather>   qtFather;
00267     TSmartPointer<TSon>      qtSon1;
00268     TSmartPointer<TSon>      qtSon2;
00269     TSmartPointer<int>       qiInt;
00270     TSon*                    ptSon = NULL;
00271 
00272     //
00273     //  Creates a new TFather instance:
00274     //
00275     //    iValue += 1;
00276     //    ( 101 == iValue );
00277     //
00278     qtFather = new TFather (iValue);
00279     TEST_NUMBERS (101, iValue);
00280 
00281     //
00282     //  Creates a new TSon instance:
00283     //
00284     //    iValue += 1;
00285     //    iValue += 10;
00286     //    ( 112 == iValue );
00287     //
00288     qtSon1 = new TSon (iValue);
00289     TEST_NUMBERS (112,   iValue);
00290     TEST_NUMBERS (true,  qtFather->isFather());
00291     TEST_NUMBERS (false, qtSon1->isFather());
00292 
00293     //
00294     //  Tries  to mutate a  TFather instance  into a  TSon instance.  This test
00295     //  ensures that there is no success.
00296     //
00297     try
00298     {
00299       qtFather.dynamicCast<TSon*>();
00300       TEST_FAIL;
00301     }
00302     catch (const mpcl::TConstraintException&)
00303     {
00304       TEST_PASS;
00305     }
00306 
00307     //
00308     //  Destroys the TFather instance (in qtFather):
00309     //
00310     //    iValue -= 1;
00311     //    ( 111 == iValue );
00312     //
00313     qtFather = NULL;
00314     TEST_NUMBERS (111, iValue);
00315 
00316     //
00317     //  Copies qtSon1 on qtSon1, so there is no change.
00318     //
00319     qtSon1 = qtSon1;
00320     TEST_NUMBERS (111,   iValue);
00321     TEST_NUMBERS (false, qtSon1->isFather());
00322     TEST_NUMBERS (1,     qtSon1.references());
00323     TEST_NUMBERS (true,  ( qtSon1 == qtSon1 ));
00324 
00325     //
00326     //  Creates a new TSon instance:
00327     //
00328     //    iValue += 1;
00329     //    iValue += 10;
00330     //    ( 122 == iValue );
00331     //
00332     qtSon2 = new TSon (iValue);
00333     TEST_NUMBERS (122, iValue);
00334 
00335     //
00336     //  Does a dynamic cast, so there is no change.
00337     //
00338     ptSon = qtSon1.dynamicCast<TSon*>();
00339     TEST_NUMBERS (122,   iValue);
00340     TEST_NUMBERS (false, ptSon->isFather());
00341     TEST_NUMBERS (false, qtSon2->isFather());
00342     TEST_NUMBERS (1,     qtSon2.references());
00343   }
00344   TEST_NUMBERS (100, iValue);
00345 
00346   //
00347   //  Tests conversion constructors.
00348   //
00349   {
00350     QTInt    qtInt;
00351     QKTInt   qktInt;
00352 
00353     qtInt  = new int (1);
00354     qktInt = new int (2);
00355     TEST_NUMBERS (*qtInt,                       1);
00356     TEST_NUMBERS (*qktInt,                      2);
00357     TEST_NUMBERS ((*QKTInt (qtInt)),            1);
00358     TEST_NUMBERS ((*QKTInt (qktInt)),           2);
00359     TEST_NUMBERS (QKTInt (qtInt).references(),  2);
00360     TEST_NUMBERS (QKTInt (qktInt).references(), 2);
00361     TEST_NUMBERS (true,                         ( qktInt.constCast<int*>() != NULL ));
00362     {
00363       QTInt   qtInnerInt;
00364       
00365       qtInnerInt = new int (3);
00366       qtInt      = qtInnerInt;
00367       TEST_NUMBERS (*qtInt,                  3);
00368       TEST_NUMBERS (*qtInnerInt,             3);
00369       TEST_NUMBERS (qtInt.references(),      2);
00370       TEST_NUMBERS (qtInnerInt.references(), 2);
00371       TEST_NUMBERS (qtInnerInt,              qtInt);
00372     }
00373     TEST_NUMBERS (*qtInt,             3);
00374     TEST_NUMBERS (qtInt.references(), 1);
00375     qtInt = new int (4);
00376     TEST_NUMBERS (*qtInt,             4);
00377     TEST_NUMBERS (qtInt.references(), 1);
00378   }
00379   
00380   TEST_MEMORY_STATUS;
00381   TEST_RETURN_CODE;
00382 
00383 }  // _TestAssigns()
00384 
00385 
00386 static int _TestBenchmarks (void)
00387 {
00388 
00389   vector<int*>::iterator        I;
00390   int*                          piNewInt;
00391   TFather*                      ptAllocFather;
00392   TAllocSmartPointer<TFather>   qtAllocFather;
00393   TSmartPointer<TFather>        qtFather;
00394   allocator<TFather>            tFatherAllocator;
00395   allocator<int>                tIntAllocator;
00396   int                           iValue   = 0;
00397   TFather*                      ptFather = new TFather (iValue);
00398 
00399   TEST_INIT ("benchmarks for smart pointers insertion/returning");
00400 
00401   //
00402   //  Initializes common data.
00403   //
00404   ptAllocFather = tFatherAllocator.allocate (1);
00405   tFatherAllocator.construct (ptAllocFather, iValue);
00406   qtAllocFather = ptAllocFather;
00407   qtFather      = new TFather (iValue);
00408 
00409   TEST_START_WATCH;
00410   for (size_t J = 0; ( J < 100000 ) ;++J)
00411   {
00412     _Insert (new int (J));
00413   }
00414   TEST_STOP_WATCH;
00415   TEST_DISPLAY_WATCH ("C++ standard pointer insertion");
00416 
00417   TEST_START_WATCH;
00418   for (size_t J = 0; ( J < 100000 ) ;++J)
00419   {
00420     _InsertSmartPointer (new int (J));
00421   }
00422   TEST_STOP_WATCH;
00423   TEST_DISPLAY_WATCH ("TSmartPointer insertion");
00424 
00425   TEST_START_WATCH;
00426   for (size_t J = 0; ( J < 100000 ) ;++J)
00427   {
00428     piNewInt = tIntAllocator.allocate (1);
00429     tIntAllocator.construct (piNewInt, J);
00430     _InsertAllocSmartPointer (piNewInt);
00431   }
00432   TEST_STOP_WATCH;
00433   TEST_DISPLAY_WATCH ("TAllocSmartPointer insertion");
00434 
00435   TEST_START_WATCH;
00436   for (size_t J = 0; ( J < 400000 ) ;++J)
00437   {
00438     _ReturnPointerToFather (ptFather);
00439   }
00440   TEST_STOP_WATCH;
00441   TEST_DISPLAY_WATCH ("C++ standard pointer returning");
00442 
00443   TEST_START_WATCH;
00444   for (size_t J = 0; ( J < 400000 ) ;++J)
00445   {
00446     _ReturnSmartPointerToFather (qtFather);
00447   }
00448   TEST_STOP_WATCH;
00449   TEST_DISPLAY_WATCH ("TSmartPointer returning");
00450 
00451   TEST_START_WATCH;
00452   for (size_t J = 0; ( J < 400000 ) ;++J)
00453   {
00454     _ReturnAllocSmartPointerToFather (qtAllocFather);
00455   }
00456   TEST_STOP_WATCH;
00457   TEST_DISPLAY_WATCH ("TAllocSmartPointer returning");
00458 
00459   TEST_START_WATCH;
00460   for (size_t J = 0; ( J < 400000 ) ;++J)
00461   {
00462     _ReturnSmartPointerReferenceToFather (qtFather);
00463   }
00464   TEST_STOP_WATCH;
00465   TEST_DISPLAY_WATCH ("TSmartPointer reference returning");
00466 
00467   TEST_START_WATCH;
00468   for (size_t J = 0; ( J < 400000 ) ;++J)
00469   {
00470     _ReturnAllocSmartPointerReferenceToFather (qtAllocFather);
00471   }
00472   TEST_STOP_WATCH;
00473   TEST_DISPLAY_WATCH ("TAllocSmartPointer reference returning");
00474 
00475   //
00476   //  Clean not smart-pointer managed objects.
00477   //
00478   delete ptFather;
00479   for (I = _tIntArray.begin(); ( I != _tIntArray.end() ) ;++I)
00480   {
00481     delete *I;
00482   }
00483 
00484   TEST_MEMORY_STATUS;
00485   TEST_RETURN_CODE;
00486 
00487 }  // _TestBenchmarks()
00488 
00489 
00490 static int _TestCastings (void)
00491 {
00492 
00493   int                            iValue;
00494   TFather*                       ptFather;
00495   TSon*                          ptSon;
00496   TSmartPointer<TFather>   qtFather (new TFather (iValue));
00497   TSmartPointer<TFather>   qtSon (new TSon (iValue));
00498   TSmartPointer<TFather>   qtAnotherFather (qtFather);
00499   
00500   TEST_INIT ("test for castings");
00501   TEST_NUMBERS (true, qtAnotherFather->isFather());
00502   qtAnotherFather = qtSon;
00503   TEST_NUMBERS (false, qtAnotherFather->isFather());
00504 
00505   //
00506   //  Converts from a TFather instance  to a  TSon instance which must throw an
00507   //  exception.
00508   //
00509   try
00510   {
00511     //
00512     //  Converts from TFather* to TSon* (error).
00513     //
00514     qtAnotherFather = qtFather;
00515     ptSon           = qtAnotherFather.dynamicCast<TSon*>();
00516     TEST_FAIL;
00517   }
00518   catch (const mpcl::TConstraintException&)
00519   {
00520     TEST_PASS;
00521   }
00522 
00523   try
00524   {
00525     //
00526     //  Converts a TSon instance to a TFather instance, which is ok.
00527     //
00528     qtAnotherFather = qtSon;
00529     ptFather        = qtAnotherFather.get();
00530     TEST_PASS;
00531   }
00532   catch (const mpcl::TConstraintException&)
00533   {
00534     TEST_FAIL;
00535   }
00536 
00537   //
00538   //  Benchmarks old castings.
00539   //
00540   TEST_START_WATCH;
00541   for (size_t J = 0; ( J < 1000000 ) ;++J)
00542   {
00543     ptSon = (TSon*) ptFather;
00544   }
00545   TEST_STOP_WATCH;
00546   TEST_DISPLAY_WATCH ("C++ standard casting");
00547 
00548   //
00549   //  Benchmarks down-castings.
00550   //
00551   TEST_START_WATCH;
00552   qtAnotherFather = qtSon;
00553   for (size_t J = 0; ( J < 1000000 ) ;++J)
00554   {
00555     ptSon = qtAnotherFather.dynamicCast<TSon*>();
00556   }
00557   TEST_STOP_WATCH;
00558   TEST_DISPLAY_WATCH ("TSmartPointer casting");
00559   TEST_MEMORY_STATUS;
00560   TEST_RETURN_CODE;
00561 
00562 }  // _TestCastings()
00563 
00564 
00565 static int _TestContainers (void)
00566 {
00567 
00568   TEST_INIT ("test for smart pointers and containers");
00569 
00570   vector<TSmartPointer<TFather> >   tFatherSmartPointerVector1;
00571   vector<TSmartPointer<TFather> >   tFatherSmartPointerVector2;
00572   int                               iValue = 0;
00573 
00574   TEST_START_WATCH;
00575   for (size_t J = 0; ( J < 100000 ) ;++J)
00576   {
00577     tFatherSmartPointerVector1.push_back (TSmartPointer<TFather> (new TFather (iValue)));
00578     tFatherSmartPointerVector2.push_back (TSmartPointer<TFather> (tFatherSmartPointerVector1.back()));
00579     tFatherSmartPointerVector1.push_back (TSmartPointer<TFather> (new TSon (iValue)));
00580     tFatherSmartPointerVector2.push_back (TSmartPointer<TFather> (tFatherSmartPointerVector1.back()));
00581   }
00582   TEST_STOP_WATCH;
00583   TEST_DISPLAY_WATCH ("container with 400.000 items");
00584   TEST_MEMORY_STATUS;
00585   TEST_RETURN_CODE;
00586 
00587 }  // _TestContainers()
00588 
00589 
00590 static int _TestCopyConstructors (TSmartPointer<int> qiSOURCE, int iREAL_VALUE)
00591 {
00592 
00593   TEST_INIT ("test for copy constructors");
00594   TEST_NUMBERS (iREAL_VALUE, *qiSOURCE);
00595   TEST_MEMORY_STATUS;
00596   TEST_RETURN_CODE;
00597 
00598 }  // _TestCopyConstructors()
00599 
00600 
00602 int main (void)
00603 {
00604 
00605   TEST_INIT ("tests for class 'TSmartPointer'");
00606 
00607   TSmartPointer<int>   qiAnotherInteger;
00608   TSmartPointer<int>   qiOtherInteger;
00609   TSmartPointer<int>   qiMyInteger (new int (10));
00610 
00611 //   _iValue      = 0;
00612 //   _ptNewFather = _tFatherAllocator.allocate (1);
00613 //   _tFatherAllocator.construct (_ptNewFather, _iValue);
00614 //   _qtFather = _ptNewFather;
00615 // // <DEBUG>
00616 //   std::cerr << "#main: _iValue = " << _iValue << std::endl;
00617 // //   std::cerr << "#main: qiMyInteger is bound to " << qiMyInteger.get() << std::endl;
00618 //   std::cerr << "#main: construct (" << _ptNewFather << ")" << std::endl;
00619 //   std::cerr << "#main: construct (" << _qtFather.get() << ")" << std::endl;
00620 // // </DEBUG>
00621 
00622 //   _qtFather    = NULL;
00623 //   _ptNewFather = _tFatherAllocator.allocate (1);
00624 //   _tFatherAllocator.construct (_ptNewFather, _iValue);
00625 //   _qtFather = _ptNewFather;
00626 // // <DEBUG>
00627 //   std::cerr << "#main: _iValue = " << _iValue << std::endl;
00628 // //   std::cerr << "#main: qiMyInteger is bound to " << qiMyInteger.get() << std::endl;
00629 //   std::cerr << "#main: construct (" << _ptNewFather << ")" << std::endl;
00630 //   std::cerr << "#main: construct (" << _qtFather.get() << ")" << std::endl;
00631 // // </DEBUG>
00632 
00633 //   _qtFather    = NULL;
00634 //   _ptNewFather = _tFatherAllocator.allocate (1);
00635 //   _tFatherAllocator.construct (_ptNewFather, _iValue);
00636 //   _qtFather = _ptNewFather;
00637 // // <DEBUG>
00638 //   std::cerr << "#main: _iValue = " << _iValue << std::endl;
00639 // //   std::cerr << "#main: qiMyInteger is bound to " << qiMyInteger.get() << std::endl;
00640 //   std::cerr << "#main: construct (" << _ptNewFather << ")" << std::endl;
00641 //   std::cerr << "#main: construct (" << _qtFather.get() << ")" << std::endl;
00642 // // </DEBUG>
00643 
00644   TEST_NUMBERS (10, *qiMyInteger);
00645   TEST_NUMBERS (1,  qiMyInteger.references());
00646   *qiMyInteger = 11;
00647   TEST_NUMBERS (11, *qiMyInteger);
00648   qiOtherInteger   = qiMyInteger;
00649   qiAnotherInteger = qiOtherInteger;
00650   TEST_NUMBERS (3,  qiMyInteger.references());
00651   TEST_NUMBERS (11, *qiMyInteger);
00652   TEST_NUMBERS (11, *qiOtherInteger);
00653   TEST_NUMBERS (11, *qiAnotherInteger);
00654 
00655   *qiAnotherInteger = 9;
00656   TEST_NUMBERS (9,           *qiMyInteger);
00657   TEST_NUMBERS (9,           *qiOtherInteger);
00658   TEST_NUMBERS (9,           *qiAnotherInteger);
00659   TEST_NUMBERS (qiMyInteger, qiMyInteger);
00660   TEST_NUMBERS (qiMyInteger, qiOtherInteger);
00661   TEST_NUMBERS (qiMyInteger, qiAnotherInteger);
00662   TEST_NUMBERS (3,           qiMyInteger.references());
00663 
00664   qiOtherInteger = new int (100);
00665   TEST_NUMBERS (9,   *qiMyInteger);
00666   TEST_NUMBERS (100, *qiOtherInteger);
00667   TEST_NUMBERS (9,   *qiAnotherInteger);
00668   TEST_NUMBERS (2,   qiMyInteger.references());
00669 
00670   qiAnotherInteger = qiOtherInteger;
00671   TEST_NUMBERS (9,              *qiMyInteger);
00672   TEST_NUMBERS (100,            *qiOtherInteger);
00673   TEST_NUMBERS (100,            *qiAnotherInteger);
00674   TEST_NUMBERS (qiMyInteger,    qiMyInteger);
00675   TEST_NUMBERS (qiOtherInteger, qiOtherInteger);
00676   TEST_NUMBERS (qiOtherInteger, qiAnotherInteger);
00677   TEST_NUMBERS (1,              qiMyInteger.references());
00678   TEST_NUMBERS (2,              qiOtherInteger.references());
00679 
00680   *qiAnotherInteger = 101;
00681   TEST_NUMBERS (  9, *qiMyInteger);
00682   TEST_NUMBERS (101, *qiOtherInteger);
00683   TEST_NUMBERS (101, *qiAnotherInteger);
00684   TEST_NUMBERS (qiMyInteger,    qiMyInteger);
00685   TEST_NUMBERS (qiOtherInteger, qiOtherInteger);
00686   TEST_NUMBERS (qiOtherInteger, qiAnotherInteger);
00687 
00688   qiMyInteger = new int (1000);
00689   qiMyInteger = new int (1001);
00690   qiMyInteger = new int (1002);
00691   TEST_NUMBERS (1002,           *qiMyInteger);
00692   TEST_NUMBERS (101,            *qiOtherInteger);
00693   TEST_NUMBERS (101,            *qiAnotherInteger);
00694   TEST_NUMBERS (qiMyInteger,    qiMyInteger);
00695   TEST_NUMBERS (qiOtherInteger, qiOtherInteger);
00696   TEST_NUMBERS (qiOtherInteger, qiAnotherInteger);
00697   TEST_NUMBERS (1,              qiMyInteger.references());
00698  
00699   TEST_FUNCTION (_TestAllocators());
00700   TEST_FUNCTION (_TestAssigns());
00701   TEST_FUNCTION (_TestBenchmarks());
00702   TEST_FUNCTION (_TestCastings());
00703   TEST_FUNCTION (_TestContainers());
00704   TEST_FUNCTION (_TestCopyConstructors (qiMyInteger,      1002));
00705   TEST_FUNCTION (_TestCopyConstructors (qiOtherInteger,   101));
00706   TEST_FUNCTION (_TestCopyConstructors (qiAnotherInteger, 101));
00707 
00708   qiMyInteger = NULL;
00709   TEST_NUMBERS (true,  !qiMyInteger);
00710   TEST_NUMBERS (false, !qiAnotherInteger);
00711 
00712   TEST_MEMORY_STATUS;
00713   TEST_RETURN_CODE;
00714 
00715 }  // main()

Generated on Mon Oct 13 02:35:24 2003 for MPCL by doxygen1.2.18