Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
daqdataformats::MicroSliceUnitTest Class Referenceabstract
Inheritance diagram for daqdataformats::MicroSliceUnitTest:
daqdataformats::RawDAQDataUnitTest

Public Member Functions

 MicroSliceUnitTest ()
 
 ~MicroSliceUnitTest ()
 
 DEFINE_checkDeepCopyConstructor (RawMicroSlice) DEFINE_checkShallowCopyConstructor(RawMicroSlice) void loopedcheckDeepCopyConstructor()
 
void loopedcheckShallowCopyConstructor ()
 
DEFINE_testReadDataIntoSameVersion void basicFieldGetAndSetChecks ()
 Check all field gets and sets for all versions. More...
 
virtual void checkDeepCopyConstructor ()
 Check Deep Copy Constructors for all versions. More...
 
virtual void checkShallowCopyConstructor ()
 Check Shallow Copy Constructors for all versions. More...
 
void setUp ()
 Some setup/teardown methods that Unittest require. More...
 
void tearDown ()
 

Protected Member Functions

virtual bool checkDeepCopyConstructor (const version_t) const =0
 Check constructors - deep copy and shallow copy. More...
 
virtual bool checkShallowCopyConstructor (const version_t) const =0
 
virtual void basicFieldGetAndSetChecksForGivenVersion (const version_t)
 Check all field gets and sets for a given version. More...
 
bool checkReadDataIntoSameVersion () const
 Check readData for all versions of the dataformat. More...
 
bool checkReadDataIntoUnknownVersion () const
 Check readData for all versions of the dataformat. More...
 
virtual DATAFORMAT_COMPARE_RESULTS compareDataFormats (const RawDAQData *, const RawDAQData *) const
 Are the two data formats the same? More...
 
virtual bool compareDataFormats (const RawDAQData *, const RawDAQData *, const DATAFORMAT_COMPARE_RESULTS) const
 
bool isPrintDataFormatUnknownVersion (const RawDAQData *) const
 Sometimes print() can print "DAQDataFormat is of unknown version". More...
 

Protected Attributes

RawDAQDataConstructor_dataFormatConstructor
 Pointer to RawDAQDataConstructor. More...
 

Private Member Functions

 CPPUNIT_TEST_SUITE (MicroSliceUnitTest)
 
 CPPUNIT_TEST (basicFieldGetAndSetChecks)
 
 CPPUNIT_TEST (loopedcheckDeepCopyConstructor)
 
 CPPUNIT_TEST (loopedcheckShallowCopyConstructor)
 
 CPPUNIT_TEST (testReadDataIntoSameVersion)
 
 CPPUNIT_TEST_SUITE_END ()
 

Private Attributes

MicroSliceConstructor_mainDFConstructor
 

Detailed Description

Definition at line 15 of file MicroSliceUnitTest.cpp.

Constructor & Destructor Documentation

daqdataformats::MicroSliceUnitTest::MicroSliceUnitTest ( )

Definition at line 40 of file MicroSliceUnitTest.cpp.

40  :
41  RawDAQDataUnitTest(new MicroSliceConstructor())
42  ,_mainDFConstructor((MicroSliceConstructor*)_dataFormatConstructor)
43 {
44 }
MicroSliceConstructor * _mainDFConstructor
RawDAQDataConstructor * _dataFormatConstructor
Pointer to RawDAQDataConstructor.
RawDAQDataUnitTest(RawDAQDataConstructor *)
daqdataformats::MicroSliceUnitTest::~MicroSliceUnitTest ( )

Definition at line 47 of file MicroSliceUnitTest.cpp.

47 { }

Member Function Documentation

void daqdataformats::MicroSliceUnitTest::basicFieldGetAndSetChecks ( )
virtual

Check all field gets and sets for all versions.

Checking just construction

Now Checking filling MicroSlice with NanoSlices

Reimplemented from daqdataformats::RawDAQDataUnitTest.

Definition at line 50 of file MicroSliceUnitTest.cpp.

