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

CdbBdbTestCompilation.cc

Go to the documentation of this file.
00001 // File and Version Information:
00002 //      $Id: CdbBdbTestCompilation.cc,v 1.15 2004/08/06 05:54:34 bartoldu Exp $
00003 #include "BaBar/BaBar.hh"
00004 
00005 /// This is the implementation file for CdbBdbTestCompilation class.
00006 /**
00007   * @see CdbBdbTestCompilation
00008   */
00009 
00010 #include "CdbBdbTests/CdbBdbTestCompilation.hh"
00011 #include "CdbBdbTests/CdbBdbTestIterator.hh"
00012 
00013 #include "CdbBase/CdbCommon.hh"
00014 
00015 #include "CdbBase/Cdb.hh"
00016 #include "CdbBase/CdbDatabase.hh"
00017 #include "CdbBase/CdbView.hh"
00018 #include "CdbBase/CdbFolder.hh"
00019 #include "CdbBase/CdbCondition.hh"
00020 #include "CdbBase/CdbObject.hh"
00021 
00022 #include "CdbBase/CdbRevision.hh"
00023 #include "CdbBase/CdbRevisionPolicy.hh"
00024 #include "CdbBase/CdbHistoryEvent.hh"
00025 
00026 #include "CdbBase/CdbDatabaseItr.hh"
00027 #include "CdbBase/CdbViewItr.hh"
00028 #include "CdbBase/CdbFolderItr.hh"
00029 #include "CdbBase/CdbConditionItr.hh"
00030 #include "CdbBase/CdbObjectItr.hh"
00031 
00032 #include "CdbBase/CdbHistoryEventItr.hh"
00033 #include "CdbBase/CdbHistoryEventTypeItr.hh"
00034 #include "CdbBase/CdbPathNameItr.hh"
00035 
00036 #include "CdbBase/CdbPathName.hh"
00037 #include "CdbBase/CdbCompositeName.hh"
00038 #include "CdbBase/CdbId.hh"
00039 #include "CdbBase/CdbStateId.hh"
00040 #include "CdbBase/CdbEnvironment.hh"
00041 
00042 //#include "CdbBdb/CdbBdbTObjectFactory.hh"
00043 
00044 #include "BdbCond/BdbDataListsP.hh"
00045 
00046 #include <iostream>
00047 using std::cout;
00048 using std::endl;
00049 
00050 CdbBdbTestCompilation::CdbBdbTestCompilation( )
00051 {
00052     status( );
00053     smartPointersForInterfaces( );
00054     iterators( );
00055     miscClasses( );
00056 }
00057 
00058 void
00059 CdbBdbTestCompilation::status( )
00060 {
00061     cout << "CdbBdbTestCompilation::status() - OK" << endl
00062          << endl
00063          << "Describing self..." << endl
00064          << endl
00065          << "  This test exercises an alternative to a tradition method" << endl
00066          << "  of reporting status values from functions/methods calls." << endl
00067          << "  An idea is that the status is returned as an Active Object" << endl
00068          << "  rather than just a numeric value of an enumerated type." << endl;
00069 
00070     CdbStatus s1;
00071     CdbStatus s2( CdbStatus::Error );
00072     CdbStatus s3 = CdbStatus::NotImplemented;
00073 
00074     cout << endl
00075          << "Constructors and assignment operator(s)..." << endl
00076          << endl;
00077 
00078     cout << "  (default    ctor)     s1 = " << s1 << endl;
00079     cout << "  (normal     ctor)     s2 = " << s2 << endl;
00080     cout << "  (assignment operator) s3 = " << s3 << endl;
00081 
00082     cout << endl
00083          << "Comparision operators..." << endl
00084          << endl;
00085 
00086     cout << "  s1 " << ( s1 == s1 ? "==" : "!=" ) << " s1" << endl;
00087     cout << "  s1 " << ( s1 != s2 ? "!=" : "==" ) << " s2" << endl;
00088     cout << "  s2 " << ( s2 != s3 ? "!=" : "==" ) << " s3" << endl;
00089     cout << "  s3 " << ( s3 != s1 ? "!=" : "==" ) << " s1" << endl;
00090 
00091     cout << endl;
00092 
00093     cout << "CdbBdbTestCompilation::status() - OK" << endl;
00094 }
00095 
00096 /// Exercise a smart pointer
00097 /**
00098   * This test will check if the smart pointers are correctly
00099   * implemented in therms of their const/nono-const-ness.
00100   */
00101 template < class T >
00102 void
00103 exerciseSmartPointer( const T& thePtr )
00104 {
00105     T ptr1( thePtr );  // copy constructor
00106 
00107     T ptr2;
00108     ptr2 = thePtr;     // assignment operator
00109 }
00110 
00111 void
00112 CdbBdbTestCompilation::smartPointersForInterfaces( )
00113 {
00114     CdbPtr cdbPtr = 0;
00115     assert( cdbPtr.isNull( ));
00116     exerciseSmartPointer( cdbPtr );
00117 
00118     CdbDatabasePtr dPtr;
00119     assert( dPtr.isNull( ));
00120     exerciseSmartPointer( dPtr );
00121 
00122     CdbViewPtr vPtr;
00123     assert( vPtr.isNull( ));
00124     exerciseSmartPointer( vPtr );
00125 
00126     CdbFolderPtr fPtr;
00127     assert( fPtr.isNull( ));
00128     exerciseSmartPointer( fPtr );
00129 
00130     CdbConditionPtr cPtr;
00131     assert( cPtr.isNull( ));
00132     exerciseSmartPointer( cPtr );
00133 
00134     CdbObjectPtr oPtr;
00135     assert( oPtr.isNull( ));
00136     exerciseSmartPointer( oPtr );
00137 
00138     CdbRevisionPtr rPtr;
00139     assert( rPtr.isNull( ));
00140     exerciseSmartPointer( rPtr );
00141 
00142     CdbHistoryEventPtr ePtr;
00143     assert( ePtr.isNull( ));
00144     exerciseSmartPointer( ePtr );
00145 
00146     cout << "CdbBdbTestCompilation::smartPointersForInterfaces() - OK" << endl;
00147 }
00148 
00149 void
00150 CdbBdbTestCompilation::iterators( )
00151 {
00152     CdbBdbTestIterator< CdbDatabaseItr         >::exerciseIterator( );
00153     CdbBdbTestIterator< CdbViewItr             >::exerciseIterator( );
00154     CdbBdbTestIterator< CdbFolderItr           >::exerciseIterator( );
00155     CdbBdbTestIterator< CdbConditionItr        >::exerciseIterator( );
00156     CdbBdbTestIterator< CdbObjectItr           >::exerciseIterator( );
00157     CdbBdbTestIterator< CdbHistoryEventItr     >::exerciseIterator( );
00158     CdbBdbTestIterator< CdbHistoryEventTypeItr >::exerciseIterator( );
00159     CdbBdbTestIterator< CdbPathNameItr         >::exerciseIterator( );
00160 
00161     cout << "CdbBdbTestCompilation::iterators() - OK" << endl;
00162 }
00163 
00164 void
00165 CdbBdbTestCompilation::miscClasses( )
00166 {
00167     cout << "CdbBdbTestCompilation::miscClasses() - BEGIN" << endl;
00168 
00169     CdbPathName pName;
00170     CdbPathName pExtName( "/emc/EmcFooClassP" );
00171 
00172     CdbId id;
00173     assert(( 0 == id.origin ) && ( 0 == id.local ));
00174 
00175     CdbStateId stateId;
00176     assert( !stateId.isValid( ));
00177 
00178     CdbCompositeName cName1;
00179     assert( !cName1.isValid( ));
00180 
00181     CdbCompositeName cName2( "" );
00182     assert( !cName2.isValid( ));
00183 
00184     CdbCompositeName cName3( "::" );
00185     assert( !cName3.isValid( ));
00186 
00187     CdbCompositeName cName4( "first" );
00188     assert( !cName4.isValid( ));
00189 
00190     CdbCompositeName cName5( "first::" );
00191     assert( !cName5.isValid( ));
00192 
00193     CdbCompositeName cName6( "::last" );
00194     assert( !cName6.isValid( ));
00195 
00196     CdbCompositeName cName7( "first::last" );
00197     assert( cName7.isValid( ));
00198 
00199     cout << cName7.getName( ).c_str( ) << endl;
00200     cout << cName7.first( ).c_str( ) << CdbCompositeName::separator( ) << cName7.last( ).c_str( ) << endl;
00201 
00202     CdbCompositeName cName8( "first", 0 );
00203     assert( !cName8.isValid( ));
00204 
00205     CdbCompositeName cName9( 0, "last" );
00206     assert( !cName9.isValid( ));
00207 
00208     CdbCompositeName cName10( "first::", "last" );
00209     assert( !cName10.isValid( ));
00210 
00211     CdbCompositeName cName11( "first", "::last" );
00212     assert( !cName11.isValid( ));
00213 
00214     CdbCompositeName cName12( "first", "last" );
00215     assert( cName12.isValid( ));
00216 
00217     bool areEqual;
00218     
00219     areEqual = ( cName8 == cName1 );
00220     assert( !areEqual );
00221 
00222     areEqual = ( cName7 == cName12 );
00223     assert( areEqual );
00224 
00225 //////////////////////////////////////////////////////////
00226 // WARNING: Disabled because the application does not link
00227 //          on Linux.
00228 //
00229 //    CdbBdbTObjectFactory< const char* const, BdbDataListsP >* oFactory = 0;
00230 //
00231 
00232     cout << "CdbBdbTestCompilation::miscClasses() - END" << endl;
00233 }
00234 
00235 /////////////////
00236 // End Of File //
00237 /////////////////

Generated on Mon Dec 5 18:22:04 2005 for CDB by doxygen1.3-rc3