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 |
#ifndef __DATA_STREAM_CHECK_VALUE_IMPL_H__ |
||
8 |
#define __DATA_STREAM_CHECK_VALUE_IMPL_H__ |
||
9 |
|||
10 |
#include "data_stream_check_value.h" |
||
11 |
|||
12 |
///Check given value compare to the reference value |
||
13 |
/** @param testName : name of the current test |
||
14 |
* @param givenSize : size to be tested |
||
15 |
* @param referenceSize : reference value |
||
16 |
* @return true on success, false otherwise |
||
17 |
*/ |
||
18 |
template<typename T> |
||
19 |
217824 |
bool checkValue(const std::string & testName, const T & givenSize, const T & referenceSize){ |
|
20 |
217824 |
std::cout << "checkValue : "<<testName<<" => " << givenSize << ", reference ("<<referenceSize<<")" << std::endl; |
|
21 |
✓✓✓ | 217824 |
if(givenSize != referenceSize){ |
22 |
1 |
std::cerr << "checkValue : "<<testName<<" wrong size givenSize("<<givenSize<<") != referenceSize("<<referenceSize<<")" << std::endl; |
|
23 |
} |
||
24 |
217824 |
return givenSize == referenceSize; |
|
25 |
} |
||
26 |
|||
27 |
///Check given value compare to the reference value |
||
28 |
/** @param testName : name of the current test |
||
29 |
* @param tabData : table of values to be tested |
||
30 |
* @param tabReferenceData : table of reference value |
||
31 |
* @param nbElement : number of elements to be checked |
||
32 |
* @return true on success, false otherwise |
||
33 |
*/ |
||
34 |
template<typename T> |
||
35 |
2158 |
bool checkValue(const std::string & testName, const T * tabData, const T * tabReferenceData, size_t nbElement){ |
|
36 |
2158 |
bool b(true); |
|
37 |
✓✓✓✓ |
111041 |
for(size_t i(0lu); i < nbElement && b; ++i){ |
38 |
✓ | 108883 |
std::stringstream str; |
39 |
✓ | 108883 |
str << i; |
40 |
✓✓✓✓ |
108883 |
b &= checkValue(testName + " element "+str.str(), tabData[i], tabReferenceData[i]); |
41 |
} |
||
42 |
2158 |
return b; |
|
43 |
} |
||
44 |
|||
45 |
///Check given value compare to the reference size |
||
46 |
/** @param testName : name of the current test |
||
47 |
* @param vecData : vector of data to be checked |
||
48 |
* @param vecReferenceData : vector of reference data |
||
49 |
* @return true on success, false otherwise |
||
50 |
*/ |
||
51 |
template<typename T> |
||
52 |
39 |
bool checkValue(const std::string & testName, const std::vector<T> & vecData, const std::vector<T> & vecReferenceData){ |
|
53 |
✓✓ | 39 |
if(vecData.size() != vecReferenceData.size()){ |
54 |
1 |
std::cout << "checkValue : "<<testName<<" => vecData.size(" << vecData.size() << ") != vecReferenceData.size("<<vecReferenceData.size()<<")" << std::endl; |
|
55 |
1 |
return false; |
|
56 |
} |
||
57 |
38 |
bool b(true); |
|
58 |
✓✓✓✗ ✓✓ |
402 |
for(size_t i(0lu); i < vecData.size() && b; ++i){ |
59 |
364 |
b &= vecData[i] == vecReferenceData[i]; |
|
60 |
✓✓ | 364 |
if(!b){ |
61 |
1 |
std::cout << "checkValue : "<<testName<<" => vecData["<<i<<"](" << vecData[i] << ") != vecReferenceData["<<i<<"]("<<vecReferenceData[i]<<")" << std::endl; |
|
62 |
} |
||
63 |
} |
||
64 |
✓✓ | 38 |
if(b){std::cout << "checkValue : "<<testName<<" => Ok"<<std::endl;} |
65 |
1 |
else{std::cout << "checkValue : "<<testName<<" => WRONG!!!!"<<std::endl;} |
|
66 |
38 |
return b; |
|
67 |
} |
||
68 |
|||
69 |
///Check given value compare to the reference size |
||
70 |
/** @param testName : name of the current test |
||
71 |
* @param vecData : vector of data to be checked |
||
72 |
* @param vecReferenceData : vector of reference data |
||
73 |
* @return true on success, false otherwise |
||
74 |
*/ |
||
75 |
template<typename T> |
||
76 |
41 |
bool checkValue(const std::string & testName, const std::list<T> & vecData, const std::list<T> & vecReferenceData){ |
|
77 |
✓✓ | 41 |
if(vecData.size() != vecReferenceData.size()){ |
78 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
1 |
std::cout << "checkValue : "<<testName<<" => vecData.size(" << vecData.size() << ") != vecReferenceData.size("<<vecReferenceData.size()<<")" << std::endl; |
79 |
1 |
return false; |
|
80 |
} |
||
81 |
40 |
bool b(true); |
|
82 |
40 |
typename std::list<T>::const_iterator itData = vecData.begin(); |
|
83 |
40 |
typename std::list<T>::const_iterator itRef = vecReferenceData.begin(); |
|
84 |
40 |
size_t i(0lu); |
|
85 |
✓✓✓✗ ✓✓ |
424 |
while(itData != vecData.end() && itRef != vecReferenceData.end()){ |
86 |
384 |
b &= *itData == *itRef; |
|
87 |
✓✓ | 384 |
if(!b){ |
88 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
1 |
std::cout << "checkValue : "<<testName<<" => vecData["<<i<<"](" << (*itData) << ") != vecReferenceData["<<i<<"]("<<(*itRef)<<")" << std::endl; |
89 |
} |
||
90 |
384 |
++i; |
|
91 |
384 |
++itData; |
|
92 |
384 |
++itRef; |
|
93 |
} |
||
94 |
✓✓✓✓ ✓✓ |
40 |
if(b){std::cout << "checkValue : "<<testName<<" => Ok"<<std::endl;} |
95 |
✓✗✓✗ ✓✗✓✗ |
1 |
else{std::cout << "checkValue : "<<testName<<" => WRONG!!!!"<<std::endl;} |
96 |
40 |
return b; |
|
97 |
} |
||
98 |
|||
99 |
///Check given value compare to the reference size |
||
100 |
/** @param testName : name of the current test |
||
101 |
* @param vecData : vector of data to be checked |
||
102 |
* @param vecReferenceData : vector of reference data |
||
103 |
* @return true on success, false otherwise |
||
104 |
*/ |
||
105 |
template<typename T, typename U> |
||
106 |
261 |
bool checkValue(const std::string & testName, const std::map<T, U> & vecData, const std::map<T, U> & vecReferenceData){ |
|
107 |
✓✓ | 261 |
if(vecData.size() != vecReferenceData.size()){ |
108 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
1 |
std::cout << "checkValue : "<<testName<<" => vecData.size(" << vecData.size() << ") != vecReferenceData.size("<<vecReferenceData.size()<<")" << std::endl; |
109 |
1 |
return false; |
|
110 |
} |
||
111 |
260 |
bool b(true); |
|
112 |
260 |
typename std::map<T,U>::const_iterator itData = vecData.begin(); |
|
113 |
260 |
typename std::map<T, U>::const_iterator itRef = vecReferenceData.begin(); |
|
114 |
260 |
size_t i(0lu); |
|
115 |
✓✓✓✗ ✓✓ |
2668 |
while(itData != vecData.end() && itRef != vecReferenceData.end()){ |
116 |
2408 |
b &= itData->first == itRef->first; |
|
117 |
2408 |
b &= itData->second == itRef->second; |
|
118 |
✓✓ | 2408 |
if(!b){ |
119 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
2 |
std::cout << "checkValue : "<<testName<<" => vecData["<<i<<"](" << itData->first << ", " << itData->second << ") != vecReferenceData["<<i<<"]("<<itRef->first << "," << itRef->second<<")" << std::endl; |
120 |
} |
||
121 |
2408 |
++i; |
|
122 |
2408 |
++itData; |
|
123 |
2408 |
++itRef; |
|
124 |
} |
||
125 |
✓✓✓✓ ✓✓ |
260 |
if(b){std::cout << "checkValue : "<<testName<<" => Ok"<<std::endl;} |
126 |
✓✗✓✗ ✓✗✓✗ |
1 |
else{std::cout << "checkValue : "<<testName<<" => WRONG!!!!"<<std::endl;} |
127 |
260 |
return b; |
|
128 |
} |
||
129 |
|||
130 |
///Check given value compare to the reference size |
||
131 |
/** @param testName : name of the current test |
||
132 |
* @param vecData : vector of data to be checked |
||
133 |
* @param vecReferenceData : vector of reference data |
||
134 |
* @return true on success, false otherwise |
||
135 |
*/ |
||
136 |
template<typename T, typename U> |
||
137 |
253 |
bool checkValue(const std::string & testName, const std::vector<std::pair<T, U> > & vecData, const std::vector<std::pair<T, U> > & vecReferenceData){ |
|
138 |
✓✓ | 253 |
if(vecData.size() != vecReferenceData.size()){ |
139 |
1 |
std::cout << "checkValue : "<<testName<<" => vecData.size(" << vecData.size() << ") != vecReferenceData.size("<<vecReferenceData.size()<<")" << std::endl; |
|
140 |
1 |
return false; |
|
141 |
} |
||
142 |
252 |
bool b(true); |
|
143 |
✓✓✓✗ ✓✓ |
2756 |
for(size_t i(0lu); i < vecData.size() && b; ++i){ |
144 |
2504 |
b &= vecData[i].first == vecReferenceData[i].first; |
|
145 |
2504 |
b &= vecData[i].second == vecReferenceData[i].second; |
|
146 |
✓✓ | 2504 |
if(!b){ |
147 |
1 |
std::cout << "checkValue : "<<testName<<" => vecData["<<i<<"](" << vecData[i].first << ", " << vecData[i].second << ") != vecReferenceData["<<i<<"]("<<vecReferenceData[i].first << ","<<vecReferenceData[i].second <<")" << std::endl; |
|
148 |
} |
||
149 |
} |
||
150 |
✓✓ | 252 |
if(b){std::cout << "checkValue : "<<testName<<" => Ok"<<std::endl;} |
151 |
1 |
else{std::cout << "checkValue : "<<testName<<" => WRONG!!!!"<<std::endl;} |
|
152 |
252 |
return b; |
|
153 |
} |
||
154 |
|||
155 |
///Check given value compare to the reference size |
||
156 |
/** @param testName : name of the current test |
||
157 |
* @param vecData : vector of data to be checked |
||
158 |
* @param vecReferenceData : vector of reference data |
||
159 |
* @return true on success, false otherwise |
||
160 |
*/ |
||
161 |
template<typename T, typename U> |
||
162 |
124 |
bool checkValue(const std::string & testName, const std::list<std::pair<T, U> > & vecData, const std::list<std::pair<T, U> > & vecReferenceData){ |
|
163 |
✓✓ | 124 |
if(vecData.size() != vecReferenceData.size()){ |
164 |
✓✓✓✓ ✓✓✓✓ |
1 |
std::cout << "checkValue : "<<testName<<" => vecData.size(" << vecData.size() << ") != vecReferenceData.size("<<vecReferenceData.size()<<")" << std::endl; |
165 |
1 |
return false; |
|
166 |
} |
||
167 |
123 |
bool b(true); |
|
168 |
123 |
typename std::list<std::pair<T,U> >::const_iterator itData = vecData.begin(); |
|
169 |
123 |
typename std::list<std::pair<T,U> >::const_iterator itRef = vecReferenceData.begin(); |
|
170 |
123 |
size_t i(0lu); |
|
171 |
✓✓✓✗ ✓✓ |
1337 |
while(itData != vecData.end() && itRef != vecReferenceData.end()){ |
172 |
1214 |
b &= itData->first == itRef->first; |
|
173 |
1214 |
b &= itData->second == itRef->second; |
|
174 |
✓✓ | 1214 |
if(!b){ |
175 |
✓✓✓✓ ✓✓✓✓ ✓✓✓✓ ✓✓✓✓ |
1 |
std::cout << "checkValue : "<<testName<<" => vecData["<<i<<"](" << itData->first << ", " << itData->second << ") != vecReferenceData["<<i<<"]("<<itRef->first << ","<<itRef->second <<")" << std::endl; |
176 |
} |
||
177 |
1214 |
++i; |
|
178 |
1214 |
++itData; |
|
179 |
1214 |
++itRef; |
|
180 |
} |
||
181 |
✓✓✓✓ ✓✓ |
123 |
if(b){std::cout << "checkValue : "<<testName<<" => Ok"<<std::endl;} |
182 |
✓✓✓✓ |
1 |
else{std::cout << "checkValue : "<<testName<<" => WRONG!!!!"<<std::endl;} |
183 |
123 |
return b; |
|
184 |
} |
||
185 |
|||
186 |
#endif |
||
187 |
Generated by: GCOVR (Version 4.2) |