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

Go to the source code of this file.

Functions

bool checkValue (const std::string &testName, size_t givenSize, size_t referenceSize)
 Check given value compare to the reference size. More...
 
int main (int argc, char **argv)
 
void testListDataSize ()
 Test if data size is Ok. More...
 
void testListPairDataSize ()
 Test if data size is Ok. More...
 
void testMapDataSize ()
 Test if data size is Ok. More...
 
void testSimpleDataSize ()
 Test if data size is Ok. More...
 
void testStringDataSize ()
 Test if data size is Ok. More...
 
void testVectorDataSize ()
 Test if data size is Ok. More...
 
void testVectorPairDataSize ()
 Test if data size is Ok. More...
 

Function Documentation

◆ checkValue()

bool checkValue ( const std::string &  testName,
size_t  givenSize,
size_t  referenceSize 
)

Check given value compare to the reference size.

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

Definition at line 16 of file main.cpp.

16  {
17 // std::cout << "checkValue : "<<testName<<" => " << givenSize << ", reference ("<<referenceSize<<")" << std::endl;
18  if(givenSize != referenceSize){std::cerr << "checkValue : "<<testName<<" wrong size givenSize("<<givenSize<<") != referenceSize("<<referenceSize<<")" << std::endl;}
19  return givenSize == referenceSize;
20 }

Referenced by testCheckValue(), testListDataMessage(), testListDataSize(), testListPairDataMessage(), testListPairDataSize(), testMapDataMessage(), testMapDataSize(), testSimpleDataMessage(), testSimpleDataSize(), testSimpleListPairValue(), testSimpleListValue(), testSimpleMapValue(), testSimpleTableFile(), testSimpleTableMessage(), testSimpleValue(), testSimpleVectorPairValue(), testSimpleVectorValue(), testStringDataSize(), testVectorDataMessage(), testVectorDataSize(), testVectorPairDataMessage(), and testVectorPairDataSize().

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 273 of file main.cpp.

273  {
277  testMapDataSize();
281  return 0;
282 }

References testListDataSize(), testListPairDataSize(), testMapDataSize(), testSimpleDataSize(), testStringDataSize(), testVectorDataSize(), and testVectorPairDataSize().

+ Here is the call graph for this function:

◆ testListDataSize()

void testListDataSize ( )

Test if data size is Ok.

Definition at line 104 of file main.cpp.

104  {
105  size_t nbValue(10lu);
106 
107  std::list<long unsigned int> vecUInt64;
108  for(size_t i(0lu); i < nbValue; ++i){vecUInt64.push_back(i);}
109  size_t sizeVecUint64 = data_size(vecUInt64);
110  data_stream_assert(checkValue("std::list<long unsigned int>", sizeVecUint64, 8lu*nbValue + 8lu));
111 
112  std::list<unsigned int> vecUInt32;
113  for(size_t i(0lu); i < nbValue; ++i){vecUInt32.push_back(i);}
114  size_t sizeVecUint32 = data_size(vecUInt32);
115  data_stream_assert(checkValue("std::list<unsigned int>", sizeVecUint32, 4lu*nbValue + 8lu));
116 
117  std::list<unsigned short> vecUInt16;
118  for(size_t i(0lu); i < nbValue; ++i){vecUInt16.push_back(i);}
119  size_t sizeVecUint16 = data_size(vecUInt16);
120  data_stream_assert(checkValue("std::list<unsigned short>", sizeVecUint16, 2lu*nbValue + 8lu));
121 
122  std::list<unsigned char> vecUInt8;
123  for(size_t i(0lu); i < nbValue; ++i){vecUInt8.push_back(i);}
124  size_t sizeVecUint8 = data_size(vecUInt8);
125  data_stream_assert(checkValue("std::list<unsigned char>", sizeVecUint8, 1lu*nbValue + 8lu));
126 
127 
128  std::list<long int> vecInt64;
129  for(size_t i(0lu); i < nbValue; ++i){vecInt64.push_back(i);}
130  size_t sizeVecInt64 = data_size(vecInt64);
131  data_stream_assert(checkValue("std::list<long int>", sizeVecInt64, 8lu*nbValue + 8lu));
132 
133  std::list<int> vecInt32;
134  for(size_t i(0lu); i < nbValue; ++i){vecInt32.push_back(i);}
135  size_t sizeVecInt32 = data_size(vecInt32);
136  data_stream_assert(checkValue("std::list<int>", sizeVecInt32, 4lu*nbValue + 8lu));
137 
138  std::list<short> vecInt16;
139  for(size_t i(0lu); i < nbValue; ++i){vecInt16.push_back(i);}
140  size_t sizeVecInt16 = data_size(vecInt16);
141  data_stream_assert(checkValue("std::list<short>", sizeVecInt16, 2lu*nbValue + 8lu));
142 
143  std::list<char> vecInt8;
144  for(size_t i(0lu); i < nbValue; ++i){vecInt8.push_back(i);}
145  size_t sizeVecInt8 = data_size(vecInt8);
146  data_stream_assert(checkValue("std::list<char>", sizeVecInt8, 1lu*nbValue + 8lu));
147 }

