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

            Line data    Source code
       1              : 
       2              : /**
       3              :  * @file WIBEthFrame_test.cxx WIBEthFrame 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/WIBEthFrame.hpp"
      11              : 
      12              : #define BOOST_TEST_MODULE WIBEthFrame_test
      13              : 
      14              : #include "boost/test/unit_test.hpp"
      15              : 
      16              : #include <string>
      17              : #include <vector>
      18              : #include <random>
      19              : 
      20              : BOOST_AUTO_TEST_SUITE(WIBEthFrame_test)
      21              : 
      22            2 : BOOST_AUTO_TEST_CASE(WIBEthFrame_ADCDataMutators)
      23              : {
      24              :   // RNG with max 14 bit values
      25            1 :   std::random_device dev;
      26            1 :   std::mt19937 rng(dev());
      27            1 :   int max_adc_value = (unsigned)(1<<14)-1;
      28            1 :   std::uniform_int_distribution<std::mt19937::result_type> dist(1, max_adc_value);
      29              : 
      30              :   // Prepare source vector with ADC samples
      31            1 :   std::vector<std::vector<uint16_t>> v;
      32           65 :   for(int i=0; i<64; ++i) {
      33           64 :     v.emplace_back(std::vector<uint16_t>(64));
      34         4160 :     for (int j=0; j<64; ++j) {
      35         4096 :       auto rand_val = dist(rng);
      36         4096 :       v[i][j] = ((uint16_t)rand_val);
      37              :     }
      38              :   }
      39              : 
      40              :   // Set ADCs from ADC samples
      41            1 :   dunedaq::fddetdataformats::WIBEthFrame wibethframe {};
      42           65 :   for(std::size_t i=0; i<v.size(); ++i) {
      43         4160 :     for(std::size_t j=0; j<v[i].size(); ++j) {
      44         4096 :       wibethframe.set_adc(i, j, v[i][j]);
      45              :     }
      46              :   }
      47              : 
      48              :   // Get ADCs and compare
      49           65 :   for(std::size_t i=0; i<v.size(); ++i) {
      50         4160 :     for(std::size_t j=0; j<v[i].size(); ++j) {
      51         4096 :       BOOST_REQUIRE_EQUAL(wibethframe.get_adc(i, j), v[i][j]);
      52              :     }
      53              :   }
      54              : 
      55            1 : }
      56              : 
      57              : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1