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

            Line data    Source code
       1              : /**
       2              :  * @file ComponentRequest_test.cxx ComponentRequest class Unit Tests
       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              : #include "daqdataformats/ComponentRequest.hpp"
      10              : 
      11              : /**
      12              :  * @brief Name of this test module
      13              :  */
      14              : #define BOOST_TEST_MODULE ComponentRequest_test // NOLINT
      15              : 
      16              : #include "boost/test/unit_test.hpp"
      17              : 
      18              : #include <string>
      19              : #include <vector>
      20              : 
      21              : using namespace dunedaq::daqdataformats;
      22              : 
      23              : BOOST_AUTO_TEST_SUITE(ComponentRequest_test)
      24              : 
      25            2 : BOOST_AUTO_TEST_CASE(Constructor)
      26              : {
      27            1 :   SourceID test{ SourceID::Subsystem::kDetectorReadout, 12345 };
      28              : 
      29            1 :   ComponentRequest component(test, 3, 4);
      30            1 :   BOOST_REQUIRE_EQUAL(component.window_begin, 3);
      31            1 :   BOOST_REQUIRE_EQUAL(component.window_end, 4);
      32            1 :   BOOST_REQUIRE_EQUAL(component.component, test);
      33            1 : }
      34              : 
      35              : /**
      36              :  * @brief Test that ComponentRequest::operator<< functions as expected
      37              :  */
      38            2 : BOOST_AUTO_TEST_CASE(StreamOperator)
      39              : {
      40            1 :   ComponentRequest component;
      41              : 
      42            1 :   SourceID::ID_t arbitrary_id = 6789;
      43            1 :   SourceID test = { SourceID::Subsystem::kDetectorReadout, arbitrary_id };
      44              : 
      45            1 :   component.component = test;
      46            1 :   component.window_begin = 3;
      47            1 :   component.window_end = 4;
      48              : 
      49            1 :   std::ostringstream ostr;
      50            1 :   ostr << component;
      51              : 
      52            1 :   std::string output = ostr.str();
      53            1 :   BOOST_TEST_MESSAGE("Stream operator: " << output);
      54              : 
      55            1 :   BOOST_REQUIRE(!output.empty());
      56            1 :   auto pos = output.find(std::to_string(arbitrary_id));
      57            1 :   BOOST_REQUIRE(pos != std::string::npos);
      58            1 :   pos = output.find("begin: 3,");
      59            1 :   BOOST_REQUIRE(pos != std::string::npos);
      60              : 
      61            1 :   std::istringstream istr(output);
      62            1 :   ComponentRequest component_from_stream;
      63            1 :   istr >> component_from_stream;
      64            1 :   BOOST_REQUIRE_EQUAL(component_from_stream.component, component.component);
      65            1 :   BOOST_REQUIRE_EQUAL(component_from_stream.window_begin, component.window_begin);
      66            1 :   BOOST_REQUIRE_EQUAL(component_from_stream.window_end, component.window_end);
      67            1 : }
      68              : 
      69              : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1