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

            Line data    Source code
       1              : /**
       2              :  * @file CRTGrenobleFrame_test.cxx CRTGrenobleFrame class Unit Tests
       3              :  *
       4              :  * This is part of the DUNE DAQ Application Framework, copyright 2022.
       5              :  * Licensing/copyright details are in the COPYING file that you should have
       6              :  * received with this code.
       7              :  */
       8              : 
       9              : #include "fddetdataformats/CRTGrenobleFrame.hpp"
      10              : 
      11              : #define BOOST_TEST_MODULE CRTGrenobleFrame_test // NOLINT
      12              : 
      13              : #include "boost/test/unit_test.hpp"
      14              : 
      15              : #include <random>
      16              : #include <vector>
      17              : 
      18              : BOOST_AUTO_TEST_SUITE(CRTGrenobleFrame_test)
      19              : 
      20            2 : BOOST_AUTO_TEST_CASE(CRTGrenobleFrame_ADCDataMutators)
      21              : {
      22            1 :   using dunedaq::fddetdataformats::CRTGrenobleFrame;
      23              : 
      24            1 :   std::random_device dev;
      25            1 :   std::mt19937 rng(dev());
      26            1 :   std::uniform_int_distribution<int> dist(-100000, 100000);
      27              : 
      28            1 :   std::vector<int> adcs(CRTGrenobleFrame::s_num_channels);
      29           33 :   for (auto& value : adcs) {
      30           32 :     value = dist(rng);
      31              :   }
      32              : 
      33            1 :   CRTGrenobleFrame frame{};
      34              : 
      35           33 :   for (int channel = 0; channel < CRTGrenobleFrame::s_num_channels; ++channel) {
      36           32 :     frame.set_adc(channel, adcs[channel]);
      37              :   }
      38              : 
      39           33 :   for (int channel = 0; channel < CRTGrenobleFrame::s_num_channels; ++channel) {
      40           32 :     BOOST_REQUIRE_EQUAL(frame.get_adc(channel), adcs[channel]);
      41              :   }
      42              : 
      43            1 :   frame.set_adc(0, adcs[0]);
      44           33 :   for (int channel = 0; channel < CRTGrenobleFrame::s_num_channels; ++channel) {
      45           32 :     BOOST_REQUIRE_EQUAL(frame.get_adc(channel), adcs[channel]);
      46              :   }
      47            1 : }
      48              : 
      49            2 : BOOST_AUTO_TEST_CASE(CRTGrenobleFrame_IndexBounds)
      50              : {
      51            1 :   using dunedaq::fddetdataformats::CRTGrenobleFrame;
      52              : 
      53            1 :   CRTGrenobleFrame frame{};
      54              : 
      55            1 :   BOOST_CHECK_THROW(frame.get_adc(-1), std::out_of_range);
      56            1 :   BOOST_CHECK_THROW(frame.get_adc(CRTGrenobleFrame::s_num_channels), std::out_of_range);
      57              : 
      58            1 :   BOOST_CHECK_THROW(frame.set_adc(-1, 123), std::out_of_range);
      59            1 :   BOOST_CHECK_THROW(frame.set_adc(CRTGrenobleFrame::s_num_channels, 123), std::out_of_range);
      60            1 : }
      61              : 
      62            2 : BOOST_AUTO_TEST_CASE(CRTGrenobleFrame_TimestampMutators)
      63              : {
      64            1 :   using dunedaq::fddetdataformats::CRTGrenobleFrame;
      65              : 
      66            1 :   CRTGrenobleFrame frame{};
      67              : 
      68            1 :   frame.set_timestamp(0x0123456789ABCDEFuLL);
      69            1 :   BOOST_CHECK_EQUAL(frame.get_timestamp(), 0x0123456789ABCDEFuLL);
      70            1 : }
      71              : 
      72            2 : BOOST_AUTO_TEST_CASE(CRTGrenobleFrame_Constants)
      73              : {
      74            1 :   using dunedaq::fddetdataformats::CRTGrenobleFrame;
      75              : 
      76            1 :   BOOST_CHECK_EQUAL(CRTGrenobleFrame::s_DTS_ticks_per_second, 62500000u);
      77            1 :   BOOST_CHECK_EQUAL(CRTGrenobleFrame::s_ns_per_DTS_tick, 16u);
      78            1 : }
      79              : 
      80              : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1