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

Public Member Functions

 ConfigurationHeaderUnitTest ()
 
 ~ConfigurationHeaderUnitTest ()
 
virtual 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 (ConfigurationHeaderUnitTest)
 
 CPPUNIT_TEST (basicFieldGetAndSetChecks)
 
 CPPUNIT_TEST (testReadDataIntoSameVersion)
 
 CPPUNIT_TEST (testReadDataIntoUnknownVersion)
 
 CPPUNIT_TEST (checkDeepCopyConstructor)
 
 CPPUNIT_TEST (checkShallowCopyConstructor)
 
 CPPUNIT_TEST_SUITE_END ()
 

Private Attributes

rawconfhdr::ConfigurationHeaderConstructor * _mainDFConstructor
 

Detailed Description

Definition at line 14 of file ConfigurationHeaderUnitTest.cpp.

Constructor & Destructor Documentation

daqdataformats::ConfigurationHeaderUnitTest::ConfigurationHeaderUnitTest ( )

Definition at line 39 of file ConfigurationHeaderUnitTest.cpp.

39  :
40  RawDAQDataUnitTest(new rawconfhdr::ConfigurationHeaderConstructor())
41  ,_mainDFConstructor((rawconfhdr::ConfigurationHeaderConstructor*)_dataFormatConstructor)
42 {
43 }
rawconfhdr::ConfigurationHeaderConstructor * _mainDFConstructor
RawDAQDataConstructor * _dataFormatConstructor
Pointer to RawDAQDataConstructor.
RawDAQDataUnitTest(RawDAQDataConstructor *)
daqdataformats::ConfigurationHeaderUnitTest::~ConfigurationHeaderUnitTest ( )

Member Function Documentation

virtual void daqdataformats::RawDAQDataUnitTest::basicFieldGetAndSetChecks ( )
inlinevirtualinherited

Check all field gets and sets for all versions.

Reimplemented in daqdataformats::MilliSliceUnitTest, and daqdataformats::MicroSliceUnitTest.

Definition at line 115 of file RawDAQDataUnitTest.h.

References daqdataformats::RawDAQDataUnitTest::basicFieldGetAndSetChecksForGivenVersion(), and VERSION_LOOP_iver.

Referenced by daqdataformats::MicroSliceHeaderUnitTest::~MicroSliceHeaderUnitTest(), daqdataformats::MilliSliceHeaderUnitTest::~MilliSliceHeaderUnitTest(), and daqdataformats::TimingMarkerUnitTest::~TimingMarkerUnitTest().

115  {
117  };
#define VERSION_LOOP_iver(ACTION)
Perform some action that depends on iver.
virtual void basicFieldGetAndSetChecksForGivenVersion(const version_t)
Check all field gets and sets for a given version.
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(), ~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 daqdataformats::MicroSliceUnitTest::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::ConfigurationHeaderUnitTest::CPPUNIT_TEST ( basicFieldGetAndSetChecks  )
private
daqdataformats::ConfigurationHeaderUnitTest::CPPUNIT_TEST ( testReadDataIntoSameVersion  )
private
daqdataformats::ConfigurationHeaderUnitTest::CPPUNIT_TEST ( testReadDataIntoUnknownVersion  )
private
daqdataformats::ConfigurationHeaderUnitTest::CPPUNIT_TEST ( checkDeepCopyConstructor  )
private
daqdataformats::ConfigurationHeaderUnitTest::CPPUNIT_TEST ( checkShallowCopyConstructor  )
private
daqdataformats::ConfigurationHeaderUnitTest::CPPUNIT_TEST_SUITE ( ConfigurationHeaderUnitTest  )
private
daqdataformats::ConfigurationHeaderUnitTest::CPPUNIT_TEST_SUITE_END ( )
private
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::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
rawconfhdr::ConfigurationHeaderConstructor* daqdataformats::ConfigurationHeaderUnitTest::_mainDFConstructor
private

Definition at line 26 of file ConfigurationHeaderUnitTest.cpp.

Referenced by ~ConfigurationHeaderUnitTest().


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