GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixDataStream/TESTS/TEST_DATA_FILE/main_map.cpp
Date: 2025-03-14 12:18:05
Exec Total Coverage
Lines: 41 41 100.0%
Branches: 70 70 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 ///Abstract check of values stored in a file
10 /** @param testName : name of the test
11 * @param nbValue : number of values to put in the reference map
12 */
13 template<typename T, typename U>
14 288 void testSimpleMapValue(const std::string & testName, size_t nbValue){
15
1/1
✓ Branch 2 taken 144 times.
288 std::string fileName("value_test_map.data");
16 288 std::map<T, U> vecRef;
17
6/6
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 1272 times.
✓ Branch 3 taken 1440 times.
✓ Branch 4 taken 120 times.
✓ Branch 5 taken 240 times.
✓ Branch 6 taken 24 times.
3168 for(size_t i(0lu); i < nbValue; ++i){vecRef[i] = (U)(2lu*i > nbValue/2lu);}
18
5/5
✓ Branch 2 taken 144 times.
✓ Branch 6 taken 144 times.
✓ Branch 10 taken 144 times.
✓ Branch 13 taken 144 times.
✓ Branch 16 taken 144 times.
288 data_stream_assert(data_save(fileName, vecRef));
19 288 std::map<T, U> vecValue;
20
5/5
✓ Branch 2 taken 144 times.
✓ Branch 6 taken 144 times.
✓ Branch 10 taken 144 times.
✓ Branch 13 taken 144 times.
✓ Branch 16 taken 144 times.
288 data_stream_assert(data_load(fileName, vecValue));
21
5/5
✓ Branch 2 taken 144 times.
✓ Branch 6 taken 144 times.
✓ Branch 10 taken 144 times.
✓ Branch 13 taken 144 times.
✓ Branch 16 taken 144 times.
288 data_stream_assert(checkValue(testName, vecValue, vecRef));
22 288 }
23
24 ///Abstract check of values stored in a file
25 /** @param firstTypeName : name of the first type
26 * @param nbValue : number of values to put in the reference map
27 */
28 template<typename T>
29 24 void testSetMapValue(const std::string & firstTypeName, size_t nbValue){
30
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, long unsigned int>("std::map<"+firstTypeName+", long unsigned int>", nbValue);
31
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, unsigned int>("std::map<"+firstTypeName+", unsigned int>", nbValue);
32
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, unsigned short>("std::map<"+firstTypeName+", unsigned short>", nbValue);
33
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, unsigned char>("std::map<"+firstTypeName+", unsigned char>", nbValue);
34
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, long int>("std::map<"+firstTypeName+", long int>", nbValue);
35
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, int>("std::map<"+firstTypeName+", int>", nbValue);
36
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, short>("std::map<"+firstTypeName+", short>", nbValue);
37
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, char>("std::map<"+firstTypeName+", char>", nbValue);
38
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, int8_t>("std::map<"+firstTypeName+", int8_t>", nbValue);
39
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, float>("std::map<"+firstTypeName+", float>", nbValue);
40
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, double>("std::map<"+firstTypeName+", double>", nbValue);
41
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
24 testSimpleMapValue<T, bool>("std::map<"+firstTypeName+", bool>", nbValue);
42
43 24 }
44
45 ///Test if data size is Ok
46 1 void testMapDataFile(){
47 1 size_t nbValue(10lu);
48
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<long unsigned int>("long unsigned int", nbValue);
49
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<unsigned int>("unsigned int", nbValue);
50
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<unsigned short>("unsigned short", nbValue);
51
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<unsigned char>("unsigned char", nbValue);
52
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<long int>("long int", nbValue);
53
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<int>("int", nbValue);
54
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<short>("short", nbValue);
55
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<char>("char", nbValue);
56
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<int8_t>("int8_t", nbValue);
57
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<float>("float", nbValue);
58
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<double>("double", nbValue);
59
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testSetMapValue<bool>("bool", nbValue);
60 1 }
61
62
63 1 int main(int argc, char** argv){
64 1 testMapDataFile();
65 1 return 0;
66 }
67
68
69