GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
/*************************************** |
||
2 |
Auteur : Pierre Aubert |
||
3 |
Mail : pierre.aubert@lapp.in2p3.fr |
||
4 |
Licence : CeCILL-C |
||
5 |
****************************************/ |
||
6 |
|||
7 |
#include "data_stream_assert.h" |
||
8 |
#include "data_stream_check_value.h" |
||
9 |
|||
10 |
#include "data_size.h" |
||
11 |
#include "data_message.h" |
||
12 |
|||
13 |
///Test the serialisation/deserialisation of table of data in message |
||
14 |
/** @param typeNameStr : name of the used type |
||
15 |
* @param nbElement : number of elements in the table of data |
||
16 |
* @return true on success, false otherwise |
||
17 |
*/ |
||
18 |
template<typename T> |
||
19 |
2156 |
bool testSimpleTableMessage(const std::string & typeNameStr, size_t nbElement){ |
|
20 |
✓✓✓ | 2156 |
T * tabData = new T[nbElement]; |
21 |
✓✓ | 111034 |
for(size_t i(0lu); i < nbElement; ++i){ |
22 |
108878 |
tabData[i] = 2lu*i + 1u; |
|
23 |
} |
||
24 |
✓✓ | 4312 |
std::vector<char> messageData(data_size(tabData, nbElement)); |
25 |
2156 |
char* iterMsg = (char*)messageData.data(); |
|
26 |
2156 |
bool b(true); |
|
27 |
✓ | 2156 |
b &= data_message_save(iterMsg, tabData, nbElement); //Save the message |
28 |
|||
29 |
✓✓✓ | 2156 |
T * tabLoadedData = new T[nbElement]; |
30 |
2156 |
char* loadIterMsg = (char*)messageData.data(); |
|
31 |
✓ | 2156 |
b &= data_message_load(loadIterMsg, tabLoadedData, nbElement); //Load the message |
32 |
|||
33 |
✓ | 2156 |
std::stringstream str; |
34 |
✓ | 2156 |
str << nbElement; |
35 |
✓✓✓✓ ✓ |
4312 |
return checkValue(typeNameStr + "("+str.str()+")", tabLoadedData, tabData, nbElement); |
36 |
} |
||
37 |
|||
38 |
///Test the serialisation/deserialisation of table of data in message |
||
39 |
/** @param typeNameStr : name of the used type |
||
40 |
* @param nbElementMin : minimum number of elements in the table of data |
||
41 |
* @param nbElementMax : maximu number of elements in the table of data |
||
42 |
* @return true on success, false otherwise |
||
43 |
*/ |
||
44 |
template<typename T> |
||
45 |
22 |
bool testMultiSimpleTableMessage(const std::string & typeNameStr, size_t nbElementMin, size_t nbElementMax){ |
|
46 |
22 |
bool b(true); |
|
47 |
✓✓✓✗ |
2178 |
for(size_t i(nbElementMin); i < nbElementMax && b; ++i){ |
48 |
2156 |
b &= testSimpleTableMessage<T>(typeNameStr, i); |
|
49 |
} |
||
50 |
22 |
return b; |
|
51 |
} |
||
52 |
|||
53 |
///Test if data size is Ok |
||
54 |
1 |
void testSimpleTableDataMessage(){ |
|
55 |
✓✓✓✓ ✓✓ |
1 |
data_stream_assert(testMultiSimpleTableMessage<bool>("bool", 2lu, 100lu)); |
56 |
✓✓✓✓ ✓✓ |
1 |
data_stream_assert(testMultiSimpleTableMessage<char>("char", 2lu, 100lu)); |
57 |
✓✓✓✓ ✓✓ |
1 |
data_stream_assert(testMultiSimpleTableMessage<short>("short", 2lu, 100lu)); |
58 |
✓✓✓✓ ✓✓ |
1 |
data_stream_assert(testMultiSimpleTableMessage<int>("int", 2lu, 100lu)); |
59 |
✓✓✓✓ ✓✓ |
1 |
data_stream_assert(testMultiSimpleTableMessage<long int>("long int", 2lu, 100lu)); |
60 |
✓✓✓✓ ✓✓ |
1 |
data_stream_assert(testMultiSimpleTableMessage<unsigned char>("unsigned char", 2lu, 100lu)); |
61 |
✓✓✓✓ ✓✓ |
1 |
data_stream_assert(testMultiSimpleTableMessage<unsigned short>("unsigned short", 2lu, 100lu)); |
62 |
✓✓✓✓ ✓✓ |
1 |
data_stream_assert(testMultiSimpleTableMessage<unsigned int>("unsigned int", 2lu, 100lu)); |
63 |
✓✓✓✓ ✓✓ |
1 |
data_stream_assert(testMultiSimpleTableMessage<long unsigned int>("long unsigned int", 2lu, 100lu)); |
64 |
✓✓✓✓ ✓✓ |
1 |
data_stream_assert(testMultiSimpleTableMessage<float>("float", 2lu, 100lu)); |
65 |
✓✓✓✓ ✓✓ |
1 |
data_stream_assert(testMultiSimpleTableMessage<double>("double", 2lu, 100lu)); |
66 |
1 |
} |
|
67 |
|||
68 |
1 |
int main(int argc, char** argv){ |
|
69 |
1 |
testSimpleTableDataMessage(); |
|
70 |
1 |
return 0; |
|
71 |
} |
||
72 |
Generated by: GCOVR (Version 4.2) |