10 #ifndef RAWDAQDATAUNITTEST_H 11 #define RAWDAQDATAUNITTEST_H 12 #include <cppunit/extensions/HelperMacros.h> 16 #include <DAQDataFormats/DataFormatException.h> 18 #include <boost/shared_ptr.hpp> 23 #define VERSION_LOOP_iver(ACTION) \ 25 const version_t maximum_version = _dataFormatConstructor->getMaximumVersion(); \ 26 if(maximum_version > rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION) { \ 27 for(int iver = 0; iver <= maximum_version; ++iver){ \ 35 #define ASSERT_VERSION_LOOP_iver(ACTION) VERSION_LOOP_iver(CPPUNIT_ASSERT(ACTION)) 38 #define DEFINE_checkDeepCopyConstructor(CLASS) \ 39 void checkDeepCopyConstructor(){ \ 40 LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<std::endl; \ 41 if(_dataFormatConstructor->getMaximumVersion() == rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION) \ 42 CPPUNIT_ASSERT(checkDeepCopyConstructor(rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION)); \ 44 ASSERT_VERSION_LOOP_iver(checkDeepCopyConstructor(iver)); \ 46 bool checkDeepCopyConstructor(const version_t ver) const { \ 47 if(ver != rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION) \ 48 LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<" for version "<<ver<<std::endl; \ 49 boost::shared_ptr<CLASS> format_nonzero((CLASS*)_mainDFConstructor->getFilledDataFormat(ver));\ 50 CLASS deep_copy(*(format_nonzero.get())); \ 51 if(compareDataFormats(format_nonzero.get(), &deep_copy) != DATAFORMATS_ARE_THE_SAME){ \ 52 LOG_ERROR("UNITTEST")<<"Failure in "<<__PRETTY_FUNCTION__<<" at "<<__LINE__<<"\n" \ 53 <<"Nonzero format:\n" \ 54 <<*(format_nonzero.get()) \ 55 <<"Copied format:\n" \ 63 #define DEFINE_checkShallowCopyConstructor(CLASS) \ 64 void checkShallowCopyConstructor() { \ 65 LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<std::endl; \ 66 if(_dataFormatConstructor->getMaximumVersion() == rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION) \ 67 CPPUNIT_ASSERT(checkShallowCopyConstructor(rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION)); \ 69 ASSERT_VERSION_LOOP_iver(checkShallowCopyConstructor(iver)); \ 71 bool checkShallowCopyConstructor(const version_t ver) const { \ 72 if(ver != rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION) \ 73 LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<" for version "<<ver<<std::endl; \ 74 boost::shared_ptr<CLASS> format_nonzero((CLASS*)_mainDFConstructor->getFilledDataFormat(ver)); \ 75 CLASS shallow_copy((void*)(format_nonzero.get()->getBuffer())); \ 76 if(compareDataFormats(format_nonzero.get(), &shallow_copy) != DATAFORMATS_ARE_THE_SAME){ \ 77 LOG_ERROR("UNITTEST")<<"Failure in "<<__PRETTY_FUNCTION__<<" at "<<__LINE__<<"\n" \ 78 <<"Nonzero format:\n" \ 79 <<*(format_nonzero.get()) \ 80 <<"Copied format:\n" \ 87 #define DEFINE_testReadDataIntoSameVersion \ 88 void testReadDataIntoSameVersion() { \ 89 LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<std::endl; \ 90 CPPUNIT_ASSERT(checkReadDataIntoSameVersion()); \ 93 #define DEFINE_testReadDataIntoUnknownVersion \ 94 void testReadDataIntoUnknownVersion() {LOG_DEBUG("UNITTEST")<<__PRETTY_FUNCTION__<<std::endl; CPPUNIT_ASSERT(checkReadDataIntoUnknownVersion());}
#define VERSION_LOOP_iver(ACTION)
Perform some action that depends on iver.