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

            Line data    Source code
       1              : /**
       2              :  * @file TimeSync_test.cxx TimeSync 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 "dfmessages/TimeSync.hpp"
      10              : 
      11              : /**
      12              :  * @brief Name of this test module
      13              :  */
      14              : #define BOOST_TEST_MODULE TimeSync_test // NOLINT
      15              : 
      16              : #include "TRACE/trace.h"
      17              : #include "boost/test/unit_test.hpp"
      18              : 
      19              : using namespace dunedaq::dfmessages;
      20              : 
      21              : BOOST_AUTO_TEST_SUITE(TimeSync_test)
      22              : 
      23              : /**
      24              :  * @brief Check that TimeSyncs have appropriate Copy/Move semantics
      25              :  */
      26            2 : BOOST_AUTO_TEST_CASE(CopyAndMoveSemantics)
      27              : {
      28            1 :   BOOST_REQUIRE(std::is_copy_constructible_v<TimeSync>);
      29            1 :   BOOST_REQUIRE(std::is_copy_assignable_v<TimeSync>);
      30            1 :   BOOST_REQUIRE(std::is_move_constructible_v<TimeSync>);
      31            1 :   BOOST_REQUIRE(std::is_move_assignable_v<TimeSync>);
      32            1 : }
      33              : 
      34            2 : BOOST_AUTO_TEST_CASE(SerDes_MsgPack)
      35              : {
      36              : 
      37            1 :   TimeSync ts(0x123456789ABCDEF0);
      38              : 
      39            1 :   auto bytes = dunedaq::serialization::serialize(ts, dunedaq::serialization::kMsgPack);
      40            3 :   TLOG(TLVL_INFO) << "MsgPack message size: " << bytes.size() << " bytes";
      41            1 :   TimeSync ts_deserialized = dunedaq::serialization::deserialize<TimeSync>(bytes);
      42              : 
      43            1 :   BOOST_REQUIRE_EQUAL(ts.daq_time, ts_deserialized.daq_time);
      44            1 :   BOOST_REQUIRE_EQUAL(ts.system_time, ts_deserialized.system_time);
      45            1 : }
      46              : 
      47              : /**
      48              :  * @brief Test the TimeSync constructor
      49              :  */
      50            2 : BOOST_AUTO_TEST_CASE(Constructor)
      51              : {
      52            1 :   TimeSync ts(100);
      53            1 :   auto now = TimeSync::gettimeofday_us();
      54              : 
      55            1 :   BOOST_REQUIRE_EQUAL(ts.daq_time, 100);
      56              :   // Check that they are the same to within 1000 us.
      57            1 :   BOOST_REQUIRE_EQUAL(ts.system_time / 1000, now / 1000);
      58            1 : }
      59              : 
      60              : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1