References daqdataformats::MicroSliceConstructor::_currentNanoSliceVersion, _mainDFConstructor, daqdataformats::RawMicroSlice::addNanoSlice(), ASSERT_CHECK_FIELD, daqdataformats::RawDAQDataUnitTest::checkDeepCopyConstructor(), daqdataformats::RawDAQDataUnitTest::compareDataFormats(), daqdataformats::rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION, allInOneTrainingPlots::df, allTimeWatchdog::endl, daqdataformats::FIRST_CONTAINS_SECOND, daqdataformats::MicroSliceConstructor::getEmptyDataFormat(), daqdataformats::RawMicroSlice::getHeader(), daqdataformats::MicroSliceConstructor::getNanoSlicesVersion(), daqdataformats::RawMicroSlice::getNumNanoSlices(), daqdataformats::RawMicroSlice::getTimingMarker(), LOG_DEBUG, and daqdataformats::RawMicroSlice::setVersion().

50  {
51 
52  /// Checking just construction
53  {
55  ASSERT_CHECK_FIELD(MonteCarloFlag);
56  ASSERT_CHECK_FIELD(Time);
57  delete df;
58  }
59 
60  /// Now Checking filling MicroSlice with NanoSlices
61  rawnano::NanoSliceConstructor nano_constructor;
63  LOG_DEBUG("UNITTEST")<< "From "<<__PRETTY_FUNCTION__<<". Checking Nano version "<<_mainDFConstructor->_currentNanoSliceVersion<<std::endl;
64 
66  microslice->setVersion(0);
67  _mainDFConstructor->setFieldToTestValue_Time(microslice);
68  _mainDFConstructor->setFieldToTestValue_MonteCarloFlag(microslice);
69  LOG_DEBUG("UNITTEST")<< "From "<<__PRETTY_FUNCTION__<<". Checking Nano version "<<_mainDFConstructor->_currentNanoSliceVersion<<std::endl;
70 
71  RawNanoSlice* nano1 = (RawNanoSlice*)nano_constructor.getFilledDataFormat(_mainDFConstructor->_currentNanoSliceVersion);
72 
73  RawNanoSlice* nano2 = (RawNanoSlice*)nano_constructor.getFilledDataFormat(_mainDFConstructor->_currentNanoSliceVersion);
74 
76  nano2->setPulseHeight(nano2->getPulseHeight() + 1);
77  }
79  nano2->setValue1(nano2->getValue1() + 1);
80  }
81 
82  microslice->addNanoSlice(nano1->getBuffer());
83  microslice->addNanoSlice(nano2->getBuffer());
84 
85  CPPUNIT_ASSERT(compareDataFormats(microslice, microslice->getHeader() , FIRST_CONTAINS_SECOND));
86  CPPUNIT_ASSERT(compareDataFormats(microslice, microslice->getTimingMarker(), FIRST_CONTAINS_SECOND));
87  CPPUNIT_ASSERT(compareDataFormats(microslice, nano1 , FIRST_CONTAINS_SECOND));
88  CPPUNIT_ASSERT(compareDataFormats(microslice, nano2 , FIRST_CONTAINS_SECOND));
89 
90  CPPUNIT_ASSERT(microslice->getNumNanoSlices() == 2 );
91 
92  CPPUNIT_ASSERT(_mainDFConstructor->checkField_MonteCarloFlag(microslice) );
93  CPPUNIT_ASSERT(_mainDFConstructor->checkField_Time(microslice) );
94 
96 
97  delete nano1;
98  delete nano2;
99  delete microslice;
100  }
101 }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
version_t getNanoSlicesVersion(const RawMicroSlice *) const
Gets the NanoSlices version in the MicroSlice.
bool setVersion(const version_t)
virtual DATAFORMAT_COMPARE_RESULTS compareDataFormats(const RawDAQData *, const RawDAQData *) const
Are the two data formats the same?
MicroSliceConstructor * _mainDFConstructor
uint32_t getNumNanoSlices() const
Get current Hit Probability (for a microslice generation)
daqdataformats::RawDAQData * getEmptyDataFormat(const version_t) const
method to create an empty dataformat with a given version
daqdataformats::RawTimingMarker * getTimingMarker() const
Get the MicroSlice Header.
daqdataformats::RawMicroSliceHeader * getHeader() const
Class to hold the MicroSlice data.
Definition: RawMicroSlice.h:48
#define ASSERT_CHECK_FIELD(FIELD_NAME)
Assert checking get/set of the the field is good.
void addNanoSlice(const void *nanoslice_buffer, const bool check_mc_flag=true)
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
virtual void daqdataformats::RawDAQDataUnitTest::basicFieldGetAndSetChecksForGivenVersion ( const version_t  )
inlineprotectedvirtualinherited

Check all field gets and sets for a given version.

Reimplemented in daqdataformats::MicroBlockUnitTest.