References checkValue(), data_size(), and data_stream_assert.

Referenced by main().

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

◆ testListPairDataSize()

void testListPairDataSize ( )

Test if data size is Ok.

Definition at line 221 of file main.cpp.

221  {
222  size_t nbValue(10lu);
223 
224  std::list<std::pair<long unsigned int, long unsigned int> > vecUInt64;
225  for(size_t i(0lu); i < nbValue; ++i){vecUInt64.push_back(std::pair<long unsigned int, long unsigned int>(i,i));}
226  size_t sizeVecUint64 = data_size(vecUInt64);
227  data_stream_assert(checkValue("std::list<std::pair<long unsigned int, long unsigned int> >", sizeVecUint64, 2lu*8lu*nbValue + 8lu));
228 
229  std::list<std::pair<unsigned int, unsigned int> > vecUInt32;
230  for(size_t i(0lu); i < nbValue; ++i){vecUInt32.push_back(std::pair<unsigned int, unsigned int>(i,i));}
231  size_t sizeVecUint32 = data_size(vecUInt32);
232  data_stream_assert(checkValue("std::list<std::pair<unsigned int, unsigned int> >", sizeVecUint32, 2lu*4lu*nbValue + 8lu));
233 
234  std::list<std::pair<unsigned short, unsigned short> > vecUInt16;
235  for(size_t i(0lu); i < nbValue; ++i){vecUInt16.push_back(std::pair<unsigned short, unsigned short>(i,i));}
236  size_t sizeVecUint16 = data_size(vecUInt16);
237  data_stream_assert(checkValue("std::list<std::pair<unsigned short, unsigned short> >", sizeVecUint16, 2lu*2lu*nbValue + 8lu));
238 
239  std::list<std::pair<unsigned char, unsigned char> > vecUInt8;
240  for(size_t i(0lu); i < nbValue; ++i){vecUInt8.push_back(std::pair<unsigned char, unsigned char>(i,i));}
241  size_t sizeVecUint8 = data_size(vecUInt8);
242  data_stream_assert(checkValue("std::list<std::pair<unsigned char, unsigned char> >", sizeVecUint8, 2lu*1lu*nbValue + 8lu));
243 
244 
245  std::list<std::pair<long int, long int> > vecInt64;
246  for(size_t i(0lu); i < nbValue; ++i){vecInt64.push_back(std::pair<long int, long int>(i,i));}
247  size_t sizeVecInt64 = data_size(vecInt64);
248  data_stream_assert(checkValue("std::list<std::pair<long int, long int> >", sizeVecInt64, 2lu*8lu*nbValue + 8lu));
249 
250  std::list<std::pair<int,int> > vecInt32;
251  for(size_t i(0lu); i < nbValue; ++i){vecInt32.push_back(std::pair<int,int>(i,i));}
252  size_t sizeVecInt32 = data_size(vecInt32);
253  data_stream_assert(checkValue("std::list<std::pair<int,int> >", sizeVecInt32, 2lu*4lu*nbValue + 8lu));
254 
255  std::list<std::pair<short, short> > vecInt16;
256  for(size_t i(0lu); i < nbValue; ++i){vecInt16.push_back(std::pair<short, short>(i,i));}
257  size_t sizeVecInt16 = data_size(vecInt16);
258  data_stream_assert(checkValue("std::list<std::pair<short, short> >", sizeVecInt16, 2lu*2lu*nbValue + 8lu));
259 
260  std::list<std::pair<char, char> > vecInt8;
261  for(size_t i(0lu); i < nbValue; ++i){vecInt8.push_back(std::pair<char, char>(i,i));}
262  size_t sizeVecInt8 = data_size(vecInt8);
263  data_stream_assert(checkValue("std::list<std::pair<char, char> >", sizeVecInt8, 2lu*1lu*nbValue + 8lu));
264 }

