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

            Line data    Source code
       1              : /**
       2              :  *
       3              :  * @file ZmqUri_test.cxx ZmqUri struct unit tests
       4              :  *
       5              :  * This is part of the DUNE DAQ Application Framework, copyright 2020.
       6              :  * Licensing/copyright details are in the COPYING file that you should have
       7              :  * received with this code.
       8              :  */
       9              : 
      10              : #include "utilities/Issues.hpp"
      11              : #include "utilities/ZmqUri.hpp"
      12              : 
      13              : #include "logging/Logging.hpp"
      14              : 
      15              : #define BOOST_TEST_MODULE ZmqUri_test // NOLINT
      16              : 
      17              : #include "boost/test/unit_test.hpp"
      18              : 
      19              : #include <chrono>
      20              : #include <filesystem>
      21              : #include <fstream>
      22              : #include <regex>
      23              : 
      24              : using namespace dunedaq::utilities;
      25              : 
      26            2 : BOOST_AUTO_TEST_CASE(Construct)
      27              : {
      28            1 :   ZmqUri test("inproc://test");
      29            4 :   BOOST_REQUIRE_EXCEPTION(ZmqUri bad("bad"), InvalidUri, [](InvalidUri const&) { return true; });
      30              : 
      31            1 :   BOOST_REQUIRE_EQUAL(test.scheme, "inproc");
      32            1 :   BOOST_REQUIRE_EQUAL(test.host, "test");
      33            1 :   BOOST_REQUIRE_EQUAL(test.port, "");
      34            1 :   BOOST_REQUIRE_EQUAL(test.to_string(), "inproc://test");
      35              : 
      36            1 :   ZmqUri test_tcp("tcp://localhost:1234");
      37            1 :   BOOST_REQUIRE_EQUAL(test_tcp.scheme, "tcp");
      38            1 :   BOOST_REQUIRE_EQUAL(test_tcp.host, "localhost");
      39            1 :   BOOST_REQUIRE_EQUAL(test_tcp.port, "1234");
      40            1 :   BOOST_REQUIRE_EQUAL(test_tcp.to_string(), "tcp://localhost:1234");
      41            1 : }
      42              : 
      43            2 : BOOST_AUTO_TEST_CASE(UriLookup)
      44              : {
      45            3 :   TLOG() << "Test UriLookup BEGIN";
      46            1 :   ZmqUri test("tcp://127.0.0.1:1234");
      47            1 :   auto res = test.get_uri_ip_addresses();
      48            1 :   BOOST_REQUIRE_GE(res.size(), 1);
      49            1 :   BOOST_REQUIRE(res[0] == "tcp://127.0.0.1:1234");
      50              : 
      51            1 :   ZmqUri test2("tcp://localhost:1234");
      52            1 :   res = test2.get_uri_ip_addresses();
      53            1 :   BOOST_REQUIRE_GE(res.size(), 1);
      54            1 :   BOOST_REQUIRE(res[0] == "tcp://127.0.0.1:1234" || res[0] == "tcp://::1:1234");
      55              : 
      56            1 :   ZmqUri test3("inproc://foo");
      57            1 :   res = test3.get_uri_ip_addresses();
      58            1 :   BOOST_REQUIRE_GE(res.size(), 1);
      59            1 :   BOOST_REQUIRE(res[0] == "inproc://foo");
      60              : 
      61            3 :   TLOG() << "Test UriLookup END";
      62            1 : }
        

Generated by: LCOV version 2.0-1