Line data Source code
1 : /**
2 : * @file DAPHNEStreamSuperChunkTypeAdapter_test.cxx DAPHNEStreamSuperChunkTypeAdapter class Unit Tests
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "fdreadoutlibs/DAPHNEStreamSuperChunkTypeAdapter.hpp"
10 :
11 : #define BOOST_TEST_MODULE DAPHNEStreamSuperChunkTypeAdapter_test // NOLINT
12 :
13 : #include "boost/test/unit_test.hpp"
14 :
15 : using namespace dunedaq::fdreadoutlibs::types;
16 :
17 : BOOST_AUTO_TEST_SUITE(DAPHNEStreamSuperChunkTypeAdapter_test)
18 :
19 2 : BOOST_AUTO_TEST_CASE(Sizes)
20 : {
21 1 : DAPHNEStreamSuperChunkTypeAdapter blob_of_junk;
22 :
23 1 : BOOST_REQUIRE(blob_of_junk.end() - blob_of_junk.begin() == blob_of_junk.get_num_frames());
24 :
25 1 : BOOST_REQUIRE(reinterpret_cast<uint8_t*>(blob_of_junk.end()) - reinterpret_cast<uint8_t*>(blob_of_junk.begin()) ==
26 : blob_of_junk.get_payload_size());
27 1 : }
28 :
29 2 : BOOST_AUTO_TEST_CASE(Timestamps)
30 : {
31 1 : DAPHNEStreamSuperChunkTypeAdapter blob_of_junk;
32 1 : DAPHNEStreamSuperChunkTypeAdapter blob_of_junk2;
33 :
34 1 : const uint64_t timestamp = 0xDEADBEEFA0B0C0D0;
35 :
36 1 : blob_of_junk.set_timestamp(timestamp);
37 1 : BOOST_REQUIRE(blob_of_junk.get_timestamp() == timestamp);
38 :
39 1 : blob_of_junk2.set_timestamp(timestamp + 1);
40 :
41 1 : BOOST_REQUIRE(blob_of_junk < blob_of_junk2);
42 :
43 1 : const uint64_t offset = 32;
44 1 : blob_of_junk.fake_timestamps(timestamp, offset);
45 :
46 13 : for (size_t i = 0; i < blob_of_junk.get_num_frames(); ++i) {
47 12 : const DAPHNEStreamSuperChunkTypeAdapter::FrameType* frame = blob_of_junk.begin() + i;
48 12 : BOOST_REQUIRE(frame->get_timestamp() == timestamp + i * offset);
49 : }
50 1 : }
51 :
52 : BOOST_AUTO_TEST_SUITE_END()
|