BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
AthenaOutputStream_test.cxx File Reference

unit test for AtRndSvc More...

#include "AthenaKernel/IClassIDSvc.h"
#include "BesServices/AthenaOutputStream.h"
#include "GaudiKernel/IAlgManager.h"
#include "GaudiKernel/IAlgorithm.h"
#include "GaudiKernel/IDataSelector.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/SmartIF.h"
#include "StoreGate/StoreGateSvc.h"
#include "TestTools/initGaudi.h"
#include "ToyConversion/FooBar.h"
#include <cassert>
#include <iostream>
#include <vector>

Go to the source code of this file.

Functions

int main ()

Detailed Description

unit test for AtRndSvc

Author
Paolo Calafiura pcala.nosp@m.fiur.nosp@m.a@lbl.nosp@m..gov -ATLAS Collaboration
Id
AthenaOutputStream_test.cxx,v 1.1.1.1 2004/09/28 01:51:05 liwd Exp

Definition in file AthenaOutputStream_test.cxx.

Function Documentation

◆ main()

int main ( )

Definition at line 28 of file AthenaOutputStream_test.cxx.

28 {
29 cout << "*** AthenaOutputStream_test starts ***" << endl;
30 ISvcLocator* pSvcLoc( 0 );
31 if ( !initGaudi( "AthenaOutputStream_test.txt", pSvcLoc ) )
32 {
33 cerr << "This test can not be run" << endl;
34 return 0;
35 }
36 assert( pSvcLoc );
37
38 // locate necessary stuff
39 const bool CREATEIF( true );
40 IClassIDSvc* pCLIDSvc( 0 );
41 assert( ( pSvcLoc->service( "ClassIDSvc", pCLIDSvc, CREATEIF ) ).isSuccess() );
42 assert( pCLIDSvc );
43
44 StoreGateSvc* pStore( 0 );
45 assert( ( pSvcLoc->service( "StoreGateSvc", pStore, CREATEIF ) ).isSuccess() );
46 assert( pStore );
47
48 SmartIF<IAlgManager> algMan( IID_IAlgManager, pSvcLoc );
49 assert( algMan.isValid() );
50 IAlgorithm* pAlg( 0 );
51 assert( ( algMan->createAlgorithm( "AthenaOutputStream", "AthenaOutputStream", pAlg ) )
52 .isSuccess() );
53
54 assert( ( pAlg->sysInitialize() ).isSuccess() );
55 assert( ( pAlg->initialize() ).isSuccess() );
56
57 assert( ( pStore->record( new Foo(), "uno" ) ).isSuccess() );
58 assert( ( pStore->record( new Foo(), "due" ) ).isSuccess() );
59 assert( ( pStore->record( new Bar(), "uno" ) ).isSuccess() );
60 assert( ( pStore->record( new Bar(), "due" ) ).isSuccess() );
61
62 AthenaOutputStream* pStream( dynamic_cast<AthenaOutputStream*>( pAlg ) );
63 assert( pStream );
64
65 // fill the vector of selected objects
66 pStream->collectAllObjects();
67
68 // cout << pStream->selectedObjects()->end() -
69 // pStream->selectedObjects()->begin() <<endl;
70 // verify that we got the right objects in the list
71 // this of course depends on AthenaOutputStream_test.txt
72 assert( 4 == ( pStream->selectedObjects()->end() - pStream->selectedObjects()->begin() ) );
73
74 pStream->clearSelection();
75 assert( 0 == ( pStream->selectedObjects()->end() - pStream->selectedObjects()->begin() ) );
76
77 // all done
78 cout << "*** AthenaOutputStream_test OK ***" << endl;
79 return 0;
80}