Ejemplo n.º 1
0
int main(){

    /** Unique pointers does not take additional memory. */
    std::cout<<"sizeof(unique_ptr<int>):"<<(int)sizeof(std::unique_ptr<int>)<<std::endl;
    std::cout<<"sizeof(int*):"<<(int)sizeof(int*)<<std::endl;

    /** Test to prove that Infector does not cause memory leaks due to
    *   unkown evaluation order of constructors' parameters when construcors
    *   throws exceptions. This is a big advantage.*/
#ifndef INFECTOR_VS_DISABLE  //disabled on visual studio due to a compiler bug
    LeakTest();
    /** Basic usage test, no shared objects. Creates a small object graph
    *   with unique ownership semantics.*/
    BedTest();
    /** This test assure that exception is thrown in case there's a circular
    *   dependency. */
    CircularTest();
#endif
    /** Basic usage test this time shared objects are used and multiple
    *   inheritance is tested.*/
    SharedTest();
    /** Multiple inheritance test failure.*/
    MultiBaseFailure();
#ifndef INFECTOR_VS_DISABLE  //disabled on visual studio due to a compiler bug
    /** Can instantiate only bound types. Verify that.*/
    InstantiateConcreteMustFail();
#endif

    /**Same as Leak test1, but use shared_ptr instead of unique_ptr*/
    LeakTest2();

    /**Same as BedTest, but use shared_ptr instead of unique_ptr*/
    BedTest2();

    /**Same as Circular test, but use shared_ptr instead of unique_ptr*/
    CircularTest2();

    return 0;
}
Ejemplo n.º 2
0
//______________________________________________________________________________
void testSt345Pads()
{
  AliMpDataProcessor mp;
  AliMpDataMap* dataMap = mp.CreateDataMap("data");
  AliMpDataStreams dataStreams(dataMap);

  AliMpSlatMotifMap* motifMap = new AliMpSlatMotifMap();
  AliMpSt345Reader reader(motifMap);
  
  Int_t ok(0);
  
  for ( Int_t i = 0; i < NSLATS; ++i ) 
  {
    Bool_t slatOK(kTRUE);
    
    TString slatName( slatTypeNames[i] );
    
    AliMpSlat* bending = reader.ReadSlat(dataStreams,slatName.Data(),AliMp::kBendingPlane);
    AliMpSlat* nonbending = reader.ReadSlat(dataStreams,slatName.Data(),AliMp::kNonBendingPlane);
  
    Int_t NumberOfBendingPads(0);
    Int_t NumberOfNonBendingPads(0);
    Int_t xcheck_b(0);
    Int_t xcheck_nb(0);
    Int_t nc_b(0);
    Int_t nc_nb(0);
    
    if ( bending )
    {
      NumberOfBendingPads = Count(*bending);
      xcheck_b = Iterate(*bending);   
      nc_b = CircularTest(*bending);   
    }
    else
    {
      cout << "Could not read bending plane of slat " << slatName.Data() << endl;
    }
    
    if ( nonbending ) 
    {
      NumberOfNonBendingPads = Count(*nonbending);
      xcheck_nb = Iterate(*nonbending);
      nc_nb = CircularTest(*nonbending);
    }
    else
    {
      cout << "Could not read bending plane of slat " << slatName.Data() << endl;
    }
    
    cout << setw(10) << slatName
      << " BENDING : " << setw(5) << NumberOfBendingPads
      << " NONBENDING : " << setw(5) << NumberOfNonBendingPads
      << " CT for " << (nc_b+nc_nb) << " pads ";
    
    if ( nc_b>0 && nc_nb>0 ) 
    {
      cout << "OK.";
    }
    else
    {
      slatOK = kFALSE;
      cout << "FAILED.";
    }
    cout << endl;

    if ( nonbending ) XCheck(*nonbending);
    if ( bending ) XCheck(*bending);

    if ( xcheck_b != NumberOfBendingPads )
    {
      cout << setw(20) << " Bending : HasPad and Iterator give different results !" 
      << " " << NumberOfBendingPads << " vs " << xcheck_b << endl;
      slatOK = kFALSE;
    }
    if ( xcheck_nb != NumberOfNonBendingPads )
    {
      cout << setw(20) << " NonBending : HasPad and Iterator give different results !"
      << " " << NumberOfNonBendingPads << " vs " << xcheck_nb << endl;
      slatOK = kFALSE;
    }

    if (slatOK) ++ok;
   }
  
  if ( ok == NSLATS ) 
  {
    cout << "Successfully tested " << ok << " slats" << endl;
  }
  else
  {
    cout << "Failed to read " << (NSLATS-ok) << " out of " << NSLATS << " slats" << endl;
  }
}