References checkValue(), data_size(), and data_stream_assert.

Referenced by main().

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

◆ testMapDataSize()

void testMapDataSize ( )

Test if data size is Ok.

Definition at line 150 of file main.cpp.

150  {
151  size_t nbValue(10lu);
152 
153  std::map<long unsigned int, long unsigned int> mapUInt64UInt64;
154  for(size_t i(0lu); i < nbValue; ++i){mapUInt64UInt64[i] = i;}
155  size_t sizeMapUint64Uint64 = data_size(mapUInt64UInt64);
156  data_stream_assert(checkValue("std::map<long unsigned int, long unsigned int>", sizeMapUint64Uint64, 8lu*nbValue + 8lu*nbValue + 8lu));
157 
158  std::map<unsigned short, unsigned int> mapUInt16UInt32;
159  for(size_t i(0lu); i < nbValue; ++i){mapUInt16UInt32[i] = i;}
160  size_t sizeMapUint16Uint32 = data_size(mapUInt16UInt32);
161  data_stream_assert(checkValue("std::map<unsigned short, unsigned int>", sizeMapUint16Uint32, 2lu*nbValue + 4lu*nbValue + 8lu));
162 
163  std::map<long int, long int> mapInt64Int64;
164  for(size_t i(0lu); i < nbValue; ++i){mapInt64Int64[i] = i;}
165  size_t sizeMapInt64Int64 = data_size(mapInt64Int64);
166  data_stream_assert(checkValue("std::map<long int, long int>", sizeMapInt64Int64, 8lu*nbValue + 8lu*nbValue + 8lu));
167 
168  std::map<short, int> mapInt16Int32;
169  for(size_t i(0lu); i < nbValue; ++i){mapInt16Int32[i] = i;}
170  size_t sizeMapInt16Int32 = data_size(mapInt16Int32);
171  data_stream_assert(checkValue("std::map<short, int>", sizeMapInt16Int32, 2lu*nbValue + 4lu*nbValue + 8lu));
172 }

References checkValue(), data_size(), and data_stream_assert.

Referenced by main().

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

◆ testSimpleDataSize()

void testSimpleDataSize ( )

Test if data size is Ok.

Definition at line 23 of file main.cpp.

23  {
24  long unsigned int dataUint64(42lu);
25  size_t sizeUint64 = data_size(dataUint64);
26  data_stream_assert(checkValue("long unsigned int", sizeUint64, 8lu));
27 
28  unsigned int dataUint32(42lu);
29  size_t sizeUint32 = data_size(dataUint32);
30  data_stream_assert(checkValue("unsigned int", sizeUint32, 4lu));
31 
32  unsigned short dataUint16(42lu);
33  size_t sizeUint16 = data_size(dataUint16);
34  data_stream_assert(checkValue("unsigned short", sizeUint16, 2lu));
35 
36  unsigned char dataUint8(42lu);
37  size_t sizeUint8 = data_size(dataUint8);
38  data_stream_assert(checkValue("unsigned char", sizeUint8, 1lu));
39 
40  size_t dataint64(42lu);
41  size_t sizeint64 = data_size(dataint64);
42  data_stream_assert(checkValue("long int", sizeint64, 8lu));
43 
44  int dataint32(42lu);
45  size_t sizeint32 = data_size(dataint32);
46  data_stream_assert(checkValue("int", sizeint32, 4lu));
47 
48  short dataint16(42lu);
49  size_t sizeint16 = data_size(dataint16);
50  data_stream_assert(checkValue("short", sizeint16, 2lu));
51 
52  char dataint8(42lu);
53  size_t sizeint8 = data_size(dataint8);
54  data_stream_assert(checkValue("char", sizeint8, 1lu));
55 }

