LCOV - code coverage report
Current view: top level - fddetdataformats/unittest - TDE16Frame_test.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 100.0 % 42 42
Test Date: 2026-05-24 15:29:04 Functions: 100.0 % 10 10

            Line data    Source code
       1              : 
       2              : /**
       3              :  * @file TDE16Frame_test.cxx TDE16Frame class Unit Tests
       4              :  *
       5              :  * This is part of the DUNE DAQ Application Framework, copyright 2022.
       6              :  * Licensing/copyright details are in the COPYING file that you should have
       7              :  * received with this code.
       8              :  */
       9              : 
      10              : #include "fddetdataformats/TDE16Frame.hpp"
      11              : 
      12              : #define BOOST_TEST_MODULE TDE16Frame_test
      13              : 
      14              : #include "boost/test/unit_test.hpp"
      15              : 
      16              : #include <string>
      17              : #include <vector>
      18              : 
      19              : using namespace dunedaq::fddetdataformats;
      20              : 
      21              : BOOST_AUTO_TEST_SUITE(TDE16Frame_test)
      22              : 
      23            2 : BOOST_AUTO_TEST_CASE(TDE16Frame_StructMethods)
      24              : {
      25            1 :   TDE16Frame tde16frame{};
      26              : 
      27            1 :   BOOST_REQUIRE(tde16frame.get_daq_header() != nullptr);
      28            1 :   BOOST_REQUIRE(tde16frame.get_tde_header() != nullptr);
      29            1 : }
      30              : 
      31            2 : BOOST_AUTO_TEST_CASE(TDE16Frame_HeaderMutators)
      32              : {
      33            1 :   TDE16Frame tde16frame{};
      34            1 :   tde16frame.set_tde_errors(0xFC5F);
      35            1 :   tde16frame.set_timestamp(0x444455555555);
      36              : 
      37            1 :   BOOST_REQUIRE_EQUAL(tde16frame.get_tde_header()->tde_errors, 0xFC5F);
      38            1 :   BOOST_REQUIRE_EQUAL(tde16frame.get_daq_header()->timestamp, 0x444455555555);
      39            1 : }
      40              : 
      41            2 : BOOST_AUTO_TEST_CASE(TDE16Frame_StreamOperator)
      42              : {
      43            1 :   TDE16Frame tde16frame{};
      44              : 
      45            1 :   std::ostringstream ostr;
      46            1 :   ostr << tde16frame;
      47            1 :   auto output = ostr.str();
      48            1 :   BOOST_TEST_MESSAGE("Stream operator: " << output);
      49            1 :   BOOST_REQUIRE(!output.empty());
      50            1 : }
      51              : 
      52            2 : BOOST_AUTO_TEST_CASE(TDE16Frame_ADCDataMutators)
      53              : {
      54            1 :   TDE16Frame tde16frame{};
      55         4475 :   for (int i = 0; i < tot_adc16_samples; i++) {
      56         4474 :     tde16frame.set_adc_sample(0x63, i);
      57              :   }
      58              : 
      59           31 :   for (int i = 0; i < 30; i++) {
      60           30 :     BOOST_REQUIRE_EQUAL(tde16frame.get_adc_sample(i), 0x63);
      61              :   }
      62           21 :   for (int i = tot_adc16_samples - 20; i < tot_adc16_samples; i++) {
      63           20 :     BOOST_REQUIRE_EQUAL(tde16frame.get_adc_sample(i), 0x63);
      64              :   }
      65            1 : }
      66              : 
      67            2 : BOOST_AUTO_TEST_CASE(TDE16Frame_FromRawData)
      68              : {
      69            1 :   dunedaq::detdataformats::DAQEthHeader daq_header{};
      70            1 :   daq_header.timestamp = 0x222211111111;
      71            1 :   TDEHeader tde_header{};
      72            1 :   Sample samples_info[tot_adc16_samples]{};
      73              : 
      74            1 :   uint8_t* buff = static_cast<uint8_t*>(malloc(sizeof(daq_header) + sizeof(tde_header) + sizeof(samples_info)));
      75            1 :   memcpy(buff, &daq_header, sizeof(daq_header));
      76            1 :   memcpy(buff + sizeof(daq_header) + sizeof(tde_header), samples_info, sizeof(Sample) * tot_adc16_samples);
      77            1 :   TDE16Frame* from_raw_data = reinterpret_cast<TDE16Frame*>(buff);
      78              : 
      79            1 :   BOOST_REQUIRE_EQUAL(from_raw_data->get_timestamp(), 0x222211111111);
      80              : 
      81            1 :   from_raw_data = nullptr;
      82            1 :   free(buff);
      83            1 : }
      84              : 
      85              : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1