Diana Software
MTestLight.cc
Go to the documentation of this file.
1 #include "MTestLight.hh"
2 #include "QEvent.hh"
3 #include "QBaseType.hh"
4 #include "QRawEvent.hh"
5 #include "QBool.hh"
6 #include <sstream>
7 
8 using namespace Diana;
9 
11 
12 using std::stringstream;
13 #define ASSERT_EQUAL(x,y)\
14 if(x==y) fTestOK++;\
15 else {\
16 fTestKO++;\
17 stringstream difference;\
18 difference<<x<<" vs "<<y;\
19 Error("Test failed: file %s; line %d: %s", __FILE__ , __LINE__,difference.str().c_str());\
20 }
21 
22 
23 
25 {
26  // called before event loop
27  fTestOK=0;
28  fTestKO=0;
29 }
30 
32 {
33  // called event by event
34  ReadHandle<QBool> iHandle("TestBoolAddition");
35  ev.Get("TestRawEvent",iHandle);
36  ASSERT_EQUAL(iHandle.IsValid(),1);
37 
38  ReadHandle<QHeader> hHandle("Header");
39  ev.Get("DAQ",hHandle);
40  ASSERT_EQUAL(hHandle.IsValid(),1);
41 
42  ReadHandle<QPulse> pHandle("Pulse");
43  ev.Get("DAQ",pHandle);
44  ASSERT_EQUAL(pHandle.IsValid(),0);
45 
46  ReadHandle<QPulseInfo> piHandle("PulseInfo");
47  ev.Get("DAQ",piHandle);
48  ASSERT_EQUAL(piHandle.IsValid(),1);
49 }
50 
52 {
53  Info("----TEST SUMMARY-----");
54  Info("OK: %d", fTestOK);
55  if(fTestKO >0 ) Error("KO: %d", fTestKO);
56  if(fTestOK != 291460) Panic("Expected test %d vs %d",291460,fTestOK);
57 
58  // called at the end of the event loop
59 }
60 
QTObjectHandle< TH1D > hHandle("MyHisto")
#define ASSERT_EQUAL(x, y)
Definition: MTestLight.cc:13
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
one-line description of your module
Definition: MTestLight.hh:41
void Do(Diana::QEvent &ev)
Do method.
Definition: MTestLight.cc:31
void Done()
Done method.
Definition: MTestLight.cc:51
void Init(Diana::QEvent &ev)
Init method.
Definition: MTestLight.cc:24
diana event
Definition: QEvent.hh:46
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
Definition: QEvent.hh:74
virtual bool IsValid() const
Check object validity.
Definition: QHandle.hh:34
read handle to access QEvent QObject's.
Definition: QHandle.hh:126
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...