Definition at line 132 of file RawDAQDataUnitTest.h.

References daqdataformats::RawDAQDataUnitTest::checkDeepCopyConstructor(), daqdataformats::RawDAQDataUnitTest::checkReadData(), daqdataformats::RawDAQDataUnitTest::checkReadDataIntoSameVersion(), daqdataformats::RawDAQDataUnitTest::checkReadDataIntoUnknownVersion(), daqdataformats::RawDAQDataUnitTest::checkShallowCopyConstructor(), daqdataformats::RawDAQDataUnitTest::compareDataFormats(), daqdataformats::RawDAQDataUnitTest::getDifferenceBetweenStrings(), daqdataformats::RawDAQDataUnitTest::isPrintDataFormatUnknownVersion(), daqdataformats::RawDAQDataUnitTest::resizeBufferToSizeOfDataFormats(), and string.

Referenced by daqdataformats::RawDAQDataUnitTest::basicFieldGetAndSetChecks(), daqdataformats::ConfigurationBlockUnitTest::~ConfigurationBlockUnitTest(), daqdataformats::ConfigurationHeaderUnitTest::~ConfigurationHeaderUnitTest(), daqdataformats::ConfigurationNameUnitTest::~ConfigurationNameUnitTest(), daqdataformats::ConfigurationSystemIDUnitTest::~ConfigurationSystemIDUnitTest(), daqdataformats::ConfigurationTailUnitTest::~ConfigurationTailUnitTest(), daqdataformats::DataBlockHeaderUnitTest::~DataBlockHeaderUnitTest(), daqdataformats::DataBlockUnitTest::~DataBlockUnitTest(), daqdataformats::EventHeaderUnitTest::~EventHeaderUnitTest(), daqdataformats::EventTailUnitTest::~EventTailUnitTest(), daqdataformats::EventUnitTest::~EventUnitTest(), daqdataformats::MicroBlockHeaderUnitTest::~MicroBlockHeaderUnitTest(), daqdataformats::NanoSliceHeaderUnitTest::~NanoSliceHeaderUnitTest(), daqdataformats::NanoSliceUnitTest::~NanoSliceUnitTest(), daqdataformats::RunHeaderUnitTest::~RunHeaderUnitTest(), daqdataformats::TriggerHeaderUnitTest::~TriggerHeaderUnitTest(), daqdataformats::TriggerMaskUnitTest::~TriggerMaskUnitTest(), daqdataformats::TriggerRangeUnitTest::~TriggerRangeUnitTest(), daqdataformats::TriggerTimeUnitTest::~TriggerTimeUnitTest(), daqdataformats::TriggerTimingMarkerUnitTest::~TriggerTimingMarkerUnitTest(), and daqdataformats::TriggerUnitTest::~TriggerUnitTest().

132 {};
virtual void daqdataformats::RawDAQDataUnitTest::checkDeepCopyConstructor ( )
inlinevirtualinherited
virtual bool daqdataformats::RawDAQDataUnitTest::checkDeepCopyConstructor ( const version_t  ) const
protectedpure virtualinherited

Check constructors - deep copy and shallow copy.

bool daqdataformats::RawDAQDataUnitTest::checkReadDataIntoSameVersion ( ) const
protectedinherited

Check readData for all versions of the dataformat.

Definition at line 32 of file RawDAQDataUnitTest.cpp.

References allTimeWatchdog::endl, LOG_DEBUG, and VERSION_LOOP_iver.

Referenced by daqdataformats::RawDAQDataUnitTest::basicFieldGetAndSetChecksForGivenVersion().

32  {
34  LOG_DEBUG("UNITTEST")<<"checkReadDataIntoSameVersion for version "<<iver<<std::endl;
35  if(!checkReadDataIntoSameVersion(iver)) return false;
36  )
37  return true;
38 }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
#define VERSION_LOOP_iver(ACTION)
Perform some action that depends on iver.
bool checkReadDataIntoSameVersion() const
Check readData for all versions of the dataformat.
bool daqdataformats::RawDAQDataUnitTest::checkReadDataIntoUnknownVersion ( ) const
protectedinherited

Check readData for all versions of the dataformat.

Definition at line 41 of file RawDAQDataUnitTest.cpp.

References allTimeWatchdog::endl, LOG_DEBUG, and VERSION_LOOP_iver.

Referenced by daqdataformats::RawDAQDataUnitTest::basicFieldGetAndSetChecksForGivenVersion().

