PhoenixSerializer  3.0.0
PhoenixSerializer is a framework to save/load/serialize/deserialize data
Loading...
Searching...
No Matches
data_stream_check_value.h File Reference
#include <iostream>
#include <list>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include "data_stream_check_value_impl.h"
Include dependency graph for data_stream_check_value.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T, typename U>
bool checkValue (const std::string &testName, const std::list< std::pair< T, U > > &vecData, const std::list< std::pair< T, U > > &vecReferenceData)
 Check given value compare to the reference size.
template<typename T>
bool checkValue (const std::string &testName, const std::list< T > &vecData, const std::list< T > &vecReferenceData)
 Check given value compare to the reference size.
template<typename T, typename U>
bool checkValue (const std::string &testName, const std::map< T, U > &vecData, const std::map< T, U > &vecReferenceData)
 Check given value compare to the reference size.
template<typename T, typename U>
bool checkValue (const std::string &testName, const std::vector< std::pair< T, U > > &vecData, const std::vector< std::pair< T, U > > &vecReferenceData)
 Check given value compare to the reference size.
template<typename T>
bool checkValue (const std::string &testName, const std::vector< T > &vecData, const std::vector< T > &vecReferenceData)
 Check given value compare to the reference size.
template<typename T>
bool checkValue (const std::string &testName, const T &givenSize, const T &referenceSize)
 Check given value compare to the reference value.
template<typename T>
bool checkValue (const std::string &testName, const T *tabData, const T *tabReferenceData, size_t nbElement)
 Check given value compare to the reference value.

Function Documentation

◆ checkValue() [1/7]

template<typename T, typename U>
bool checkValue ( const std::string & testName,
const std::list< std::pair< T, U > > & vecData,
const std::list< std::pair< T, U > > & vecReferenceData )

Check given value compare to the reference size.

Parameters
testName: name of the current test
vecData: vector of data to be checked
vecReferenceData: vector of reference data
Returns
true on success, false otherwise

Definition at line 174 of file data_stream_check_value_impl.h.

174 {
175 if(vecData.size() != vecReferenceData.size()) {
176 std::cout << "checkValue : " << testName << " => vecData.size(" << vecData.size() << ") != vecReferenceData.size(" << vecReferenceData.size() << ")" << std::endl;
177 return false;
178 }
179 bool b(true);
180 typename std::list<std::pair<T, U>>::const_iterator itData = vecData.begin();
181 typename std::list<std::pair<T, U>>::const_iterator itRef = vecReferenceData.begin();
182 size_t i(0LU);
183 while(itData != vecData.end() && itRef != vecReferenceData.end()) {
184 b &= itData->first == itRef->first;
185 b &= itData->second == itRef->second;
186 if(!b) {
187 std::cout << "checkValue : " << testName << " => vecData[" << i << "](" << checkValue_printable(itData->first) << ", " << checkValue_printable(itData->second) << ") != vecReferenceData[" << i << "](" << checkValue_printable(itRef->first) << "," << checkValue_printable(itRef->second) << ")" << std::endl;
188 }
189 ++i;
190 ++itData;
191 ++itRef;
192 }
193 // if(b){std::cout << "checkValue : "<<testName<<" => Ok"<<std::endl;}
194 // else{std::cout << "checkValue : "<<testName<<" => WRONG!!!!"<<std::endl;}
195 return b;
196}
std::conditional_t< std::is_same_v< T, int8_t >||std::is_same_v< T, uint8_t >, int, T > checkValue_printable(const T &value)
Value to be printed by checkValue : int8_t and uint8_t are printed as numbers instead of characters.

References checkValue(), and checkValue_printable().

Here is the call graph for this function:

◆ checkValue() [2/7]

template<typename T>
bool checkValue ( const std::string & testName,
const std::list< T > & vecData,
const std::list< T > & vecReferenceData )

Check given value compare to the reference size.

Parameters
testName: name of the current test
vecData: vector of data to be checked
vecReferenceData: vector of reference data
Returns
true on success, false otherwise

