LCOV - code coverage report
Current view: top level - include/testutils/hardio/impl - mock_udp_protocol.h (source / functions) Hit Total Coverage
Test: hardiocore_coverage Lines: 1 1 100.0 %
Date: 2025-05-26 19:00:29 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /*      File: mock_udp_protocol.h
       2             :  *       This file is part of the program hardiocore
       3             :  *       Program description : Abstract low level I/O removing direct hardware
       4             :  * implementation Copyright (C) 2018-2020 -  Robin Passama (CNRS / LIRMM)
       5             :  * Clement Rebut (EPITA / LIRMM) Charles Villard (EPITA / LIRMM). All Right
       6             :  * reserved.
       7             :  *
       8             :  *       This software is free software: you can redistribute it and/or modify
       9             :  *       it under the terms of the CeCILL-C license as published by
      10             :  *       the CEA CNRS INRIA, either version 1
      11             :  *       of the License, or (at your option) any later version.
      12             :  *       This software is distributed in the hope that it will be useful,
      13             :  *       but WITHOUT ANY WARRANTY without even the implied warranty of
      14             :  *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      15             :  *       CeCILL-C License for more details.
      16             :  *
      17             :  *       You should have received a copy of the CeCILL-C License
      18             :  *       along with this software. If not, it can be found on the official
      19             :  * website of the CeCILL licenses family (http://www.cecill.info/index.en.html).
      20             :  */
      21             : /**
      22             :  * @file impl/mock_udp_protocol.h
      23             :  * @author Robin Passama
      24             :  * @brief header file for MockUDPEndpoint class.
      25             :  * @date May 2025
      26             :  * @ingroup  testutils
      27             :  */
      28             : #pragma once
      29             : 
      30             : #include <hardio/core.h>
      31             : #include <hardio/test/mock_message_interface.h>
      32             : #include <map>
      33             : 
      34             : namespace hardio {
      35             : 
      36             : namespace test {
      37             : 
      38             : ////////////////////////////////////////////////////////////////////
      39             : ////////////////////////////////////////////////////////////////////
      40             : ////////////////////////////////////////////////////////////////////
      41             : 
      42             : class MockUDPEndpoint : public UDPEndpoint {
      43             : public:
      44             :     MockUDPEndpoint(ssize_t port = -1);
      45             : 
      46          46 :     virtual ~MockUDPEndpoint() = default;
      47             : 
      48             :     std::vector<EndpointSpec> connected_endpoints() const final;
      49             : 
      50             :     bool memorize(std::string_view server = "", ssize_t remote_port = -1) final;
      51             : 
      52             :     bool write_to(std::string_view server, ssize_t port, size_t length,
      53             :                   const uint8_t* data) final;
      54             : 
      55             :     bool read_from(std::string_view server, ssize_t port, size_t length,
      56             :                    uint8_t* data, size_t& data_read) final;
      57             : 
      58             :     bool read_from_if(std::string_view server, ssize_t port, size_t length,
      59             :                       uint8_t* data, size_t& data_read) final;
      60             : 
      61             :     std::shared_ptr<MockMessageInterface> remote(const std::string& ip,
      62             :                                                  ssize_t port) const;
      63             : 
      64             : private:
      65             :     std::map<uint64_t, std::tuple<std::string, ssize_t,
      66             :                                   std::shared_ptr<MockMessageInterface>,
      67             :                                   std::shared_ptr<MockMessageInterface>>>
      68             :         connected_endpoints_;
      69             : };
      70             : 
      71             : } // namespace test
      72             : 
      73             : } // namespace hardio

Generated by: LCOV version 1.16