Typedefs | Functions
test_FileChannelMappingService.cxx File Reference
#include "../FileChannelMappingService.h"
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>

Go to the source code of this file.

Typedefs

typedef ChannelMappingService::Channel Channel
 

Functions

int test_FileChannelMappingService (string fname)
 
int main (int argc, char *argv[])
 

Typedef Documentation

Definition at line 20 of file test_FileChannelMappingService.cxx.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 86 of file test_FileChannelMappingService.cxx.

86  {
87  test_FileChannelMappingService("rce_channel_map_dune35t.txt");
88  return 0;
89 }
int test_FileChannelMappingService(string fname)
int test_FileChannelMappingService ( string  fname)

Definition at line 25 of file test_FileChannelMappingService.cxx.

25  {
26  const string myname = "test_FileChannelMappingService: ";
27 #ifdef NDEBUG
28  cout << myname << "NDEBUG must be off." << endl;
29  abort();
30 #endif
31  const string line = "-----------------------------";
32 
33  cout << myname << line << endl;
34  cout << myname << "Create channel mapping service." << endl;
36  pset.put("FileName", fname);
37  FileChannelMappingService mapsvc(pset);
38 
39  cout << myname << line << endl;
40  cout << myname << "Fetch offline channels." << endl;
41  Channel maxch = 20;
42  unsigned int w = 12;
43  cout << myname << setw(w) << "online" << setw(w) << "offline" << endl;
44  for ( unsigned int chin=0; chin<maxch; ++chin ) {
45  cout << myname << setw(w) << chin << setw(w) << mapsvc.offline(chin) << endl;
46  }
47 
48  cout << myname << line << endl;
49  cout << myname << "Fetch online channels." << endl;
50  cout << myname << setw(w) << "offline" << setw(w) << "online" << endl;
51  for ( unsigned int chin=0; chin<maxch; ++chin ) {
52  cout << myname << setw(w) << chin << setw(w) << mapsvc.online(chin) << endl;
53  }
54 
55  cout << myname << line << endl;
56  cout << myname << "Check mapping failures raise exceptions." << endl;
57  Channel nch = 2048;
58  try {
59  mapsvc.offline(nch);
60  cout << myname << "ERROR: Invalid online channel did not raise exception!" << endl;
61  return 1;
62  } catch(...) {
63  cout << myname << "Invalid online channel raised exception." << endl;
64  }
65  try {
66  mapsvc.online(nch);
67  cout << myname << "ERROR: Invalid offline channel did not raise exception!" << endl;
68  return 1;
69  } catch(...) {
70  cout << myname << "Invalid offline channel raised exception." << endl;
71  }
72 
73  cout << myname << line << endl;
74  cout << myname << "Check map consistency." << endl;
75  for ( Channel chin=0; chin<nch; ++chin ) {
76  Channel choff = mapsvc.offline(chin);
77  Channel chon = mapsvc.online(choff);
78  assert( chon == chin );
79  }
80 
81  cout << myname << line << endl;
82  cout << myname << "Done." << endl;
83  return 0;
84 }
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
void line(double t, double *p, double &x, double &y, double &z)
void put(std::string const &key)
QTextStream & endl(QTextStream &s)
ChannelMappingService::Channel Channel