NanoSliceUnitTest.cpp
Go to the documentation of this file.
1 /*
2  * File: NanoSliceUnitTest.cpp
3  * Author: denis
4  *
5  * Created on September 24, 2012, 10:18 AM
6  */
7 #include <DAQDataFormats/RawNanoSlice.h>
8 
9 //#include "DAQDataFormats/../unittest/RawDAQDataUnitTest.h"
10 //#include "DAQDataFormats/../unittest/NanoSliceConstructor.h"
11 #include "RawDAQDataUnitTest.h"
12 #include "NanoSliceConstructor.h"
13 
14 namespace daqdataformats {
15 
19  CPPUNIT_TEST(testReadDataIntoSameVersion);
20  CPPUNIT_TEST(testReadDataIntoUnknownVersion);
24 public:
27 
32 
33 private:
35 
36 private:
37  rawnano::NanoSliceConstructor* _mainDFConstructor;
38 };
39 
40 //------------------------------------------------------------------------------
42  RawDAQDataUnitTest(new rawnano::NanoSliceConstructor())
43  ,_mainDFConstructor((rawnano::NanoSliceConstructor*)_dataFormatConstructor)
44 {
45 }
46 
47 //------------------------------------------------------------------------------
49 
50 //------------------------------------------------------------------------------
52 
53  RawNanoSlice* df = (RawNanoSlice*)_mainDFConstructor->getEmptyDataFormat(version);
54 
55  ASSERT_CHECK_FIELD(TimeStamp);
56  ASSERT_CHECK_FIELD(PulseHeight);
57 
58  if(version == 1){
59  ASSERT_CHECK_FIELD(Value1);
60  //ASSERT_GETANDSET_IS_NOT_ALLOWED(Value2);
61  }
62 
63  if(version == 2){
64  //ASSERT_GETANDSET_IS_NOT_ALLOWED(Value1);
65  //ASSERT_CHECK_FIELD(Value2);
66  }
67 
68  if(version == 0){
69  //ASSERT_GETANDSET_IS_NOT_ALLOWED(Value1);
70  //ASSERT_GETANDSET_IS_NOT_ALLOWED(Value2);
71  }
72 
73  CPPUNIT_ASSERT(version == (version_t) df->getHeader()->getVersion());
74 
75  CPPUNIT_ASSERT(compareDataFormats(df, df->getHeader()) == FIRST_CONTAINS_SECOND);
76 
78 
79 
80  delete df;
81 }
82 
83 //CPPUNIT_TEST_SUITE_REGISTRATION(NanoSliceUnitTest);
85 CPPUNIT_REGISTRY_ADD_TO_DEFAULT("DAQDataFormats");
86 
87 }; // end of class
#define DEFINE_testReadDataIntoSameVersion
#define DEFINE_testReadDataIntoUnknownVersion
IMPLEMENT_MAIN_STANDARD IMPLEMENT_MAIN_setBufferSource daqdataformats::RawNanoSliceHeader * getHeader() const
Get the NanoSlice header pointer.
Definition: RawNanoSlice.h:57
virtual DATAFORMAT_COMPARE_RESULTS compareDataFormats(const RawDAQData *, const RawDAQData *) const
Are the two data formats the same?
#define ASSERT_PRINT_IS_NOT_UNKNOWN
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.
rawnano::NanoSliceConstructor * _mainDFConstructor
virtual void basicFieldGetAndSetChecksForGivenVersion(const version_t)
Check all field gets and sets for a given version.
RawDAQDataConstructor * _dataFormatConstructor
Pointer to RawDAQDataConstructor.
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConfigurationBlockUnitTest,"DAQDataFormats")
#define DEFINE_checkDeepCopyConstructor(CLASS)
Standard function that checks Deep Copy Constructor.
const XML_Char * version
Definition: expat.h:187
CPPUNIT_TEST(basicFieldGetAndSetChecks)
CPPUNIT_TEST_SUITE(NanoSliceUnitTest)
virtual void checkDeepCopyConstructor()
Check Deep Copy Constructors for all versions.
#define ASSERT_CHECK_FIELD(FIELD_NAME)
Assert checking get/set of the the field is good.
int32_t version_t
Definition: RawDAQData.h:72
Class to hold the data from the FEBs in correct formats.
CPPUNIT_REGISTRY_ADD_TO_DEFAULT("DAQDataFormats")