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

unit test for ITimeKeeper simplest implementation More...

#include "AthenaKernel/ITimeKeeper.h"
#include "BesServices/SimplePOSIXTimeKeeperSvc.h"
#include "GaudiKernel/ISvcLocator.h"
#include "TestTools/initGaudi.h"
#include <cassert>
#include <cmath>
#include <iostream>

Go to the source code of this file.

Functions

int main ()

Detailed Description

unit test for ITimeKeeper simplest implementation

Based on ATLAS software

Definition in file SimplePOSIXTimeKeeperSvc_test.cxx.

Function Documentation

◆ main()

int main ( )

Definition at line 21 of file SimplePOSIXTimeKeeperSvc_test.cxx.

21 {
22 cout << "*** SimplePOSIXTimeKeeperSvc_test starts ***" << endl;
23 ISvcLocator* pSvcLoc( 0 );
24 if ( !initGaudi( "SimplePOSIXTimeKeeperSvc_test.txt", pSvcLoc ) )
25 {
26 cerr << "This test can not be run" << endl;
27 return 0;
28 }
29 assert( pSvcLoc );
30
31 // locate time keeper
32 const bool CREATEIF( true );
33 ITimeKeeper* pITK( 0 );
34 assert( ( pSvcLoc->service( "SimplePOSIXTimeKeeperSvc", pITK, CREATEIF ) ).isSuccess() );
35 assert( pITK );
36 // cout << *pITK <<endl;
37
38 SimplePOSIXTimeKeeperSvc& tk( dynamic_cast<SimplePOSIXTimeKeeperSvc&>( *pITK ) );
39 assert( tk.timeX() + tk.timeL() == tk.allocTime() );
40
41 while ( pITK->nextIter() )
42 {
43 for ( int i = 0; i < 20000000; ++i ) atan( i ); // waste some time
44 }
45
46 assert( tk.timeX() + tk.timeL() == tk.allocTime() );
47
48 tk.finalize();
49
50 // all done
51 cout << "*** SimplePOSIXTimeKeeperSvc_test OK ***" << endl;
52 return 0;
53}