Definition at line 88 of file data_stream_check_value_impl.h.

88 {
89 if(vecData.size() != vecReferenceData.size()) {
90 std::cout << "checkValue : " << testName << " => vecData.size(" << vecData.size() << ") != vecReferenceData.size(" << vecReferenceData.size() << ")" << std::endl;
91 return false;
92 }
93 bool b(true);
94 typename std::list<T>::const_iterator itData = vecData.begin();
95 typename std::list<T>::const_iterator itRef = vecReferenceData.begin();
96 size_t i(0LU);
97 while(itData != vecData.end() && itRef != vecReferenceData.end()) {
98 b &= *itData == *itRef;
99 if(!b) {
100 std::cout << "checkValue : " << testName << " => vecData[" << i << "](" << checkValue_printable(*itData) << ") != vecReferenceData[" << i << "](" << checkValue_printable(*itRef) << ")" << std::endl;
101 }
102 ++i;
103 ++itData;
104 ++itRef;
105 }
106 // if(b){std::cout << "checkValue : "<<testName<<" => Ok"<<std::endl;}
107 // else{std::cout << "checkValue : "<<testName<<" => WRONG!!!!"<<std::endl;}
108 return b;
109}

References checkValue(), and checkValue_printable().

Here is the call graph for this function:

◆ checkValue() [3/7]

template<typename T, typename U>
bool checkValue ( const std::string & testName,
const std::map< T, U > & vecData,
const std::map< T, U > & vecReferenceData )

Check given value compare to the reference size.

Parameters
testName: name of the current test
vecData: vector of data to be checked
vecReferenceData: vector of reference data
Returns
true on success, false otherwise

Definition at line 118 of file data_stream_check_value_impl.h.

118 {
119 if(vecData.size() != vecReferenceData.size()) {
120 std::cout << "checkValue : " << testName << " => vecData.size(" << vecData.size() << ") != vecReferenceData.size(" << vecReferenceData.size() << ")" << std::endl;
121 return false;
122 }
123 bool b(true);
124 typename std::map<T, U>::const_iterator itData = vecData.begin();
125 typename std::map<T, U>::const_iterator itRef = vecReferenceData.begin();
126 size_t i(0LU);
127 while(itData != vecData.end() && itRef != vecReferenceData.end()) {
128 b &= itData->first == itRef->first;
129 b &= itData->second == itRef->second;
130 if(!b) {
131 std::cout << "checkValue : " << testName << " => vecData[" << i << "](" << checkValue_printable(itData->first) << ", " << checkValue_printable(itData->second) << ") != vecReferenceData[" << i << "](" << checkValue_printable(itRef->first) << "," << checkValue_printable(itRef->second) << ")" << std::endl;
132 }
133 ++i;
134 ++itData;
135 ++itRef;
136 }
137 // if(b){std::cout << "checkValue : "<<testName<<" => Ok"<<std::endl;}
138 // else{std::cout << "checkValue : "<<testName<<" => WRONG!!!!"<<std::endl;}
139 return b;
140}

References checkValue(), and checkValue_printable().

Here is the call graph for this function:

◆ checkValue() [4/7]

template<typename T, typename U>
bool checkValue ( const std::string & testName,
const std::vector< std::pair< T, U > > & vecData,
const std::vector< std::pair< T, U > > & vecReferenceData )

Check given value compare to the reference size.

Parameters
testName: name of the current test
vecData: vector of data to be checked
vecReferenceData: vector of reference data
Returns
true on success, false otherwise

Definition at line 149 of file data_stream_check_value_impl.h.

