LCOV - code coverage report
Current view: top level - rawdatautils/unittest - WIBtoWIB2_test.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 100.0 % 23 23
Test Date: 2025-12-21 13:07:08 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /**
       2              :  * @file WIBtoWIB2_test.cxx Unit Tests for the WIB -> WIB2 file converter
       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              : /**
      10              :  * @brief Name of this test module
      11              :  */
      12              : #define BOOST_TEST_MODULE WIBtoWIB2_test // NOLINT
      13              : 
      14              : #include "boost/test/unit_test.hpp"
      15              : 
      16              : #include "rawdatautils/WIBtoWIB2.hpp"
      17              : #include "fddetdataformats/WIBFrame.hpp"
      18              : 
      19              : #include <random>
      20              : 
      21              : namespace dunedaq{
      22              : namespace rawdatautils{
      23              : 
      24              : BOOST_AUTO_TEST_SUITE(WIBtoWIB2_test)
      25              : 
      26              : std::mt19937 mt(1000007);
      27              : 
      28            2 : BOOST_AUTO_TEST_CASE(WIBtoWIB2_test1)
      29              : {
      30              : 
      31            1 :   std::uniform_real_distribution<double> dist(0, 4096);
      32              : 
      33            1 :   std::vector<int> adcs;
      34          257 :   for (int i = 0; i < 256; i++) {
      35          256 :     int num = dist(mt);
      36          256 :     adcs.push_back(num);
      37              :   }
      38              :   
      39              :   fddetdataformats::WIBFrame fr;
      40          257 :   for (int i = 0; i < 256; i++){
      41          256 :     fr.set_channel(i, adcs[i]);
      42              :   }
      43            1 :   auto header = fr.get_wib_header();
      44            1 :   header->version = 31;
      45            1 :   header->crate_no = 31;
      46            1 :   header->slot_no = 7;
      47            1 :   header->fiber_no = 7;
      48            1 :   fr.set_timestamp(1844674407370955161U); //2**48-1
      49              : 
      50            1 :   auto wib2fr = wibtowib2(&fr, 1844674407370955161U);
      51          257 :   for (int i = 0; i < 256; i++){
      52          256 :     BOOST_REQUIRE_EQUAL(adcs[i], wib2fr.get_adc(i));
      53              :   }
      54            1 :   BOOST_REQUIRE_EQUAL(wib2fr.header.version, 31);
      55            1 :   BOOST_REQUIRE_EQUAL(wib2fr.header.crate, 31);
      56            1 :   BOOST_REQUIRE_EQUAL(wib2fr.header.slot, 7);
      57            1 :   BOOST_REQUIRE_EQUAL(wib2fr.header.link, 7);
      58            1 :   BOOST_REQUIRE_EQUAL(wib2fr.get_timestamp(), 1844674407370955161U);
      59            1 : }
      60              : 
      61              : } // namespace dunedaq
      62              : } // namespace rawdatautils
      63              : 
      64              : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1