41  {
42 
44  LOG_DEBUG("UNITTEST")<<"checkReadDataIntoUnknownVersion for version "<<iver<<std::endl;
46  return false;
47  )
48 
49  return true;
50 }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
bool checkReadDataIntoUnknownVersion() const
Check readData for all versions of the dataformat.
#define VERSION_LOOP_iver(ACTION)
Perform some action that depends on iver.
virtual void daqdataformats::RawDAQDataUnitTest::checkShallowCopyConstructor ( )
inlinevirtualinherited
virtual bool daqdataformats::RawDAQDataUnitTest::checkShallowCopyConstructor ( const version_t  ) const
protectedpure virtualinherited
DATAFORMAT_COMPARE_RESULTS daqdataformats::RawDAQDataUnitTest::compareDataFormats ( const RawDAQData format1,
const RawDAQData format2 
) const
protectedvirtualinherited

Are the two data formats the same?

Print the first input dataformat into a string

Print the first input dataformat into a string

Compare the two strings and see if they are the same

See if first string contains second

See if second string contains first

Definition at line 227 of file RawDAQDataUnitTest.cpp.

References daqdataformats::DATAFORMATS_ARE_DIFFERENT, daqdataformats::DATAFORMATS_ARE_THE_SAME, daqdataformats::FIRST_CONTAINS_SECOND, daqdataformats::RawDAQData::print(), daqdataformats::SECOND_CONTAINS_FIRST, and string.

Referenced by basicFieldGetAndSetChecks(), daqdataformats::MilliSliceUnitTest::basicFieldGetAndSetChecks(), daqdataformats::RawDAQDataUnitTest::basicFieldGetAndSetChecksForGivenVersion(), daqdataformats::RawDAQDataUnitTest::checkReadData(), daqdataformats::ConfigurationBlockUnitTest::~ConfigurationBlockUnitTest(), daqdataformats::DataBlockUnitTest::~DataBlockUnitTest(), daqdataformats::EventUnitTest::~EventUnitTest(), daqdataformats::NanoSliceUnitTest::~NanoSliceUnitTest(), and daqdataformats::TriggerUnitTest::~TriggerUnitTest().

228 {
229  /// Print the first input dataformat into a string
230  std::string string1;
231  format1->print(string1);
232 
233  /// Print the first input dataformat into a string
234  std::string string2;
235  format2->print(string2);
236 
237  /// Compare the two strings and see if they are the same
238  if(string1.compare(string2) == 0) return DATAFORMATS_ARE_THE_SAME;
239 
240  /// See if first string contains second
241  if(string1.find(string2) != std::string::npos) return FIRST_CONTAINS_SECOND;
242 
243  /// See if second string contains first
244  if(string2.find(string1) != std::string::npos) return SECOND_CONTAINS_FIRST;
245 
247 }
enum BeamMode string
bool daqdataformats::RawDAQDataUnitTest::compareDataFormats ( const RawDAQData format1,
const RawDAQData format2,
const DATAFORMAT_COMPARE_RESULTS  what_it_should_be 
) const
protectedvirtualinherited

Print the first input dataformat into a string

Print the first input dataformat into a string

Compare the two strings and see if they are the same

Definition at line 250 of file RawDAQDataUnitTest.cpp.

References daqdataformats::DATAFORMATS_ARE_DIFFERENT, daqdataformats::DATAFORMATS_ARE_THE_SAME, daqdataformats::FIRST_CONTAINS_SECOND, daqdataformats::RawDAQDataUnitTest::getDifferenceBetweenStrings(), daqdataformats::getNameForResults(), LOG_ERROR, daqdataformats::RawDAQData::print(), fillBadChanDBTables::result, daqdataformats::SECOND_CONTAINS_FIRST, and string.