References checkValue(), data_size(), and data_stream_assert.

Referenced by main().

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

◆ testStringDataSize()

void testStringDataSize ( )

Test if data size is Ok.

Definition at line 267 of file main.cpp.

267  {
268  std::string str("One thing to say");
269  size_t sizeStr = data_size(str);
270  data_stream_assert(checkValue("std::string", sizeStr, 16lu + 8lu));
271 }

References checkValue(), data_size(), data_stream_assert, and createReleaseCurl::str.

Referenced by main().

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

◆ testVectorDataSize()

void testVectorDataSize ( )

Test if data size is Ok.

Definition at line 58 of file main.cpp.

58  {
59  size_t nbValue(10lu);
60 
61  std::vector<long unsigned int> vecUInt64;
62  for(size_t i(0lu); i < nbValue; ++i){vecUInt64.push_back(i);}
63  size_t sizeVecUint64 = data_size(vecUInt64);
64  data_stream_assert(checkValue("std::vector<long unsigned int>", sizeVecUint64, 8lu*nbValue + 8lu));
65 
66  std::vector<unsigned int> vecUInt32;
67  for(size_t i(0lu); i < nbValue; ++i){vecUInt32.push_back(i);}
68  size_t sizeVecUint32 = data_size(vecUInt32);
69  data_stream_assert(checkValue("std::vector<unsigned int>", sizeVecUint32, 4lu*nbValue + 8lu));
70 
71  std::vector<unsigned short> vecUInt16;
72  for(size_t i(0lu); i < nbValue; ++i){vecUInt16.push_back(i);}
73  size_t sizeVecUint16 = data_size(vecUInt16);
74  data_stream_assert(checkValue("std::vector<unsigned short>", sizeVecUint16, 2lu*nbValue + 8lu));
75 
76  std::vector<unsigned char> vecUInt8;
77  for(size_t i(0lu); i < nbValue; ++i){vecUInt8.push_back(i);}
78  size_t sizeVecUint8 = data_size(vecUInt8);
79  data_stream_assert(checkValue("std::vector<unsigned char>", sizeVecUint8, 1lu*nbValue + 8lu));
80 
81 
82  std::vector<long int> vecInt64;
83  for(size_t i(0lu); i < nbValue; ++i){vecInt64.push_back(i);}
84  size_t sizeVecInt64 = data_size(vecInt64);
85  data_stream_assert(checkValue("std::vector<long int>", sizeVecInt64, 8lu*nbValue + 8lu));
86 
87  std::vector<int> vecInt32;
88  for(size_t i(0lu); i < nbValue; ++i){vecInt32.push_back(i);}
89  size_t sizeVecInt32 = data_size(vecInt32);
90  data_stream_assert(checkValue("std::vector<int>", sizeVecInt32, 4lu*nbValue + 8lu));
91 
92  std::vector<short> vecInt16;
93  for(size_t i(0lu); i < nbValue; ++i){vecInt16.push_back(i);}
94  size_t sizeVecInt16 = data_size(vecInt16);
95  data_stream_assert(checkValue("std::vector<short>", sizeVecInt16, 2lu*nbValue + 8lu));
96 
97  std::vector<char> vecInt8;
98  for(size_t i(0lu); i < nbValue; ++i){vecInt8.push_back(i);}
99  size_t sizeVecInt8 = data_size(vecInt8);
100  data_stream_assert(checkValue("std::vector<char>", sizeVecInt8, 1lu*nbValue + 8lu));
101 }

References checkValue(), data_size(), and data_stream_assert.

Referenced by main().

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

◆ testVectorPairDataSize()

void testVectorPairDataSize ( )

Test if data size is Ok.

Definition at line 175 of file main.cpp.

175  {
176  size_t nbValue(10lu);
177 
178  std::vector<std::pair<long unsigned int, long unsigned int> > vecUInt64;
179  for(size_t i(0lu); i < nbValue; ++i){vecUInt64.push_back(std::pair<long unsigned int, long unsigned int>(i,i));}
180  size_t sizeVecUint64 = data_size(vecUInt64);
181  data_stream_assert(checkValue("std::vector<std::pair<long unsigned int, long unsigned int> >", sizeVecUint64, 2lu*8lu*nbValue + 8lu));
182 
183  std::vector<std::pair<unsigned int, unsigned int> > vecUInt32;
184  for(size_t i(0lu); i < nbValue; ++i){vecUInt32.push_back(std::pair<unsigned int, unsigned int>(i,i));}
185  size_t sizeVecUint32 = data_size(vecUInt32);
186  data_stream_assert(checkValue("std::vector<std::pair<unsigned int, unsigned int> >", sizeVecUint32, 2lu*4lu*nbValue + 8lu));
187 
188  std::vector<std::pair<unsigned short, unsigned short> > vecUInt16;
189  for(size_t i(0lu); i < nbValue; ++i){vecUInt16.push_back(std::pair<unsigned short, unsigned short>(i,i));}
190  size_t sizeVecUint16 = data_size(vecUInt16);
191  data_stream_assert(checkValue("std::vector<std::pair<unsigned short, unsigned short> >", sizeVecUint16, 2lu*2lu*nbValue + 8lu));
192 
193  std::vector<std::pair<unsigned char, unsigned char> > vecUInt8;
194  for(size_t i(0lu); i < nbValue; ++i){vecUInt8.push_back(std::pair<unsigned char, unsigned char>(i,i));}
195  size_t sizeVecUint8 = data_size(vecUInt8);
196  data_stream_assert(checkValue("std::vector<std::pair<unsigned char, unsigned char> >", sizeVecUint8, 2lu*1lu*nbValue + 8lu));
197 
198 
199  std::vector<std::pair<long int, long int> > vecInt64;
200  for(size_t i(0lu); i < nbValue; ++i){vecInt64.push_back(std::pair<long int, long int>(i,i));}
201  size_t sizeVecInt64 = data_size(vecInt64);
202  data_stream_assert(checkValue("std::vector<std::pair<long int, long int> >", sizeVecInt64, 2lu*8lu*nbValue + 8lu));
203 
204  std::vector<std::pair<int,int> > vecInt32;
205  for(size_t i(0lu); i < nbValue; ++i){vecInt32.push_back(std::pair<int,int>(i,i));}
206  size_t sizeVecInt32 = data_size(vecInt32);
207  data_stream_assert(checkValue("std::vector<std::pair<int,int> >", sizeVecInt32, 2lu*4lu*nbValue + 8lu));
208 
209  std::vector<std::pair<short, short> > vecInt16;
210  for(size_t i(0lu); i < nbValue; ++i){vecInt16.push_back(std::pair<short, short>(i,i));}
211  size_t sizeVecInt16 = data_size(vecInt16);
212  data_stream_assert(checkValue("std::vector<std::pair<short, short> >", sizeVecInt16, 2lu*2lu*nbValue + 8lu));
213 
214  std::vector<std::pair<char, char> > vecInt8;
215  for(size_t i(0lu); i < nbValue; ++i){vecInt8.push_back(std::pair<char, char>(i,i));}
216  size_t sizeVecInt8 = data_size(vecInt8);
217  data_stream_assert(checkValue("std::vector<std::pair<char, char> >", sizeVecInt8, 2lu*1lu*nbValue + 8lu));
218 }

References checkValue(), data_size(), and data_stream_assert.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:
testVectorDataSize
void testVectorDataSize()
Test if data size is Ok.
Definition: main.cpp:58
testListDataSize
void testListDataSize()
Test if data size is Ok.
Definition: main.cpp:104
testMapDataSize
void testMapDataSize()
Test if data size is Ok.
Definition: main.cpp:150
testStringDataSize
void testStringDataSize()
Test if data size is Ok.
Definition: main.cpp:267
data_stream_assert
#define data_stream_assert(isOk)
Definition: data_stream_assert.h:17
testListPairDataSize
void testListPairDataSize()
Test if data size is Ok.
Definition: main.cpp:221
data_size
size_t data_size(T &data)
Get size of data.
Definition: data_size.h:17
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
createReleaseCurl.str
str
Definition: createReleaseCurl.py:128
testVectorPairDataSize
void testVectorPairDataSize()
Test if data size is Ok.
Definition: main.cpp:175
testSimpleDataSize
void testSimpleDataSize()
Test if data size is Ok.
Definition: main.cpp:23