MicroBlockUnitTest.cpp
Go to the documentation of this file.
1 /*
2  * File: MicroBlockUnitTest.cpp
3  * Author: denis
4  *
5  * Created on September 24, 2012, 10:18 AM
6  */
7 #include <DAQDataFormats/RawMicroBlock.h>
8 
9 //#include "DAQDataFormats/../unittest/RawDAQDataUnitTest.h"
10 //#include "DAQDataFormats/../unittest/MicroBlockConstructor.h"
11 #include "RawDAQDataUnitTest.h"
12 #include "MicroBlockConstructor.h"
13 
16 
17 namespace daqdataformats {
18 
22  CPPUNIT_TEST(testReadDataIntoSameVersion);
23  CPPUNIT_TEST(testReadDataIntoUnknownVersion);
24  CPPUNIT_TEST(loopedcheckDeepCopyConstructor);
27 public:
30 
33 
36  void loopedcheckDeepCopyConstructor();
38 
39 private:
41 
42 private:
43  microblock::MicroBlockConstructor* _mainDFConstructor;
44 };
45 
46 //------------------------------------------------------------------------------
48  RawDAQDataUnitTest(new microblock::MicroBlockConstructor())
49  ,_mainDFConstructor((microblock::MicroBlockConstructor*)_dataFormatConstructor)
50 {
51 }
52 
53 //------------------------------------------------------------------------------
55 
56 //------------------------------------------------------------------------------
58 
59 
60  LOG_DEBUG("UNITTEST")<<"MicroBlockUnitTest::basicFieldGetAndSetChecksForGivenVersion for version "<<version<<std::endl;
61 
62  /// Loop over nanoslices
63  rawnano::NanoSliceConstructor nano_constructor;
64 
65  MicroSliceConstructor* micro_constructor = &(_mainDFConstructor->_milliSliceConstructor._microSliceConstructor);
66  for(micro_constructor->_currentNanoSliceVersion = 0; micro_constructor->_currentNanoSliceVersion <= nano_constructor.getMaximumVersion(); ++(micro_constructor->_currentNanoSliceVersion)){
67 
68  RawMicroBlock* microblock = new RawMicroBlock(version);
69 
70  RawMilliSlice* milli = (RawMilliSlice*)_mainDFConstructor->_milliSliceConstructor.getFilledDataFormat(rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION);
71  RawMicroSlice* micro = (RawMicroSlice*)_mainDFConstructor->_milliSliceConstructor._microSliceConstructor.getFilledDataFormat(rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION);
72 
73  microblock->setMicroBlockHeader(milli->getBuffer());
74  microblock->setMicroSlice(micro->getBuffer());
75 
76  delete microblock;
77  }
78  LOG_DEBUG("UNITTEST")<<"End MicroBlockUnitTest::basicFieldGetAndSetChecksForGivenVersion for version "<<version<<std::endl;
79 }
80 
81 //------------------------------------------------------------------------------
82 void MicroBlockUnitTest::loopedcheckDeepCopyConstructor(){
83 
84  rawnano::NanoSliceConstructor nano_constructor;
85 
86  MicroSliceConstructor* micro_constructor = &(_mainDFConstructor->_milliSliceConstructor._microSliceConstructor);
87 
88  for(micro_constructor->_currentNanoSliceVersion = 0; micro_constructor->_currentNanoSliceVersion <= nano_constructor.getMaximumVersion(); ++(micro_constructor->_currentNanoSliceVersion)){
89  LOG_DEBUG("UNITTEST")<< "From "<<__PRETTY_FUNCTION__<<". Checking Nano version "<<micro_constructor->_currentNanoSliceVersion<<std::endl;
91  }
92 
93 }
94 
95 //------------------------------------------------------------------------------
97 
98  rawnano::NanoSliceConstructor nano_constructor;
99 
100  MicroSliceConstructor* micro_constructor = &(_mainDFConstructor->_milliSliceConstructor._microSliceConstructor);
101 
102  for(micro_constructor->_currentNanoSliceVersion = 0; micro_constructor->_currentNanoSliceVersion <= nano_constructor.getMaximumVersion(); ++(micro_constructor->_currentNanoSliceVersion)){
103  LOG_DEBUG("UNITTEST")<< "From "<<__PRETTY_FUNCTION__<<". Checking Nano version "<<micro_constructor->_currentNanoSliceVersion<<std::endl;
105  }
106 
107 }
108 
109 
110 //CPPUNIT_TEST_SUITE_REGISTRATION(MicroBlockUnitTest);
112 CPPUNIT_REGISTRY_ADD_TO_DEFAULT("DAQDataFormats");
113 
114 }; // end of class
#define DEFINE_testReadDataIntoSameVersion
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
#define DEFINE_testReadDataIntoUnknownVersion
virtual void basicFieldGetAndSetChecks()
Check all field gets and sets for all versions.
#define DEFINE_checkShallowCopyConstructor(CLASS)
Standard function that checks Shallow Copy Constructor.
virtual void checkShallowCopyConstructor()
Check Shallow Copy Constructors for all versions.
Base class for RawDAQData unittest.
void * getBuffer() const
Definition: RawDAQData.h:131
RawDAQDataConstructor * _dataFormatConstructor
Pointer to RawDAQDataConstructor.
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConfigurationBlockUnitTest,"DAQDataFormats")
const XML_Char * version
Definition: expat.h:187
Class to hold the MicroSlice data.
Definition: RawMicroSlice.h:48
DEFINE_testReadDataIntoSameVersion DEFINE_testReadDataIntoUnknownVersion DEFINE_checkDeepCopyConstructor(RawMicroBlock) DEFINE_checkShallowCopyConstructor(RawMicroBlock) void loopedcheckDeepCopyConstructor()
microblock::MicroBlockConstructor * _mainDFConstructor
virtual void checkDeepCopyConstructor()
Check Deep Copy Constructors for all versions.
int32_t version_t
Definition: RawDAQData.h:72
CPPUNIT_TEST_SUITE(MicroBlockUnitTest)
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
Class to hold the data from the FEBs in correct formats.
CPPUNIT_TEST(basicFieldGetAndSetChecks)
void basicFieldGetAndSetChecksForGivenVersion(const version_t)
Check all field gets and sets for a given version.
CPPUNIT_REGISTRY_ADD_TO_DEFAULT("DAQDataFormats")