| 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 | 480 | bool testTableSize(size_t nbElement){ | |
| 17 |
2/2✓ Branch 0 (2→3) taken 480 times.
✓ Branch 2 (3→5) taken 320 times.
|
480 | T * tabData = new T[nbElement]; |
| 18 |
1/1✓ Branch 0 (5→6) taken 480 times.
|
480 | size_t sizeTabData = data_size(tabData, nbElement); |
| 19 | 480 | size_t expectedSize(nbElement*sizeof(T)); | |
| 20 |
2/2✓ Branch 0 (8→9) taken 480 times.
✓ Branch 2 (9→10) taken 480 times.
|
960 | return checkValue("testTableSize :", sizeTabData, expectedSize); |
| 21 | } | ||
| 22 | |||
| 23 | ///Check size of a table of data | ||
| 24 | /** @param nbElementMin : minimum number of elements of the table of data | ||
| 25 | * @param nbElementMax : maximum number of elements of the table of data | ||
| 26 | * @return true on success, false otherwise | ||
| 27 | */ | ||
| 28 | template<typename T> | ||
| 29 | 12 | bool testMultiTableSize(size_t nbElementMin, size_t nbElementMax){ | |
| 30 | 12 | bool b(true); | |
| 31 |
3/4✓ Branch 0 (5→6) taken 480 times.
✓ Branch 1 (5→7) taken 12 times.
✓ Branch 2 (6→3) taken 480 times.
✗ Branch 3 (6→7) not taken.
|
492 | for(size_t i(nbElementMin); i < nbElementMax && b; ++i){ |
| 32 | 480 | b &= testTableSize<T>(i); | |
| 33 | } | ||
| 34 | 12 | return b; | |
| 35 | } | ||
| 36 | |||
| 37 | ///Test if data size is Ok | ||
| 38 | 1 | void testSimpleTableDataSize(){ | |
| 39 |
4/4✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✓ Branch 4 (11→12) taken 1 times.
✓ Branch 6 (12→13) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<bool>(2lu, 42lu)); |
| 40 |
4/4✓ Branch 0 (22→23) taken 1 times.
✓ Branch 2 (25→26) taken 1 times.
✓ Branch 4 (28→29) taken 1 times.
✓ Branch 6 (29→30) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<char>(2lu, 42lu)); |
| 41 |
4/4✓ Branch 0 (39→40) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
✓ Branch 4 (45→46) taken 1 times.
✓ Branch 6 (46→47) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<int8_t>(2lu, 42lu)); |
| 42 |
4/4✓ Branch 0 (56→57) taken 1 times.
✓ Branch 2 (59→60) taken 1 times.
✓ Branch 4 (62→63) taken 1 times.
✓ Branch 6 (63→64) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<short>(2lu, 42lu)); |
| 43 |
4/4✓ Branch 0 (73→74) taken 1 times.
✓ Branch 2 (76→77) taken 1 times.
✓ Branch 4 (79→80) taken 1 times.
✓ Branch 6 (80→81) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<int>(2lu, 42lu)); |
| 44 |
4/4✓ Branch 0 (90→91) taken 1 times.
✓ Branch 2 (93→94) taken 1 times.
✓ Branch 4 (96→97) taken 1 times.
✓ Branch 6 (97→98) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<long int>(2lu, 42lu)); |
| 45 |
4/4✓ Branch 0 (107→108) taken 1 times.
✓ Branch 2 (110→111) taken 1 times.
✓ Branch 4 (113→114) taken 1 times.
✓ Branch 6 (114→115) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<unsigned char>(2lu, 42lu)); |
| 46 |
4/4✓ Branch 0 (124→125) taken 1 times.
✓ Branch 2 (127→128) taken 1 times.
✓ Branch 4 (130→131) taken 1 times.
✓ Branch 6 (131→132) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<unsigned short>(2lu, 42lu)); |
| 47 |
4/4✓ Branch 0 (141→142) taken 1 times.
✓ Branch 2 (144→145) taken 1 times.
✓ Branch 4 (147→148) taken 1 times.
✓ Branch 6 (148→149) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<unsigned int>(2lu, 42lu)); |
| 48 |
4/4✓ Branch 0 (158→159) taken 1 times.
✓ Branch 2 (161→162) taken 1 times.
✓ Branch 4 (164→165) taken 1 times.
✓ Branch 6 (165→166) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<unsigned long int>(2lu, 42lu)); |
| 49 |
4/4✓ Branch 0 (175→176) taken 1 times.
✓ Branch 2 (178→179) taken 1 times.
✓ Branch 4 (181→182) taken 1 times.
✓ Branch 6 (182→183) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<float>(2lu, 42lu)); |
| 50 |
4/4✓ Branch 0 (192→193) taken 1 times.
✓ Branch 2 (195→196) taken 1 times.
✓ Branch 4 (198→199) taken 1 times.
✓ Branch 6 (199→200) taken 1 times.
|
6 | data_stream_assert(testMultiTableSize<double>(2lu, 42lu)); |
| 51 | 1 | } | |
| 52 | |||
| 53 | 1 | int main(int argc, char** argv){ | |
| 54 | 1 | testSimpleTableDataSize(); | |
| 55 | 1 | return 0; | |
| 56 | } | ||
| 57 | |||
| 58 |