254 {
255 
256  /// Print the first input dataformat into a string
257  std::string string1;
258  format1->print(string1);
259 
260  /// Print the first input dataformat into a string
261  std::string string2;
262  format2->print(string2);
263 
264 
266 
267  /// Compare the two strings and see if they are the same
268  if (string1.compare(string2) == 0) result = DATAFORMATS_ARE_THE_SAME;
269  else if(string1.find(string2) != std::string::npos) result = FIRST_CONTAINS_SECOND;
270  else if(string2.find(string1) != std::string::npos) result = SECOND_CONTAINS_FIRST;
271 
272 
273  if(result != what_it_should_be){
274  LOG_ERROR("UNITTEST")<<"Failure in "<<__PRETTY_FUNCTION__<<" at "<<__LINE__<<". "
275  <<"Formats should be "<<daqdataformats::getNameForResults(what_it_should_be)
276  <<". But they are " <<daqdataformats::getNameForResults(result)
277  <<"\nFirst format:"<<string1
278  <<"\nSecond format:"<<string2
279  <<"\n Difference:\n"
280  <<getDifferenceBetweenStrings(string1, string2);
281  return false;
282  }// end of checking if the dataformats are the same
283 
284  return(result == what_it_should_be);
285 }
std::string getNameForResults(const DATAFORMAT_COMPARE_RESULTS res)
DATAFORMAT_COMPARE_RESULTS
Enumeration of the two dataformat comparisson results.
std::string getDifferenceBetweenStrings(const std::string, const std::string) const
#define LOG_ERROR(stream)
Definition: Messenger.h:129
enum BeamMode string
daqdataformats::MicroSliceUnitTest::CPPUNIT_TEST ( basicFieldGetAndSetChecks  )
private
daqdataformats::MicroSliceUnitTest::CPPUNIT_TEST ( loopedcheckDeepCopyConstructor  )
private
daqdataformats::MicroSliceUnitTest::CPPUNIT_TEST ( loopedcheckShallowCopyConstructor  )
private
daqdataformats::MicroSliceUnitTest::CPPUNIT_TEST ( testReadDataIntoSameVersion  )
private
daqdataformats::MicroSliceUnitTest::CPPUNIT_TEST_SUITE ( MicroSliceUnitTest  )
private
daqdataformats::MicroSliceUnitTest::CPPUNIT_TEST_SUITE_END ( )
private
daqdataformats::MicroSliceUnitTest::DEFINE_checkDeepCopyConstructor ( RawMicroSlice  )
bool daqdataformats::RawDAQDataUnitTest::isPrintDataFormatUnknownVersion ( const RawDAQData df) const
protectedinherited

Sometimes print() can print "DAQDataFormat is of unknown version".

Print the first input dataformat into a string

See if first string contains second

Definition at line 291 of file RawDAQDataUnitTest.cpp.

References daqdataformats::RawDAQData::print(), and string.

Referenced by daqdataformats::MilliSliceUnitTest::basicFieldGetAndSetChecks(), daqdataformats::RawDAQDataUnitTest::basicFieldGetAndSetChecksForGivenVersion(), and daqdataformats::RawDAQDataUnitTest::checkReadData().

291  {
292 
293  /// Print the first input dataformat into a string
294  std::string string1;
295  df->print(string1);
296 
297  /// See if first string contains second
298  if(string1.find("DAQDataFormat is of unknown version") != std::string::npos) return true;
299 
300  return false;
301 }
enum BeamMode string
void daqdataformats::MicroSliceUnitTest::loopedcheckShallowCopyConstructor ( )

Definition at line 116 of file MicroSliceUnitTest.cpp.

References daqdataformats::MicroSliceConstructor::_currentNanoSliceVersion, _mainDFConstructor, daqdataformats::RawDAQDataUnitTest::checkShallowCopyConstructor(), daqdataformats::CPPUNIT_REGISTRY_ADD_TO_DEFAULT(), daqdataformats::CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(), allTimeWatchdog::endl, and LOG_DEBUG.

116  {
117 
118  rawnano::NanoSliceConstructor nano_constructor;
119 
121  LOG_DEBUG("UNITTEST")<< "From "<<__PRETTY_FUNCTION__<<". Checking Nano version "<<_mainDFConstructor->_currentNanoSliceVersion<<std::endl;
123  }
124 
125 }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
MicroSliceConstructor * _mainDFConstructor
virtual void checkShallowCopyConstructor()
Check Shallow Copy Constructors for all versions.
void daqdataformats::RawDAQDataUnitTest::setUp ( )
inlineinherited

Some setup/teardown methods that Unittest require.

Definition at line 126 of file RawDAQDataUnitTest.h.

126 {}
void daqdataformats::RawDAQDataUnitTest::tearDown ( )
inlineinherited

Definition at line 127 of file RawDAQDataUnitTest.h.

127 {}

Member Data Documentation

RawDAQDataConstructor* daqdataformats::RawDAQDataUnitTest::_dataFormatConstructor
protectedinherited
MicroSliceConstructor* daqdataformats::MicroSliceUnitTest::_mainDFConstructor
private

The documentation for this class was generated from the following file: