PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
main.cpp File Reference
#include "data_stream_assert.h"
#include "data_stream_check_value.h"
#include "data_size.h"
#include "data_message.h"
#include "data_file.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 
void testListDataFile ()
 Test if data size is Ok. More...
 
void testListPairDataFile ()
 Test if data size is Ok. More...
 
void testMapDataFile ()
 Test if data size is Ok. More...
 
template<typename T >
bool testSetListPairValue (const std::string &firstTypeName, size_t nbValue)
 Abstract check of values stored in a file. More...
 
template<typename T >
bool testSetMapValue (const std::string &firstTypeName, size_t nbValue)
 Abstract check of values stored in a file. More...
 
template<typename T >
bool testSetVectorPairValue (const std::string &firstTypeName, size_t nbValue)
 Abstract check of values stored in a file. More...
 
void testSimpleDataFile ()
 Test if data size is Ok. More...
 
template<typename T , typename U >
bool testSimpleListPairValue (const std::string &testName, size_t nbValue)
 Abstract check of values stored in a file. More...
 
template<typename T >
bool testSimpleListValue (const std::string &testName, size_t nbValue)
 Abstract check of values stored in a file. More...
 
template<typename T , typename U >
bool testSimpleMapValue (const std::string &testName, size_t nbValue)
 Abstract check of values stored in a file. More...
 
template<typename T >
bool testSimpleValue (const std::string &testName, T referenceValue)
 Abstract check of a value stored in a file. More...
 
template<typename T , typename U >
bool testSimpleVectorPairValue (const std::string &testName, size_t nbValue)
 Abstract check of values stored in a file. More...
 
template<typename T >
bool testSimpleVectorValue (const std::string &testName, size_t nbValue)
 Abstract check of values stored in a file. More...
 
void testStringDataFile ()
 Test if data size is Ok. More...
 
void testVectorDataFile ()
 Test if data size is Ok. More...
 
void testVectorPairDataFile ()
 Test if data size is Ok. More...
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 324 of file main.cpp.

324  {
328  testMapDataFile();
332  return 0;
333 }

References testListDataFile(), testListPairDataFile(), testMapDataFile(), testSimpleDataFile(), testStringDataFile(), testVectorDataFile(), and testVectorPairDataFile().

+ Here is the call graph for this function:

◆ testListDataFile()

void testListDataFile ( )

Test if data size is Ok.

Definition at line 124 of file main.cpp.

124  {
125  size_t nbValue(10lu);
126  data_stream_assert(testSimpleListValue<long unsigned int>("std::list<long unsigned int>", nbValue));
127  data_stream_assert(testSimpleListValue<unsigned int>("std::list<unsigned int>", nbValue));
128  data_stream_assert(testSimpleListValue<unsigned short>("std::list<unsigned short>", nbValue));
129  data_stream_assert(testSimpleListValue<unsigned char>("std::list<unsigned char>", nbValue));
130  data_stream_assert(testSimpleListValue<long int>("std::list<long int>", nbValue));
131  data_stream_assert(testSimpleListValue<int>("std::list<int>", nbValue));
132  data_stream_assert(testSimpleListValue<short>("std::list<short>", nbValue));
133  data_stream_assert(testSimpleListValue<char>("std::list<char>", nbValue));
134  data_stream_assert(testSimpleListValue<float>("std::list<float>", nbValue));
135  data_stream_assert(testSimpleListValue<double>("std::list<double>", nbValue));
136  data_stream_assert(testSimpleListValue<bool>("std::list<bool>", nbValue));
137 }

References data_stream_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ testListPairDataFile()

void testListPairDataFile ( )

Test if data size is Ok.

Definition at line 303 of file main.cpp.

303  {
304  size_t nbValue(10lu);
305  data_stream_assert(testSetListPairValue<long unsigned int>("long unsigned int", nbValue));
306  data_stream_assert(testSetListPairValue<unsigned int>("unsigned int", nbValue));
307  data_stream_assert(testSetListPairValue<unsigned short>("unsigned short", nbValue));
308  data_stream_assert(testSetListPairValue<unsigned char>("unsigned char", nbValue));
309  data_stream_assert(testSetListPairValue<long int>("long int", nbValue));
310  data_stream_assert(testSetListPairValue<int>("int", nbValue));
311  data_stream_assert(testSetListPairValue<short>("short", nbValue));
312  data_stream_assert(testSetListPairValue<char>("char", nbValue));
313  data_stream_assert(testSetListPairValue<float>("float", nbValue));
314  data_stream_assert(testSetListPairValue<double>("double", nbValue));
315  data_stream_assert(testSetListPairValue<bool>("bool", nbValue));
316 }

References data_stream_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ testMapDataFile()

void testMapDataFile ( )

Test if data size is Ok.

Definition at line 185 of file main.cpp.

185  {
186  size_t nbValue(10lu);
187  data_stream_assert(testSetMapValue<long unsigned int>("long unsigned int", nbValue));
188  data_stream_assert(testSetMapValue<unsigned int>("unsigned int", nbValue));
189  data_stream_assert(testSetMapValue<unsigned short>("unsigned short", nbValue));
190  data_stream_assert(testSetMapValue<unsigned char>("unsigned char", nbValue));
191  data_stream_assert(testSetMapValue<long int>("long int", nbValue));
192  data_stream_assert(testSetMapValue<int>("int", nbValue));
193  data_stream_assert(testSetMapValue<short>("short", nbValue));
194  data_stream_assert(testSetMapValue<char>("char", nbValue));
195  data_stream_assert(testSetMapValue<float>("float", nbValue));
196  data_stream_assert(testSetMapValue<double>("double", nbValue));
197  data_stream_assert(testSetMapValue<bool>("bool", nbValue));
198 }

References data_stream_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ testSetListPairValue()

template<typename T >
bool testSetListPairValue ( const std::string &  firstTypeName,
size_t  nbValue 
)

Abstract check of values stored in a file.

Parameters
firstTypeName: name of the first type
nbValue: number of values to put in the reference list
Returns
true on success, false otherwise

Definition at line 285 of file main.cpp.

285  {
286  bool b(true);
287  b &= testSimpleListPairValue<T, long unsigned int>("std::list<std::pair<"+firstTypeName+", long unsigned int> >", nbValue);
288  b &= testSimpleListPairValue<T, unsigned int>("std::list<std::pair<"+firstTypeName+", unsigned int> >", nbValue);
289  b &= testSimpleListPairValue<T, unsigned short>("std::list<std::pair<"+firstTypeName+", unsigned short> >", nbValue);
290  b &= testSimpleListPairValue<T, unsigned char>("std::list<std::pair<"+firstTypeName+", unsigned char> >", nbValue);
291 
292  b &= testSimpleListPairValue<T, long int>("std::list<std::pair<"+firstTypeName+", long int> >", nbValue);
293  b &= testSimpleListPairValue<T, int>("std::list<std::pair<"+firstTypeName+", int> >", nbValue);
294  b &= testSimpleListPairValue<T, short>("std::list<std::pair<"+firstTypeName+", short> >", nbValue);
295  b &= testSimpleListPairValue<T, char>("std::list<std::pair<"+firstTypeName+", char> >", nbValue);
296  b &= testSimpleListPairValue<T, float>("std::list<std::pair<"+firstTypeName+", float> >", nbValue);
297  b &= testSimpleListPairValue<T, double>("std::list<std::pair<"+firstTypeName+", double> >", nbValue);
298  b &= testSimpleListPairValue<T, bool>("std::list<std::pair<"+firstTypeName+", bool> >", nbValue);
299  return b;
300 }

◆ testSetMapValue()

template<typename T >
bool testSetMapValue ( const std::string &  firstTypeName,
size_t  nbValue 
)

Abstract check of values stored in a file.

Parameters
firstTypeName: name of the first type
nbValue: number of values to put in the reference map
Returns
true on success, false otherwise

Definition at line 167 of file main.cpp.

167  {
168  bool b(true);
169  b &= testSimpleMapValue<T, long unsigned int>("std::map<"+firstTypeName+", long unsigned int>", nbValue);
170  b &= testSimpleMapValue<T, unsigned int>("std::map<"+firstTypeName+", unsigned int>", nbValue);
171  b &= testSimpleMapValue<T, unsigned short>("std::map<"+firstTypeName+", unsigned short>", nbValue);
172  b &= testSimpleMapValue<T, unsigned char>("std::map<"+firstTypeName+", unsigned char>", nbValue);
173 
174  b &= testSimpleMapValue<T, long int>("std::map<"+firstTypeName+", long int>", nbValue);
175  b &= testSimpleMapValue<T, int>("std::map<"+firstTypeName+", int>", nbValue);
176  b &= testSimpleMapValue<T, short>("std::map<"+firstTypeName+", short>", nbValue);
177  b &= testSimpleMapValue<T, char>("std::map<"+firstTypeName+", char>", nbValue);
178  b &= testSimpleMapValue<T, float>("std::map<"+firstTypeName+", float>", nbValue);
179  b &= testSimpleMapValue<T, double>("std::map<"+firstTypeName+", double>", nbValue);
180  b &= testSimpleMapValue<T, bool>("std::map<"+firstTypeName+", bool>", nbValue);
181  return b;
182 }

◆ testSetVectorPairValue()

template<typename T >
bool testSetVectorPairValue ( const std::string &  firstTypeName,
size_t  nbValue 
)

Abstract check of values stored in a file.

Parameters
firstTypeName: name of the first type
nbValue: number of values to put in the reference vector
Returns
true on success, false otherwise

Definition at line 226 of file main.cpp.

226  {
227  bool b(true);
228  b &= testSimpleVectorPairValue<T, long unsigned int>("std::vector<std::pair<"+firstTypeName+", long unsigned int> >", nbValue);
229  b &= testSimpleVectorPairValue<T, unsigned int>("std::vector<std::pair<"+firstTypeName+", unsigned int> >", nbValue);
230  b &= testSimpleVectorPairValue<T, unsigned short>("std::vector<std::pair<"+firstTypeName+", unsigned short> >", nbValue);
231  b &= testSimpleVectorPairValue<T, unsigned char>("std::vector<std::pair<"+firstTypeName+", unsigned char> >", nbValue);
232 
233  b &= testSimpleVectorPairValue<T, long int>("std::vector<std::pair<"+firstTypeName+", long int> >", nbValue);
234  b &= testSimpleVectorPairValue<T, int>("std::vector<std::pair<"+firstTypeName+", int> >", nbValue);
235  b &= testSimpleVectorPairValue<T, short>("std::vector<std::pair<"+firstTypeName+", short> >", nbValue);
236  b &= testSimpleVectorPairValue<T, char>("std::vector<std::pair<"+firstTypeName+", char> >", nbValue);
237  b &= testSimpleVectorPairValue<T, float>("std::vector<std::pair<"+firstTypeName+", float> >", nbValue);
238  b &= testSimpleVectorPairValue<T, double>("std::vector<std::pair<"+firstTypeName+", double> >", nbValue);
239  b &= testSimpleVectorPairValue<T, bool>("std::vector<std::pair<"+firstTypeName+", bool> >", nbValue);
240  return b;
241 }

◆ testSimpleDataFile()

void testSimpleDataFile ( )

Test if data size is Ok.

Definition at line 33 of file main.cpp.

33  {
34  long unsigned int dataUInt64(42lu);
35  data_stream_assert(testSimpleValue("long unsigned int", dataUInt64));
36 
37  unsigned int dataUInt32(42lu);
38  data_stream_assert(testSimpleValue("unsigned int", dataUInt32));
39 
40  unsigned short dataUInt16(42lu);
41  data_stream_assert(testSimpleValue("unsigned short", dataUInt16));
42 
43  unsigned char dataUInt8(42lu);
44  data_stream_assert(testSimpleValue("unsigned char", dataUInt8));
45 
46  long int dataInt64(42lu);
47  data_stream_assert(testSimpleValue("long int", dataInt64));
48 
49  int dataInt32(42lu);
50  data_stream_assert(testSimpleValue("int", dataInt32));
51 
52  short dataInt16(42lu);
53  data_stream_assert(testSimpleValue("short", dataInt16));
54 
55  char dataInt8(42lu);
56  data_stream_assert(testSimpleValue("char", dataInt8));
57 
58  float dataFloat(42.0f);
59  data_stream_assert(testSimpleValue("float", dataFloat));
60 
61  float dataDouble(42.0);
62  data_stream_assert(testSimpleValue("double", dataDouble));
63 
64  bool dataBool(true);
65  data_stream_assert(testSimpleValue("bool", dataBool));
66 }

References data_stream_assert, and testSimpleValue().

Referenced by main().

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

◆ testSimpleListPairValue()

template<typename T , typename U >
bool testSimpleListPairValue ( const std::string &  testName,
size_t  nbValue 
)

Abstract check of values stored in a file.

Parameters
testName: name of the test
nbValue: number of values to put in the reference list
Returns
true on success, false otherwise

Definition at line 265 of file main.cpp.

265  {
266  std::string fileName("value_test.data");
267 
268  std::list<std::pair<T, U> > vecRef;
269  for(size_t i(0lu); i < nbValue; ++i){vecRef.push_back(std::pair<T, U>(i,2lu*i));}
270  bool b(true);
271  b &= data_save(fileName, vecRef);
272 
273  std::list<std::pair<T, U> > vecValue;
274  b &= data_load(fileName, vecValue);
275  b &= checkValue(testName, vecValue, vecRef);
276  return b;
277 }

References checkValue(), data_load(), and data_save().

+ Here is the call graph for this function:

◆ testSimpleListValue()

template<typename T >
bool testSimpleListValue ( const std::string &  testName,
size_t  nbValue 
)

Abstract check of values stored in a file.

Parameters
testName: name of the test
nbValue: number of values to put in the reference list
Returns
true on success, false otherwise

Definition at line 109 of file main.cpp.

109  {
110  std::string fileName("value_test.data");
111 
112  std::list<T> vecRef;
113  for(size_t i(0lu); i < nbValue; ++i){vecRef.push_back(i);}
114  bool b(true);
115  b &= data_save(fileName, vecRef);
116 
117  std::list<T> vecValue;
118  b &= data_load(fileName, vecValue);
119  b &= checkValue(testName, vecValue, vecRef);
120  return b;
121 }

References checkValue(), data_load(), and data_save().

+ Here is the call graph for this function:

◆ testSimpleMapValue()

template<typename T , typename U >
bool testSimpleMapValue ( const std::string &  testName,
size_t  nbValue 
)

Abstract check of values stored in a file.

Parameters
testName: name of the test
nbValue: number of values to put in the reference map
Returns
true on success, false otherwise

Definition at line 145 of file main.cpp.

145  {
146  std::string fileName("value_test.data");
147 
148  std::map<T, U> vecRef;
149  for(size_t i(0lu); i < nbValue; ++i){vecRef[i] = (U)(2lu*i > nbValue/2lu);}
150  bool b(true);
151  b &= data_save(fileName, vecRef);
152  b &= !data_save("unexistingDir/unexistingFileName.data", vecRef);
153 
154  std::map<T, U> vecValue;
155  b &= data_load(fileName, vecValue);
156  b &= checkValue(testName, vecValue, vecRef);
157  b &= !data_load("UnexistingFilename.data", vecValue);
158  return b;
159 }

References checkValue(), data_load(), and data_save().

+ Here is the call graph for this function:

◆ testSimpleValue()

template<typename T >
bool testSimpleValue ( const std::string &  testName,
referenceValue 
)

Abstract check of a value stored in a file.

Parameters
testName: name of the test
referenceValue: reference value
Returns
true on success, false otherwise

Definition at line 20 of file main.cpp.

20  {
21  std::string fileName("value_test.data"), unexistingFileName("someUnexisting/file/in/unexistingDir/file.data");
22  bool b(true);
23  b &= data_save(fileName, referenceValue);
24  T value;
25  b &= data_load(fileName, value);
26  b &= checkValue(testName, value, referenceValue);
27  b &= !data_save(unexistingFileName, referenceValue);
28  b &= !data_load(unexistingFileName, value);
29  return b;
30 }

References checkValue(), data_load(), and data_save().

Referenced by testSimpleDataFile(), and testStringDataFile().

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

◆ testSimpleVectorPairValue()

template<typename T , typename U >
bool testSimpleVectorPairValue ( const std::string &  testName,
size_t  nbValue 
)

Abstract check of values stored in a file.

Parameters
testName: name of the test
nbValue: number of values to put in the reference vector
Returns
true on success, false otherwise

Definition at line 206 of file main.cpp.

206  {
207  std::string fileName("value_test.data");
208 
209  std::vector<std::pair<T, U> > vecRef;
210  for(size_t i(0lu); i < nbValue; ++i){vecRef.push_back(std::pair<T, U>(i,2lu*i));}
211  bool b(true);
212  b &= data_save(fileName, vecRef);
213 
214  std::vector<std::pair<T, U> > vecValue;
215  b &= data_load(fileName, vecValue);
216  b &= checkValue(testName, vecValue, vecRef);
217  return b;
218 }

References checkValue(), data_load(), and data_save().

+ Here is the call graph for this function:

◆ testSimpleVectorValue()

template<typename T >
bool testSimpleVectorValue ( const std::string &  testName,
size_t  nbValue 
)

Abstract check of values stored in a file.

Parameters
testName: name of the test
nbValue: number of values to put in the reference vector
Returns
true on success, false otherwise

Definition at line 74 of file main.cpp.

74  {
75  std::string fileName("value_test.data");
76 
77  std::vector<T> vecRef;
78  for(size_t i(0lu); i < nbValue; ++i){vecRef.push_back(i);}
79  bool b(true);
80  b &= data_save(fileName, vecRef);
81 
82  std::vector<T> vecValue;
83  b &= data_load(fileName, vecValue);
84  b &= checkValue(testName, vecValue, vecRef);
85  return b;
86 }

References checkValue(), data_load(), and data_save().

+ Here is the call graph for this function:

◆ testStringDataFile()

void testStringDataFile ( )

Test if data size is Ok.

Definition at line 319 of file main.cpp.

319  {
320  std::string str("One thing to say");
321  data_stream_assert(testSimpleValue("std::string", str));
322 }

References data_stream_assert, createReleaseCurl::str, and testSimpleValue().

Referenced by main().

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

◆ testVectorDataFile()

void testVectorDataFile ( )

Test if data size is Ok.

Definition at line 89 of file main.cpp.

89  {
90  size_t nbValue(10lu);
91  data_stream_assert(testSimpleVectorValue<long unsigned int>("std::vector<long unsigned int>", nbValue));
92  data_stream_assert(testSimpleVectorValue<unsigned int>("std::vector<unsigned int>", nbValue));
93  data_stream_assert(testSimpleVectorValue<unsigned short>("std::vector<unsigned short>", nbValue));
94  data_stream_assert(testSimpleVectorValue<unsigned char>("std::vector<unsigned char>", nbValue));
95  data_stream_assert(testSimpleVectorValue<long int>("std::vector<long int>", nbValue));
96  data_stream_assert(testSimpleVectorValue<int>("std::vector<int>", nbValue));
97  data_stream_assert(testSimpleVectorValue<short>("std::vector<short>", nbValue));
98  data_stream_assert(testSimpleVectorValue<char>("std::vector<char>", nbValue));
99  data_stream_assert(testSimpleVectorValue<float>("std::vector<float>", nbValue));
100  data_stream_assert(testSimpleVectorValue<double>("std::vector<double>", nbValue));
101 }

References data_stream_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ testVectorPairDataFile()

void testVectorPairDataFile ( )

Test if data size is Ok.

Definition at line 244 of file main.cpp.

244  {
245  size_t nbValue(10lu);
246  data_stream_assert(testSetVectorPairValue<long unsigned int>("long unsigned int", nbValue));
247  data_stream_assert(testSetVectorPairValue<unsigned int>("unsigned int", nbValue));
248  data_stream_assert(testSetVectorPairValue<unsigned short>("unsigned short", nbValue));
249  data_stream_assert(testSetVectorPairValue<unsigned char>("unsigned char", nbValue));
250  data_stream_assert(testSetVectorPairValue<long int>("long int", nbValue));
251  data_stream_assert(testSetVectorPairValue<int>("int", nbValue));
252  data_stream_assert(testSetVectorPairValue<short>("short", nbValue));
253  data_stream_assert(testSetVectorPairValue<char>("char", nbValue));
254  data_stream_assert(testSetVectorPairValue<float>("float", nbValue));
255  data_stream_assert(testSetVectorPairValue<double>("double", nbValue));
256  data_stream_assert(testSetVectorPairValue<bool>("bool", nbValue));
257 }

References data_stream_assert.

Referenced by main().

+ Here is the caller graph for this function:
data_stream_assert
#define data_stream_assert(isOk)
Definition: data_stream_assert.h:17
testSimpleDataFile
void testSimpleDataFile()
Test if data size is Ok.
Definition: main.cpp:33
testListPairDataFile
void testListPairDataFile()
Test if data size is Ok.
Definition: main.cpp:303
checkValue
bool checkValue(const std::string &testName, size_t givenSize, size_t referenceSize)
Check given value compare to the reference size.
Definition: main.cpp:16
testVectorPairDataFile
void testVectorPairDataFile()
Test if data size is Ok.
Definition: main.cpp:244
testSimpleValue
bool testSimpleValue(const std::string &testName, T referenceValue)
Abstract check of a value stored in a file.
Definition: main.cpp:20
data_save
bool data_save(FILE *iter, const T &data)
Save data in a message.
Definition: data_file.h:18
testVectorDataFile
void testVectorDataFile()
Test if data size is Ok.
Definition: main.cpp:89
testStringDataFile
void testStringDataFile()
Test if data size is Ok.
Definition: main.cpp:319
data_load
bool data_load(FILE *iter, T &data)
Load data from a message.
Definition: data_file.h:39
createReleaseCurl.str
str
Definition: createReleaseCurl.py:128
testListDataFile
void testListDataFile()
Test if data size is Ok.
Definition: main.cpp:124
testMapDataFile
void testMapDataFile()
Test if data size is Ok.
Definition: main.cpp:185