LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_lctrackercellid.cc
Go to the documentation of this file.
1 // example for LCIO tests
4 
5 #include "tutil.h"
6 #include "lcio.h"
7 
8 
9 #include "UTIL/LCTrackerConf.h"
10 
11 #include <iostream>
12 
13 using namespace std ;
14 
15 // replace mytest with the name of your test
16 const static string testname="test_lctrackercellid";
17 
18 //=============================================================================
19 
20 int main(int /*argc*/, char** /*argv*/ ){
21 
22  // this should be the first line in your test
23  TEST MYTEST=TEST( testname, std::cout );
24 
25 
26  MYTEST.LOG( "testing the LCTrackerCellID ... " );
27 
28  // set a different encoding string
29  lcio::LCTrackerCellID::instance().set_encoding_string("subdet:4,side:-2,layer:10,module:6,sensor:10" ) ;
30 
31 
32  MYTEST( lcio::LCTrackerCellID::subdet() , 0u , " subdet index != 0 " ) ;
33  MYTEST( lcio::LCTrackerCellID::side() , 1u , " side index != 1 " ) ;
34  MYTEST( lcio::LCTrackerCellID::layer() , 2u , " layer index != 2 " ) ;
35  MYTEST( lcio::LCTrackerCellID::module() , 3u , " module index != 3 " ) ;
36  MYTEST( lcio::LCTrackerCellID::sensor() , 4u , " sensor index != 4 " ) ;
37 
38 
39  MYTEST( lcio::LCTrackerCellID::encoding_string() , std::string("subdet:4,side:-2,layer:10,module:6,sensor:10") , "wrong encoding string ! " ) ;
40 
41 
42  bool exception = false ;
43 
44  try {
45  lcio::LCTrackerCellID::instance().set_encoding_string("hello" ) ;
46  } catch( std::logic_error& ){
47  exception = true ;
48  }
49 
50  if( ! exception ){
51 
52  MYTEST.FAILED( "oops, should not be possible to change the encoding string after it has been accessed " );
53  }
54 
55 
56  return 0;
57 }
58 
59 //=============================================================================
60 
Definition: tutil.h:7
STL class.
void FAILED(const std::string &msg)
Definition: tutil.h:42
int main(int argc, char **argv)
Simple program that opens existing LCIO files and appends the records needed for direct access - if t...
STL class.
STL class.
void LOG(const std::string &msg)
Definition: tutil.h:21
static const string testname