149 {
150 if(vecData.size() != vecReferenceData.size()) {
151 std::cout << "checkValue : " << testName << " => vecData.size(" << vecData.size() << ") != vecReferenceData.size(" << vecReferenceData.size() << ")" << std::endl;
152 return false;
153 }
154 bool b(true);
155 for(size_t i(0LU); i < vecData.size() && b; ++i) {
156 b &= vecData[i].first == vecReferenceData[i].first;
157 b &= vecData[i].second == vecReferenceData[i].second;
158 if(!b) {
159 std::cout << "checkValue : " << testName << " => vecData[" << i << "](" << checkValue_printable(vecData[i].first) << ", " << checkValue_printable(vecData[i].second) << ") != vecReferenceData[" << i << "](" << checkValue_printable(vecReferenceData[i].first) << "," << checkValue_printable(vecReferenceData[i].second) << ")" << std::endl;
160 }
161 }
162 // if(b){std::cout << "checkValue : "<<testName<<" => Ok"<<std::endl;}
163 // else{std::cout << "checkValue : "<<testName<<" => WRONG!!!!"<<std::endl;}
164 return b;
165}

References checkValue(), and checkValue_printable().

Here is the call graph for this function:

◆ checkValue() [5/7]

template<typename T>
bool checkValue ( const std::string & testName,
const std::vector< T > & vecData,
const std::vector< T > & vecReferenceData )

Check given value compare to the reference size.

Parameters
testName: name of the current test
vecData: vector of data to be checked
vecReferenceData: vector of reference data
Returns
true on success, false otherwise

Definition at line 64 of file data_stream_check_value_impl.h.

64 {
65 if(vecData.size() != vecReferenceData.size()) {
66 std::cout << "checkValue : " << testName << " => vecData.size(" << vecData.size() << ") != vecReferenceData.size(" << vecReferenceData.size() << ")" << std::endl;
67 return false;
68 }
69 bool b(true);
70 for(size_t i(0LU); i < vecData.size() && b; ++i) {
71 b &= vecData[i] == vecReferenceData[i];
72 if(!b) {
73 std::cout << "checkValue : " << testName << " => vecData[" << i << "](" << checkValue_printable(vecData[i]) << ") != vecReferenceData[" << i << "](" << checkValue_printable(vecReferenceData[i]) << ")" << std::endl;
74 }
75 }
76 // if(b){std::cout << "checkValue : "<<testName<<" => Ok"<<std::endl;}
77 // else{std::cout << "checkValue : "<<testName<<" => WRONG!!!!"<<std::endl;}
78 return b;
79}

References checkValue(), and checkValue_printable().

Here is the call graph for this function:

◆ checkValue() [6/7]

template<typename T>
bool checkValue ( const std::string & testName,
const T & givenSize,
const T & referenceSize )

Check given value compare to the reference value.

Parameters
testName: name of the current test
givenSize: size to be tested
referenceSize: reference value
Returns
true on success, false otherwise

Definition at line 31 of file data_stream_check_value_impl.h.

31 {
32 // std::cout << "checkValue : "<<testName<<" => " << givenSize << ", reference ("<<referenceSize<<")" << std::endl;
33 if(givenSize != referenceSize) {
34 std::cerr << "checkValue : " << testName << " wrong size givenSize(" << givenSize << ") != referenceSize(" << referenceSize << ")" << std::endl;
35 }
36 return givenSize == referenceSize;
37}

References checkValue().

Referenced by checkValue(), checkValue(), checkValue(), checkValue(), checkValue(), checkValue(), and checkValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkValue() [7/7]

template<typename T>
bool checkValue ( const std::string & testName,
const T * tabData,
const T * tabReferenceData,
size_t nbElement )

Check given value compare to the reference value.

Parameters
testName: name of the current test
tabData: table of values to be tested
tabReferenceData: table of reference value
nbElement: number of elements to be checked
Returns
true on success, false otherwise

Definition at line 47 of file data_stream_check_value_impl.h.

47 {
48 bool b(true);
49 for(size_t i(0LU); i < nbElement && b; ++i) {
50 std::stringstream str;
51 str << i;
52 b &= checkValue(testName + " element " + str.str(), tabData[i], tabReferenceData[i]); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) the table is given as pointer + nbElement by the public API
53 }
54 return b;
55}
bool checkValue(const std::string &testName, const T &givenSize, const T &referenceSize)
Check given value compare to the reference value.

References checkValue().

Here is the call graph for this function: