GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixSocket/src/phoenix_mock_socket.cpp
Date: 2025-03-14 12:18:05
Exec Total Coverage
Lines: 3 18 16.7%
Branches: 1 36 2.8%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #include <sstream>
8 #include "phoenix_mock_socket.h"
9
10 ///Create a mock socket
11 /** @param[out] vecInput : vector of input message to be read
12 * @param[out] inputFileName : name of the input message file to be loaded
13 * @param[out] outputFileName : name of the output message file to be written
14 * @param address : host address
15 * @param port : port to be used
16 * @return true on success, false otherwise
17 */
18 bool phoenix_createMockSocket(PVecMockMessage & vecInput, std::string & inputFileName, std::string & outputFileName, const std::string & address, size_t port){
19 std::stringstream strFileName;
20 strFileName << address << "_" << port << "_";
21 std::string baseFileName(strFileName.str());
22 // inputFileName = baseFileName + "_recv.pmocksocket";
23 // outputFileName = baseFileName + "_send.pmocksocket";
24
25 inputFileName = baseFileName + ".pmocksocket";
26 outputFileName = baseFileName + ".pmocksocket";
27
28 data_load(inputFileName, vecInput);
29 return true;
30 }
31
32 ///Read a mock socket
33 /** @param[out] vecInput : vector of input message to be read
34 * @param address : host address
35 * @param port : port to be used
36 * @return true on success, false otherwise
37 */
38 bool phoenix_readMockSocket(PVecMockMessage & vecInput, const std::string & address, size_t port){
39 std::stringstream strFileName;
40 strFileName << address << "_" << port << "_";
41 std::string baseFileName(strFileName.str());
42
43 std::string inputFileName = baseFileName + ".pmocksocket";
44
45 return data_load(inputFileName, vecInput);
46 }
47
48 ///Close a mock socket
49 /** @param vecOutput : vector of output messages to be saved
50 * @param outputFileName : name of the output message file to be written
51 * @return true on success, false otherwise
52 */
53 7 bool phoenix_closeMockSocket(const PVecMockMessage & vecOutput, const std::string & outputFileName){
54
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 if(vecOutput.size() != 0lu){
55 7 return data_save(outputFileName, vecOutput);
56 }else{
57 return true;
58 }
59 }
60
61