LCOV - code coverage report
Current view: top level - datahandlinglibs/unittest - datahandlinglibs_IterableQueueModel_test.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 100.0 % 19 19
Test Date: 2026-07-12 15:23:06 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /**
       2              :  * @file datahandlinglibs_IterableQueueModel_test.cxx Unit Tests for IterableQueueModel
       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 datahandlinglibs_IterableQueueModel_test // NOLINT
      13              : 
      14              : #include "boost/test/unit_test.hpp"
      15              : 
      16              : #include "datahandlinglibs/ReadoutTypes.hpp"
      17              : #include "datahandlinglibs/models/IterableQueueModel.hpp"
      18              : 
      19              : #include <utility>
      20              : 
      21              : BOOST_AUTO_TEST_SUITE(datahandlinglibs_IterableQueueModel_test)
      22              : 
      23              : using namespace dunedaq::datahandlinglibs;
      24              : 
      25              : using ReadoutType = types::DUMMY_FRAME_STRUCT;
      26              : 
      27            2 : BOOST_AUTO_TEST_CASE(datahandlinglibs_IterableQueueModel_write)
      28              : {
      29            1 :   const std::size_t size = 4;
      30            1 :   IterableQueueModel<ReadoutType> buffer(size);
      31              : 
      32            1 :   ReadoutType frame1;
      33            1 :   frame1.timestamp = 2;
      34            1 :   BOOST_REQUIRE_EQUAL(buffer.write(std::move(frame1)), true);
      35            1 :   BOOST_REQUIRE_EQUAL(buffer.back()->get_timestamp(), 2);  
      36              : 
      37              :   // Last written == back() in queue
      38            1 :   ReadoutType frame2;
      39            1 :   frame2.timestamp = 1;
      40            1 :   BOOST_REQUIRE_EQUAL(buffer.write(std::move(frame2)), true);
      41            1 :   BOOST_REQUIRE_EQUAL(buffer.back()->get_timestamp(), 1);
      42              : 
      43              :   // Queue accepts duplicates
      44            1 :   ReadoutType frame3;
      45            1 :   frame3.timestamp = 1;  
      46            1 :   BOOST_REQUIRE_EQUAL(buffer.write(std::move(frame3)), true);
      47            1 :   BOOST_REQUIRE_EQUAL(buffer.back()->get_timestamp(), 1);
      48              : 
      49              :   // Overflow (the actual capacity is size - 1, in this case it is 3)
      50            1 :   ReadoutType frame4;
      51            1 :   frame4.timestamp = 1;
      52            1 :   BOOST_REQUIRE_EQUAL(buffer.write(std::move(frame4)), false);
      53            1 : }
      54              : 
      55              : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1