GCC Code Coverage Report


Directory: ./
File: src/phoenix_createMockControl.cpp
Date: 2024-12-09 11:00:39
Exec Total Coverage
Lines: 29 36 80.6%
Branches: 11 23 47.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 "string_filename.h"
8 #include "phoenix_createMockControl.h"
9
10 ///Create a PMockConnectorVar
11 /** @param[out] var : PMockConnectorVar to be initialised
12 * @param fileName : file name to save the PMockConnectorVar
13 * TODO : add the type of the variable
14 */
15 5 void phoenix_mockCreate(PMockConnectorVar & var, const std::string & fileName){
16
1/1
✓ Branch 2 taken 5 times.
5 createDirectoriesIfNotExist(getDirectory(fileName));
17 5 var.setFileNameMock(fileName);
18 5 var.setIsWriteMode(true);
19
20 5 }
21
22 ///Append a value in a PMockConnectorVar
23 /** @param eventId : event id to be used
24 * @param[out] vecEventVar : vector of PMockEventVar to be modified
25 * @param value : value to be append
26 * @return true on success, false otherwise
27 */
28 151 bool phoenix_mockVarAppend(size_t eventId, std::vector<PMockEventVar> & vecEventVar, const PMockControlBackend::Message & value){
29
1/1
✓ Branch 1 taken 151 times.
151 PMockEventVar data;
30 //We have to get the eventId and append the value with it
31
1/1
✓ Branch 1 taken 151 times.
151 data.setEventId(eventId);
32
1/1
✓ Branch 1 taken 151 times.
151 data.setVecData(value);
33
1/1
✓ Branch 1 taken 151 times.
151 vecEventVar.push_back(data);
34 151 return true;
35 151 }
36
37 ///Save the PMockConnectorVar in a file
38 /** @param var : PMockConnectorVar to be saved
39 * @return true on success, false otherwise
40 */
41 5 bool phoenix_mockSave(const PMockConnectorVar & var){
42 5 return data_save(var.getFileNameMock(), var);
43 }
44
45
46 ///Create the PMockConnectorCall
47 /** @param[out] call : PMockConnectorCall to be created
48 * @param fileName : name of the file where to save the PMockConnectorCall
49 * @param prototype : prototype of the called function
50 */
51 2 void phoenix_mockCreate(PMockConnectorCall & call, const std::string& fileName, const PFunctionPrototype & prototype){
52
1/1
✓ Branch 2 taken 2 times.
2 createDirectoriesIfNotExist(getDirectory(fileName));
53 2 call.setFileNameMock(fileName);
54 2 call.setIsWriteMode(true);
55 2 call.setPrototype(prototype);
56 2 }
57
58 ///Append a call in a PMockConnectorCall
59 /** @param eventId : event id to be used
60 * @param[out] call : PMockConnectorCall to be modified
61 * @param param : serialised parameters call
62 * @return true on success, false otherwise
63 */
64 20 bool phoenix_mockCallAppend(size_t eventId, PMockConnectorCall & call, const std::vector<PMockControlBackend::Message> & param){
65
1/1
✓ Branch 1 taken 20 times.
20 PMockEventCall data;
66 //We have to get the eventId and append the value with it
67
1/1
✓ Branch 1 taken 20 times.
20 data.setEventId(eventId);
68
1/1
✓ Branch 1 taken 20 times.
20 data.setVecParam(param);
69
2/2
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
20 call.getVecEvent().push_back(data);
70 20 return true;
71 20 }
72
73 ///Append a call in a PMockConnectorCall
74 /** @param eventId : event id to be used
75 * @param[out] call : PMockConnectorCall to be modified
76 * @param param : serialised parameters call
77 * @param result : serialised result of the function call
78 * @return true on success, false otherwise
79 */
80 bool phoenix_mockCallAppend(size_t eventId, PMockConnectorCall & call, const std::vector<PMockControlBackend::Message> & param, const std::vector<PMockControlBackend::Message> & result){
81 PMockEventCall data;
82 //We have to get the eventId and append the value with it
83 data.setEventId(eventId);
84 data.setVecParam(param);
85 data.setVecResult(result);
86 call.getVecEvent().push_back(data);
87 return true;
88 }
89
90 ///Save the PMockConnectorCall in a file
91 /** @param call : PMockConnectorCall to be saved
92 * @return true on success, false otherwise
93 */
94 2 bool phoenix_mockSave(const PMockConnectorCall & call){
95 2 return data_save(call.getFileNameMock(), call);
96 }
97
98
99