| Directory: | ./ |
|---|---|
| File: | src/phoenix_createMockControl_impl.h |
| Date: | 2024-12-09 11:00:39 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 21 | 21 | 100.0% |
| Branches: | 18 | 27 | 66.7% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Pierre Aubert | ||
| 3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #ifndef __PHOENIX_CREATEMOCKCONTROL_IMPL_H__ | ||
| 8 | #define __PHOENIX_CREATEMOCKCONTROL_IMPL_H__ | ||
| 9 | |||
| 10 | #include "phoenix_createMockControl.h" | ||
| 11 | |||
| 12 | ///Append a data in a PMockConnectorVar | ||
| 13 | /** @param eventId : event id to be used | ||
| 14 | * @param[out] var : PMockConnectorVar to be modified | ||
| 15 | * @param data : data to be append | ||
| 16 | */ | ||
| 17 | template<typename T> | ||
| 18 | 50 | bool phoenix_mockVarAppendData(size_t eventId, PMockConnectorVar & var, const T & data){ | |
| 19 |
1/1✓ Branch 1 taken 50 times.
|
50 | size_t dataSize(data_size<T>(data)); |
| 20 | 50 | PMockControlBackend::Message vecTmpMsg; | |
| 21 |
1/1✓ Branch 1 taken 50 times.
|
50 | vecTmpMsg.resize(dataSize); |
| 22 | 50 | char* iter = (char*)vecTmpMsg.data(); | |
| 23 |
1/1✓ Branch 1 taken 50 times.
|
50 | data_message_save<char*, T>(iter, data); |
| 24 |
2/2✓ Branch 1 taken 50 times.
✓ Branch 4 taken 50 times.
|
50 | phoenix_mockVarAppend(eventId, var.getVecEvent(), vecTmpMsg); |
| 25 | 50 | return true; | |
| 26 | 50 | } | |
| 27 | |||
| 28 | ///Append a call in a PMockConnectorCall | ||
| 29 | /** @param eventId : event if to be used | ||
| 30 | * @param[out] call : PMockConnectorCall to be modified | ||
| 31 | * @param __args : list of arguments of the function call | ||
| 32 | */ | ||
| 33 | template<typename... _Args> | ||
| 34 | 20 | bool phoenix_mockCallAppendData(size_t eventId, PMockConnectorCall & call, _Args&&... __args){ | |
| 35 | 20 | bool b(true); | |
| 36 |
1/1✓ Branch 1 taken 20 times.
|
20 | std::tuple<_Args... > tupleCall = std::make_tuple(__args...); |
| 37 | //Let's create the type for parameters from the function arguments | ||
| 38 | 20 | std::vector<PComposeType> vecParamType; | |
| 39 |
1/1✓ Branch 1 taken 20 times.
|
20 | b &= PSerialiseCallType<0, std::tuple_size<std::tuple<_Args... > >{} >::makeType(vecParamType, tupleCall); |
| 40 | //Let's check if the type of parameters is OK compare to what we expect | ||
| 41 |
9/18✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 20 times.
✓ Branch 6 taken 20 times.
✓ Branch 10 taken 20 times.
✓ Branch 13 taken 20 times.
✓ Branch 15 taken 20 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 20 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 20 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 20 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
20 | if(b && checkValue("phoenix_mockCallAppendData : Check param type", call.getPrototype().getVecParam(), vecParamType)){ |
| 42 | //Let's serialise the function arguments as they correspond to the extected type | ||
| 43 | 20 | std::vector<PMockControlBackend::Message> vecParamData; | |
| 44 |
1/1✓ Branch 1 taken 20 times.
|
20 | b &= PSerialiseCallType<0, std::tuple_size<std::tuple<_Args... > >{} >::makeParam(vecParamData, tupleCall); |
| 45 | //Let's add the call into the mock | ||
| 46 |
1/1✓ Branch 1 taken 20 times.
|
20 | b &= phoenix_mockCallAppend(eventId, call, vecParamData); |
| 47 | 20 | } | |
| 48 | 20 | return b; | |
| 49 | 20 | } | |
| 50 | |||
| 51 | |||
| 52 | #endif | ||
| 53 |