RawMilliSliceTests.cpp
Go to the documentation of this file.
1 #include <cppunit/extensions/HelperMacros.h>
2 #include <DAQDataFormats/RawMilliSlice.h>
3 
4 using namespace daqdataformats;
5 
6 class RawMilliSliceTests : public CppUnit::TestFixture {
7 
8  CPPUNIT_TEST_SUITE(RawMilliSliceTests);
9  CPPUNIT_TEST(testCalculateCheckSum);
10  CPPUNIT_TEST(testCalculateCheckSumCorrupt);
11  CPPUNIT_TEST_SUITE_END();
12 
13 public:
14  void setUp();
15  void tearDown();
16 
17  void testCalculateCheckSum();
18  void testCalculateCheckSumCorrupt();
19 
20 
21 private:
22 
23 };
24 
26  // flush stdout to get progress markers to display in realtime
27  std::cout.flush();
28 }
29 
31  // flush stdout to get progress markers to display in realtime
32  std::cout.flush();
33 }
34 
36 
37  RawMilliSlice rawMilliSlice;
38  rawMilliSlice.setDetId(1);
39  rawMilliSlice.setDCMId(2);
40  rawMilliSlice.setDiblockId(3);
41  rawMilliSlice.setPartition(4);
42  rawMilliSlice.setDestBuffID(5);
43  rawMilliSlice.close(true);
44 
45  CPPUNIT_ASSERT(rawMilliSlice.calculateCheckSum(0) == 0);
46 
47 }
48 
50 
51  RawMilliSlice rawMilliSlice;
52  rawMilliSlice.setDetId(1);
53  rawMilliSlice.setDCMId(2);
54  rawMilliSlice.setDiblockId(3);
55  rawMilliSlice.setPartition(4);
56  rawMilliSlice.setDestBuffID(5);
57  rawMilliSlice.close();
58 
59  uint32_t* buffer_data = (uint32_t*)(rawMilliSlice.getBuffer());
60  buffer_data[3] = 0xdeadbeef;
61 
62  CPPUNIT_ASSERT(rawMilliSlice.calculateCheckSum(0) != 0);
63 
64 }
65 
67 CPPUNIT_REGISTRY_ADD_TO_DEFAULT("DAQDataFormats");
bool setPartition(const uint32_t a)
Definition: RawMilliSlice.h:85
bool setDCMId(const uint32_t a)
Definition: RawMilliSlice.h:81
bool setDestBuffID(const uint32_t a)
Definition: RawMilliSlice.h:84
void * getBuffer() const
Definition: RawDAQData.h:131
bool close(const bool produce_crc=false)
bool setDiblockId(const uint32_t a)
Definition: RawMilliSlice.h:80
uint32_t calculateCheckSum(const uint32_t skip_last_words) const
Definition: RawDAQData.cpp:541
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConfigurationBlockUnitTest,"DAQDataFormats")
OStream cout
Definition: OStream.cxx:6
Class to hold the data from the FEBs in correct formats.
bool setDetId(const uint32_t a)
Definition: RawMilliSlice.h:82
CPPUNIT_REGISTRY_ADD_TO_DEFAULT("DAQDataFormats")