Classes | Namespaces | Macros | Enumerations | Functions
RawDAQDataUnitTest.h File Reference
#include <cppunit/extensions/HelperMacros.h>
#include "RawDAQDataConstructor.h"
#include <DAQDataFormats/DataFormatException.h>
#include <boost/shared_ptr.hpp>

Go to the source code of this file.

Classes

class  daqdataformats::RawDAQDataUnitTest
 Base class for RawDAQData unittest. More...
 

Namespaces

 daqdataformats
 Class to hold the data from the FEBs in correct formats.
 

Macros

#define VERSION_LOOP_iver(ACTION)
 Perform some action that depends on iver. More...
 
#define ASSERT_VERSION_LOOP_iver(ACTION)   VERSION_LOOP_iver(CPPUNIT_ASSERT(ACTION))
 Assert some action that depends on iver. More...
 
#define DEFINE_checkDeepCopyConstructor(CLASS)
 Standard function that checks Deep Copy Constructor. More...
 
#define DEFINE_checkShallowCopyConstructor(CLASS)
 Standard function that checks Shallow Copy Constructor. More...
 
#define DEFINE_testReadDataIntoSameVersion
 
#define DEFINE_testReadDataIntoUnknownVersion   void testReadDataIntoUnknownVersion() {LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<std::endl; CPPUNIT_ASSERT(checkReadDataIntoUnknownVersion());}
 

Enumerations

enum  daqdataformats::DATAFORMAT_COMPARE_RESULTS { daqdataformats::DATAFORMATS_ARE_DIFFERENT = 1, daqdataformats::DATAFORMATS_ARE_THE_SAME, daqdataformats::FIRST_CONTAINS_SECOND, daqdataformats::SECOND_CONTAINS_FIRST }
 Enumeration of the two dataformat comparisson results. More...
 

Functions

std::string daqdataformats::getNameForResults (const DATAFORMAT_COMPARE_RESULTS res)
 

Macro Definition Documentation

#define ASSERT_VERSION_LOOP_iver (   ACTION)    VERSION_LOOP_iver(CPPUNIT_ASSERT(ACTION))

Assert some action that depends on iver.

Definition at line 35 of file RawDAQDataUnitTest.h.

#define DEFINE_checkDeepCopyConstructor (   CLASS)
Value:
void checkDeepCopyConstructor(){ \
LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<std::endl; \
if(_dataFormatConstructor->getMaximumVersion() == rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION) \
CPPUNIT_ASSERT(checkDeepCopyConstructor(rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION)); \
ASSERT_VERSION_LOOP_iver(checkDeepCopyConstructor(iver)); \
} \
bool checkDeepCopyConstructor(const version_t ver) const { \
LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<" for version "<<ver<<std::endl; \
boost::shared_ptr<CLASS> format_nonzero((CLASS*)_mainDFConstructor->getFilledDataFormat(ver));\
CLASS deep_copy(*(format_nonzero.get())); \
if(compareDataFormats(format_nonzero.get(), &deep_copy) != DATAFORMATS_ARE_THE_SAME){ \
LOG_ERROR("UNITTEST")<<"Failure in "<<__PRETTY_FUNCTION__<<" at "<<__LINE__<<"\n" \
<<"Nonzero format:\n" \
<<*(format_nonzero.get()) \
<<"Copied format:\n" \
<<deep_copy; \
return false; \
} \
return true; \
}
#define ASSERT_VERSION_LOOP_iver(ACTION)
Assert some action that depends on iver.
int32_t version_t
Definition: RawDAQData.h:72
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81

Standard function that checks Deep Copy Constructor.

Definition at line 38 of file RawDAQDataUnitTest.h.

#define DEFINE_checkShallowCopyConstructor (   CLASS)
Value:
void checkShallowCopyConstructor() { \
LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<std::endl; \
if(_dataFormatConstructor->getMaximumVersion() == rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION) \
CPPUNIT_ASSERT(checkShallowCopyConstructor(rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION)); \
ASSERT_VERSION_LOOP_iver(checkShallowCopyConstructor(iver)); \
} \
bool checkShallowCopyConstructor(const version_t ver) const { \
LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<" for version "<<ver<<std::endl; \
boost::shared_ptr<CLASS> format_nonzero((CLASS*)_mainDFConstructor->getFilledDataFormat(ver)); \
CLASS shallow_copy((void*)(format_nonzero.get()->getBuffer())); \
if(compareDataFormats(format_nonzero.get(), &shallow_copy) != DATAFORMATS_ARE_THE_SAME){ \
LOG_ERROR("UNITTEST")<<"Failure in "<<__PRETTY_FUNCTION__<<" at "<<__LINE__<<"\n" \
<<"Nonzero format:\n" \
<<*(format_nonzero.get()) \
<<"Copied format:\n" \
<<shallow_copy; \
return false; \
} \
return true; \
}
#define ASSERT_VERSION_LOOP_iver(ACTION)
Assert some action that depends on iver.
int32_t version_t
Definition: RawDAQData.h:72
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81

Standard function that checks Shallow Copy Constructor.

Definition at line 63 of file RawDAQDataUnitTest.h.

#define DEFINE_testReadDataIntoSameVersion
Value:
void testReadDataIntoSameVersion() { \
LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<std::endl; \
CPPUNIT_ASSERT(checkReadDataIntoSameVersion()); \
}

Definition at line 87 of file RawDAQDataUnitTest.h.

#define DEFINE_testReadDataIntoUnknownVersion   void testReadDataIntoUnknownVersion() {LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<std::endl; CPPUNIT_ASSERT(checkReadDataIntoUnknownVersion());}

Definition at line 93 of file RawDAQDataUnitTest.h.

#define VERSION_LOOP_iver (   ACTION)
Value:
{ \
const version_t maximum_version = _dataFormatConstructor->getMaximumVersion(); \
for(int iver = 0; iver <= maximum_version; ++iver){ \
ACTION; \
} \
} \
}
int32_t version_t
Definition: RawDAQData.h:72
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81

Perform some action that depends on iver.

Definition at line 23 of file RawDAQDataUnitTest.h.

Referenced by daqdataformats::RawDAQDataUnitTest::basicFieldGetAndSetChecks(), daqdataformats::RawDAQDataUnitTest::checkReadDataIntoSameVersion(), and daqdataformats::RawDAQDataUnitTest::checkReadDataIntoUnknownVersion().