LCOV - code coverage report
Current view: top level - include/testutils/hardio/impl - mock_serial_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_serial_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_serial_protocol.h
      23             :  * @author Robin Passama
      24             :  * @brief header file for MockSerialProtocol 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             : 
      33             : namespace hardio {
      34             : 
      35             : namespace test {
      36             : 
      37             : class MockSerialProtocol : public SerialProtocol {
      38             : public:
      39             :     MockSerialProtocol(size_t baudrate);
      40             : 
      41          22 :     virtual ~MockSerialProtocol() = default;
      42             : 
      43             :     bool custom_initialization(std::string& reason,
      44             :                                bool managed_thread = true) final;
      45             :     void flush() final;
      46             :     bool write(size_t length, const uint8_t* data) final;
      47             :     bool read(size_t length, uint8_t* data, size_t& read_data) final;
      48             : 
      49             :     bool can_bind_to(const std::shared_ptr<Interface>& other,
      50             :                      std::string& reason) const final;
      51             : 
      52             :     std::shared_ptr<MockMessageInterface> remote() const;
      53             : 
      54             : private:
      55             :     std::shared_ptr<MockMessageInterface> local_endpoint_, remote_endpoint_;
      56             : };
      57             : } // namespace test
      58             : } // namespace hardio

Generated by: LCOV version 1.16