LCOV - code coverage report
Current view: top level - ipm/unittest - ZmqSender_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 ZmqSender_test.cxx ZmqSender 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 "ipm/Sender.hpp"
      10              : #include "ipm/ZmqContext.hpp"
      11              : 
      12              : #define BOOST_TEST_MODULE ZmqSender_test // NOLINT
      13              : 
      14              : #include "boost/test/unit_test.hpp"
      15              : 
      16              : #include <string>
      17              : #include <vector>
      18              : 
      19              : using namespace dunedaq::ipm;
      20              : 
      21              : BOOST_AUTO_TEST_SUITE(ZmqSender_test)
      22              : 
      23            2 : BOOST_AUTO_TEST_CASE(BasicTests)
      24              : {
      25            1 :   auto the_sender = make_ipm_sender("ZmqSender");
      26            1 :   BOOST_REQUIRE(the_sender != nullptr);
      27            1 :   BOOST_REQUIRE(!the_sender->can_send());
      28            1 : }
      29              : 
      30            2 : BOOST_AUTO_TEST_CASE(Errors)
      31              : {
      32            1 :   auto the_sender = make_ipm_sender("ZmqSender");
      33            1 :   BOOST_REQUIRE(the_sender != nullptr);
      34            1 :   BOOST_REQUIRE(!the_sender->can_send());
      35              : 
      36            1 :   nlohmann::json config_json;
      37              : 
      38            1 :   config_json["connection_string"] = "not a uri";
      39            3 :   BOOST_REQUIRE_EXCEPTION(the_sender->connect_for_sends(config_json), ZmqOperationError, [&](ZmqOperationError e) {
      40              :     return std::string(e.what()).find("Operation failed for all resolved connection strings") != std::string::npos;
      41              :   });
      42            1 :   BOOST_REQUIRE(!the_sender->can_send());
      43              :   
      44            1 :   config_json["connection_string"] = "tcp://thishostddoesnotexist";
      45            3 :   BOOST_REQUIRE_EXCEPTION(the_sender->connect_for_sends(config_json), ZmqOperationError, [&](ZmqOperationError e) {
      46              :     return std::string(e.what()).find("Operation failed for all resolved connection strings") != std::string::npos;
      47              :   });
      48            1 :   BOOST_REQUIRE(!the_sender->can_send());
      49              :   
      50            1 :   config_json["connection_string"] = "badproto://default";
      51            3 :   BOOST_REQUIRE_EXCEPTION(the_sender->connect_for_sends(config_json), ZmqOperationError, [&](ZmqOperationError e) {
      52              :     return std::string(e.what()).find("Operation failed for all resolved connection strings") != std::string::npos;
      53              :   });
      54            1 :   BOOST_REQUIRE(!the_sender->can_send());
      55            1 : }
      56              : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1