Directory: | ./ |
---|---|
File: | tmp_project/PhoenixDataStream/TESTS/TEST_DATA_SIZE/main_vector.cpp |
Date: | 2025-03-14 11:54:19 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 22 | 22 | 100.0% |
Branches: | 29 | 29 | 100.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | #include "phoenix_data_stream.h" | ||
8 | |||
9 | ///Check the size of given vector of data | ||
10 | /** @param testTypeName : name of the type to test | ||
11 | */ | ||
12 | template<typename T> | ||
13 | 20 | void checkVectorDataSize(const std::string & testTypeName){ | |
14 | 20 | size_t nbValue(10lu); | |
15 | 20 | std::vector<T> vecData; | |
16 |
3/3✓ Branch 1 taken 100 times.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 10 times.
|
220 | for(size_t i(0lu); i < nbValue; ++i){vecData.push_back(i);} |
17 |
1/1✓ Branch 1 taken 10 times.
|
20 | size_t sizeData = data_size(vecData); |
18 |
5/5✓ Branch 2 taken 10 times.
✓ Branch 6 taken 10 times.
✓ Branch 10 taken 10 times.
✓ Branch 13 taken 10 times.
✓ Branch 16 taken 10 times.
|
20 | data_stream_assert(checkValue(testTypeName, sizeData, sizeof(T)*nbValue + sizeof(size_t))); |
19 | 20 | } | |
20 | |||
21 | ///Test if data size is Ok | ||
22 | 1 | void testVectorDataSize(){ | |
23 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | checkVectorDataSize<long unsigned int>("long unsigned int"); |
24 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | checkVectorDataSize<unsigned int>("unsigned int"); |
25 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | checkVectorDataSize<unsigned short>("unsigned short"); |
26 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | checkVectorDataSize<unsigned char>("unsigned char"); |
27 | |||
28 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | checkVectorDataSize<long int>("long int"); |
29 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | checkVectorDataSize<long>("long"); |
30 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | checkVectorDataSize<int>("int"); |
31 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | checkVectorDataSize<short>("short"); |
32 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | checkVectorDataSize<char>("char"); |
33 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | checkVectorDataSize<int8_t>("int8_t"); |
34 | 1 | } | |
35 | |||
36 | |||
37 | 1 | int main(int argc, char** argv){ | |
38 | 1 | testVectorDataSize(); | |
39 | 1 | return 0; | |
40 | } | ||
41 | |||
42 |