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 |
#include "data_size.h" |
||
10 |
|||
11 |
///Check size of a table of data |
||
12 |
/** @param nbElement : number of elements of the table of data |
||
13 |
* @return true on success, false otherwise |
||
14 |
*/ |
||
15 |
template<typename T> |
||
16 |
880 |
bool testTableSize(size_t nbElement){ |
|
17 |
✓✗ | 880 |
T * tabData = new T[nbElement]; |
18 |
880 |
size_t sizeTabData = data_size(tabData, nbElement); |
|
19 |
880 |
return sizeTabData == nbElement*sizeof(T); |
|
20 |
} |
||
21 |
|||
22 |
///Check size of a table of data |
||
23 |
/** @param nbElementMin : minimum number of elements of the table of data |
||
24 |
* @param nbElementMax : maximum number of elements of the table of data |
||
25 |
* @return true on success, false otherwise |
||
26 |
*/ |
||
27 |
template<typename T> |
||
28 |
22 |
bool testMultiTableSize(size_t nbElementMin, size_t nbElementMax){ |
|
29 |
22 |
bool b(true); |
|
30 |
✓✓✓✗ |
902 |
for(size_t i(nbElementMin); i < nbElementMax && b; ++i){ |
31 |
880 |
b &= testTableSize<T>(i); |
|
32 |
} |
||
33 |
22 |
return b; |
|
34 |
} |
||
35 |
|||
36 |
///Test if data size is Ok |
||
37 |
1 |
void testSimpleTableDataSize(){ |
|
38 |
✓✓✓✓ ✓ |
1 |
data_stream_assert(testMultiTableSize<bool>(2lu, 42lu)); |
39 |
✓✓✓✓ ✓ |
1 |
data_stream_assert(testMultiTableSize<char>(2lu, 42lu)); |
40 |
✓✓✓✓ ✓ |
1 |
data_stream_assert(testMultiTableSize<short>(2lu, 42lu)); |
41 |
✓✓✓✓ ✓ |
1 |
data_stream_assert(testMultiTableSize<int>(2lu, 42lu)); |
42 |
✓✓✓✓ ✓ |
1 |
data_stream_assert(testMultiTableSize<long int>(2lu, 42lu)); |
43 |
✓✓✓✓ ✓ |
1 |
data_stream_assert(testMultiTableSize<unsigned char>(2lu, 42lu)); |
44 |
✓✓✓✓ ✓ |
1 |
data_stream_assert(testMultiTableSize<unsigned short>(2lu, 42lu)); |
45 |
✓✓✓✓ ✓ |
1 |
data_stream_assert(testMultiTableSize<unsigned int>(2lu, 42lu)); |
46 |
✓✓✓✓ ✓ |
1 |
data_stream_assert(testMultiTableSize<unsigned long int>(2lu, 42lu)); |
47 |
✓✓✓✓ ✓ |
1 |
data_stream_assert(testMultiTableSize<float>(2lu, 42lu)); |
48 |
✓✓✓✓ ✓ |
1 |
data_stream_assert(testMultiTableSize<double>(2lu, 42lu)); |
49 |
1 |
} |
|
50 |
|||
51 |
1 |
int main(int argc, char** argv){ |
|
52 |
1 |
testSimpleTableDataSize(); |
|
53 |
1 |
return 0; |
|
54 |
} |
||
55 |
Generated by: GCOVR (Version 4.2) |