GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/DataStream/TESTS/TEST_DATA_MESSAGE/main.cpp Lines: 444 444 100.0 %
Date: 2024-12-09 15:30:52 Branches: 992 992 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 "data_stream_assert.h"
8
#include "data_stream_check_value.h"
9
10
#include "data_size.h"
11
#include "data_message.h"
12
13
///Test if data size is Ok
14
1
void testSimpleDataMessage(){
15
1
	long unsigned int dataUInt64(42lu);
16
2
	std::vector<char> messageUInt64(data_size(dataUInt64));
17
	//Put data in message
18
1
	char* iterUInt64 = (char*)messageUInt64.data();
19

1
	data_stream_assert(data_message_save(iterUInt64, dataUInt64));			//Save the message
20
1
	char* loadIterUInt64 = (char*)messageUInt64.data();
21
1
	long unsigned int outUInt64(0lu);
22

1
	data_stream_assert(data_message_load(loadIterUInt64, outUInt64));		//Load the message
23

1
	data_stream_assert(checkValue("long unsigned int", dataUInt64, outUInt64));
24
25
1
	unsigned int dataUInt32(42u);
26
2
	std::vector<char> messageUInt32(data_size(dataUInt32));
27
	//Put data in message
28
1
	char* iterUInt32 = (char*)messageUInt32.data();
29

1
	data_stream_assert(data_message_save(iterUInt32, dataUInt32));			//Save the message
30
1
	char* loadIterUInt32 = (char*)messageUInt32.data();
31
1
	unsigned int outUInt32(0lu);
32

1
	data_stream_assert(data_message_load(loadIterUInt32, outUInt32));		//Load the message
33

1
	data_stream_assert(checkValue("unsigned int", dataUInt32, outUInt32));
34
35
1
	unsigned short dataUInt16(42u);
36
2
	std::vector<char> messageUInt16(data_size(dataUInt16));
37
	//Put data in message
38
1
	char* iterUInt16 = (char*)messageUInt16.data();
39

1
	data_stream_assert(data_message_save(iterUInt16, dataUInt32));			//Save the message
40
1
	char* loadIterUInt16 = (char*)messageUInt16.data();
41
1
	unsigned short outUInt16(0lu);
42

1
	data_stream_assert(data_message_load(loadIterUInt16, outUInt16));		//Load the message
43

1
	data_stream_assert(checkValue("unsigned short", dataUInt16, outUInt16));
44
45
1
	unsigned char dataUInt8(42u);
46
2
	std::vector<char> messageUInt8(data_size(dataUInt8));
47
	//Put data in message
48
1
	char* iterUInt8 = (char*)messageUInt8.data();
49

1
	data_stream_assert(data_message_save(iterUInt8, dataUInt32));			//Save the message
50
1
	char* loadIterUInt8 = (char*)messageUInt8.data();
51
1
	unsigned char outUInt8(0lu);
52

1
	data_stream_assert(data_message_load(loadIterUInt8, outUInt8));		//Load the message
53

1
	data_stream_assert(checkValue("unsigned char", dataUInt8, outUInt8));
54
55
56
1
	long int dataInt64(42lu);
57
2
	std::vector<char> messageInt64(data_size(dataInt64));
58
	//Put data in message
59
1
	char* iterInt64 = (char*)messageInt64.data();
60

1
	data_stream_assert(data_message_save(iterInt64, dataInt64));			//Save the message
61
1
	char* loadIterInt64 = (char*)messageInt64.data();
62
1
	long int outInt64(0lu);
63

1
	data_stream_assert(data_message_load(loadIterInt64, outInt64));		//Load the message
64

1
	data_stream_assert(checkValue("long int", dataInt64, outInt64));
65
66
1
	int dataInt32(42u);
67
2
	std::vector<char> messageInt32(data_size(dataInt32));
68
	//Put data in message
69
1
	char* iterInt32 = (char*)messageInt32.data();
70

1
	data_stream_assert(data_message_save(iterInt32, dataInt32));			//Save the message
71
1
	char* loadIterInt32 = (char*)messageInt32.data();
72
1
	int outInt32(0lu);
73

1
	data_stream_assert(data_message_load(loadIterInt32, outInt32));		//Load the message
74

1
	data_stream_assert(checkValue("int", dataInt32, outInt32));
75
76
1
	short dataInt16(42u);
77
2
	std::vector<char> messageInt16(data_size(dataInt16));
78
	//Put data in message
79
1
	char* iterInt16 = (char*)messageInt16.data();
80

1
	data_stream_assert(data_message_save(iterInt16, dataInt32));			//Save the message
81
1
	char* loadIterInt16 = (char*)messageInt16.data();
82
1
	short outInt16(0lu);
83

1
	data_stream_assert(data_message_load(loadIterInt16, outInt16));		//Load the message
84

1
	data_stream_assert(checkValue("short", dataInt16, outInt16));
85
86
1
	char dataInt8(42u);
87
2
	std::vector<char> messageInt8(data_size(dataInt8));
88
	//Put data in message
89
1
	char* iterInt8 = (char*)messageInt8.data();
90

1
	data_stream_assert(data_message_save(iterInt8, dataInt32));			//Save the message
91
1
	char* loadIterInt8 = (char*)messageInt8.data();
92
1
	char outInt8(0lu);
93

1
	data_stream_assert(data_message_load(loadIterInt8, outInt8));		//Load the message
94

1
	data_stream_assert(checkValue("char", dataInt8, outInt8));
95
96
1
	bool dataBool(true);
97
2
	std::vector<char> messageBool(data_size(dataBool));
98
	//Put data in message
99
1
	char* iterBool = (char*)messageBool.data();
100

1
	data_stream_assert(data_message_save(iterBool, dataBool));			//Save the message
101
1
	char* loadIterBool = (char*)messageBool.data();
102
1
	bool outBool(false);
103

1
	data_stream_assert(data_message_load(loadIterBool, outBool));		//Load the message
104

1
	data_stream_assert(checkValue("bool", dataBool, outBool));
105
106
1
	float dataFloat(3.14f);
107
2
	std::vector<char> messageFloat(data_size(dataFloat));
108
	//Put data in message
109
1
	char* iterFloat = (char*)messageFloat.data();
110

1
	data_stream_assert(data_message_save(iterFloat, dataFloat));			//Save the message
111
1
	char* loadIterFloat = (char*)messageFloat.data();
112
1
	float outFloat(0.0f);
113

1
	data_stream_assert(data_message_load(loadIterFloat, outFloat));		//Load the message
114

1
	data_stream_assert(checkValue("float", dataFloat, outFloat));
115
116
1
	double dataDouble(58.9);
117
1
	std::vector<char> messageDouble(data_size(dataDouble));
118
	//Put data in message
119
1
	char* iterDouble = (char*)messageDouble.data();
120

1
	data_stream_assert(data_message_save(iterDouble, dataDouble));			//Save the message
121
1
	char* loadIterDouble = (char*)messageDouble.data();
122
1
	double outDouble(0.0);
123

1
	data_stream_assert(data_message_load(loadIterDouble, outDouble));		//Load the message
124

1
	data_stream_assert(checkValue("double", dataDouble, outDouble));
125
1
}
126
127
///Test if data size is Ok
128
1
void testVectorDataMessage(){
129
1
	size_t nbValue(10lu);
130
131
2
	std::vector<long unsigned int> vecUInt64;
132
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt64.push_back(i);}
133
2
	std::vector<char> messageUInt64(data_size(vecUInt64));
134
	//Put data in message
135
1
	char* iterUInt64 = (char*)messageUInt64.data();
136

1
	data_stream_assert(data_message_save(iterUInt64, vecUInt64));			//Save the message
137
1
	char* loadIterUInt64 = (char*)messageUInt64.data();
138
2
	std::vector<long unsigned int> outVecUInt64(0lu);
139

1
	data_stream_assert(data_message_load(loadIterUInt64, outVecUInt64));		//Load the message
140

1
	data_stream_assert(checkValue("std::vector<long unsigned int>", outVecUInt64, vecUInt64));
141
142
2
	std::vector<unsigned int> vecUInt32;
143
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt32.push_back(i);}
144
2
	std::vector<char> messageUInt32(data_size(vecUInt32));
145
	//Put data in message
146
1
	char* iterUInt32 = (char*)messageUInt32.data();
147

1
	data_stream_assert(data_message_save(iterUInt32, vecUInt32));			//Save the message
148
1
	char* loadIterUInt32 = (char*)messageUInt32.data();
149
2
	std::vector<unsigned int> outVecUInt32(0lu);
150

1
	data_stream_assert(data_message_load(loadIterUInt32, outVecUInt32));		//Load the message
151

1
	data_stream_assert(checkValue("std::vector<unsigned int>", outVecUInt32, vecUInt32));
152
153
2
	std::vector<unsigned short> vecUInt16;
154
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt16.push_back(i);}
155
2
	std::vector<char> messageUInt16(data_size(vecUInt16));
156
	//Put data in message
157
1
	char* iterUInt16 = (char*)messageUInt16.data();
158

1
	data_stream_assert(data_message_save(iterUInt16, vecUInt16));			//Save the message
159
1
	char* loadIterUInt16 = (char*)messageUInt16.data();
160
2
	std::vector<unsigned short> outVecUInt16(0lu);
161

1
	data_stream_assert(data_message_load(loadIterUInt16, outVecUInt16));		//Load the message
162

1
	data_stream_assert(checkValue("std::vector<unsigned short>", outVecUInt16, vecUInt16));
163
164
2
	std::vector<unsigned char> vecUInt8;
165
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt8.push_back(i);}
166
2
	std::vector<char> messageUInt8(data_size(vecUInt8));
167
	//Put data in message
168
1
	char* iterUInt8 = (char*)messageUInt8.data();
169

1
	data_stream_assert(data_message_save(iterUInt8, vecUInt8));			//Save the message
170
1
	char* loadIterUInt8 = (char*)messageUInt8.data();
171
2
	std::vector<unsigned char> outVecUInt8(0lu);
172

1
	data_stream_assert(data_message_load(loadIterUInt8, outVecUInt8));		//Load the message
173

1
	data_stream_assert(checkValue("std::vector<unsigned char>", outVecUInt8, vecUInt8));
174
175
176
2
	std::vector<long int> vecInt64;
177
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt64.push_back(i);}
178
2
	std::vector<char> messageInt64(data_size(vecInt64));
179
	//Put data in message
180
1
	char* iterInt64 = (char*)messageInt64.data();
181

1
	data_stream_assert(data_message_save(iterInt64, vecInt64));			//Save the message
182
1
	char* loadIterInt64 = (char*)messageInt64.data();
183
2
	std::vector<long int> outVecInt64(0lu);
184

1
	data_stream_assert(data_message_load(loadIterInt64, outVecInt64));		//Load the message
185

1
	data_stream_assert(checkValue("std::vector<long int>", outVecInt64, vecInt64));
186
187
2
	std::vector<int> vecInt32;
188
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt32.push_back(i);}
189
2
	std::vector<char> messageInt32(data_size(vecInt32));
190
	//Put data in message
191
1
	char* iterInt32 = (char*)messageInt32.data();
192

1
	data_stream_assert(data_message_save(iterInt32, vecInt32));			//Save the message
193
1
	char* loadIterInt32 = (char*)messageInt32.data();
194
2
	std::vector<int> outVecInt32(0lu);
195

1
	data_stream_assert(data_message_load(loadIterInt32, outVecInt32));		//Load the message
196

1
	data_stream_assert(checkValue("std::vector<int>", outVecInt32, vecInt32));
197
198
2
	std::vector<short> vecInt16;
199
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt16.push_back(i);}
200
2
	std::vector<char> messageInt16(data_size(vecInt16));
201
	//Put data in message
202
1
	char* iterInt16 = (char*)messageInt16.data();
203

1
	data_stream_assert(data_message_save(iterInt16, vecInt16));			//Save the message
204
1
	char* loadIterInt16 = (char*)messageInt16.data();
205
2
	std::vector<short> outVecInt16(0lu);
206

1
	data_stream_assert(data_message_load(loadIterInt16, outVecInt16));		//Load the message
207

1
	data_stream_assert(checkValue("std::vector<short>", outVecInt16, vecInt16));
208
209
2
	std::vector<char> vecInt8;
210
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt8.push_back(i);}
211
2
	std::vector<char> messageInt8(data_size(vecInt8));
212
	//Put data in message
213
1
	char* iterInt8 = (char*)messageInt8.data();
214

1
	data_stream_assert(data_message_save(iterInt8, vecInt8));			//Save the message
215
1
	char* loadIterInt8 = (char*)messageInt8.data();
216
1
	std::vector<char> outVecInt8(0lu);
217

1
	data_stream_assert(data_message_load(loadIterInt8, outVecInt8));		//Load the message
218

1
	data_stream_assert(checkValue("std::vector<char>", outVecInt8, vecInt8));
219
1
}
220
221
///Test if data size is Ok
222
1
void testListDataMessage(){
223
1
	size_t nbValue(10lu);
224
225
2
	std::list<long unsigned int> vecUInt64;
226
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt64.push_back(i);}
227
2
	std::vector<char> messageUInt64(data_size(vecUInt64));
228
	//Put data in message
229
1
	char* iterUInt64 = (char*)messageUInt64.data();
230

1
	data_stream_assert(data_message_save(iterUInt64, vecUInt64));			//Save the message
231
1
	char* loadIterUInt64 = (char*)messageUInt64.data();
232
2
	std::list<long unsigned int> outVecUInt64(0lu);
233

1
	data_stream_assert(data_message_load(loadIterUInt64, outVecUInt64));		//Load the message
234

1
	data_stream_assert(checkValue("std::list<long unsigned int>", outVecUInt64, vecUInt64));
235
236
2
	std::list<unsigned int> vecUInt32;
237
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt32.push_back(i);}
238
2
	std::vector<char> messageUInt32(data_size(vecUInt32));
239
	//Put data in message
240
1
	char* iterUInt32 = (char*)messageUInt32.data();
241

1
	data_stream_assert(data_message_save(iterUInt32, vecUInt32));			//Save the message
242
1
	char* loadIterUInt32 = (char*)messageUInt32.data();
243
2
	std::list<unsigned int> outVecUInt32(0lu);
244

1
	data_stream_assert(data_message_load(loadIterUInt32, outVecUInt32));		//Load the message
245

1
	data_stream_assert(checkValue("std::list<unsigned int>", outVecUInt32, vecUInt32));
246
247
2
	std::list<unsigned short> vecUInt16;
248
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt16.push_back(i);}
249
2
	std::vector<char> messageUInt16(data_size(vecUInt16));
250
	//Put data in message
251
1
	char* iterUInt16 = (char*)messageUInt16.data();
252

1
	data_stream_assert(data_message_save(iterUInt16, vecUInt16));			//Save the message
253
1
	char* loadIterUInt16 = (char*)messageUInt16.data();
254
2
	std::list<unsigned short> outVecUInt16(0lu);
255

1
	data_stream_assert(data_message_load(loadIterUInt16, outVecUInt16));		//Load the message
256

1
	data_stream_assert(checkValue("std::list<unsigned short>", outVecUInt16, vecUInt16));
257
258
2
	std::list<unsigned char> vecUInt8;
259
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt8.push_back(i);}
260
2
	std::vector<char> messageUInt8(data_size(vecUInt8));
261
	//Put data in message
262
1
	char* iterUInt8 = (char*)messageUInt8.data();
263

1
	data_stream_assert(data_message_save(iterUInt8, vecUInt8));			//Save the message
264
1
	char* loadIterUInt8 = (char*)messageUInt8.data();
265
2
	std::list<unsigned char> outVecUInt8(0lu);
266

1
	data_stream_assert(data_message_load(loadIterUInt8, outVecUInt8));		//Load the message
267

1
	data_stream_assert(checkValue("std::list<unsigned char>", outVecUInt8, vecUInt8));
268
269
270
2
	std::list<long int> vecInt64;
271
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt64.push_back(i);}
272
2
	std::vector<char> messageInt64(data_size(vecInt64));
273
	//Put data in message
274
1
	char* iterInt64 = (char*)messageInt64.data();
275

1
	data_stream_assert(data_message_save(iterInt64, vecInt64));			//Save the message
276
1
	char* loadIterInt64 = (char*)messageInt64.data();
277
2
	std::list<long int> outVecInt64(0lu);
278

1
	data_stream_assert(data_message_load(loadIterInt64, outVecInt64));		//Load the message
279

1
	data_stream_assert(checkValue("std::list<long int>", outVecInt64, vecInt64));
280
281
2
	std::list<int> vecInt32;
282
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt32.push_back(i);}
283
2
	std::vector<char> messageInt32(data_size(vecInt32));
284
	//Put data in message
285
1
	char* iterInt32 = (char*)messageInt32.data();
286

1
	data_stream_assert(data_message_save(iterInt32, vecInt32));			//Save the message
287
1
	char* loadIterInt32 = (char*)messageInt32.data();
288
2
	std::list<int> outVecInt32(0lu);
289

1
	data_stream_assert(data_message_load(loadIterInt32, outVecInt32));		//Load the message
290

1
	data_stream_assert(checkValue("std::list<int>", outVecInt32, vecInt32));
291
292
2
	std::list<short> vecInt16;
293
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt16.push_back(i);}
294
2
	std::vector<char> messageInt16(data_size(vecInt16));
295
	//Put data in message
296
1
	char* iterInt16 = (char*)messageInt16.data();
297

1
	data_stream_assert(data_message_save(iterInt16, vecInt16));			//Save the message
298
1
	char* loadIterInt16 = (char*)messageInt16.data();
299
2
	std::list<short> outVecInt16(0lu);
300

1
	data_stream_assert(data_message_load(loadIterInt16, outVecInt16));		//Load the message
301

1
	data_stream_assert(checkValue("std::list<short>", outVecInt16, vecInt16));
302
303
2
	std::list<char> vecInt8;
304
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt8.push_back(i);}
305
2
	std::vector<char> messageInt8(data_size(vecInt8));
306
	//Put data in message
307
1
	char* iterInt8 = (char*)messageInt8.data();
308

1
	data_stream_assert(data_message_save(iterInt8, vecInt8));			//Save the message
309
1
	char* loadIterInt8 = (char*)messageInt8.data();
310
1
	std::list<char> outVecInt8(0lu);
311

1
	data_stream_assert(data_message_load(loadIterInt8, outVecInt8));		//Load the message
312

1
	data_stream_assert(checkValue("std::list<char>", outVecInt8, vecInt8));
313
1
}
314
315
///Test if data size is Ok
316
1
void testMapDataMessage(){
317
1
	size_t nbValue(10lu);
318
319
2
	std::map<long unsigned int, long unsigned int> mapUInt64UInt64;
320
11
	for(size_t i(0lu); i < nbValue; ++i){mapUInt64UInt64[i] = 2lu*i;}
321
2
	std::vector<char> messageUInt64UInt64(data_size(mapUInt64UInt64));
322
	//Put data in message
323
1
	char* iterUIntUInt64 = (char*)messageUInt64UInt64.data();
324

1
	data_stream_assert(data_message_save(iterUIntUInt64, mapUInt64UInt64));			//Save the message
325
1
	char* loadIterUIntUInt64 = (char*)messageUInt64UInt64.data();
326
2
	std::map<long unsigned int, long unsigned int> outVecUInt64UInt64;
327

1
	data_stream_assert(data_message_load(loadIterUIntUInt64, outVecUInt64UInt64));		//Load the message
328

1
	data_stream_assert(checkValue("std::map<long unsigned int, long unsigned int>", outVecUInt64UInt64, mapUInt64UInt64));
329
330
2
	std::map<unsigned int, unsigned int> mapUInt32UInt32;
331
11
	for(size_t i(0lu); i < nbValue; ++i){mapUInt32UInt32[i] = 2lu*i;}
332
2
	std::vector<char> messageUInt32UInt32(data_size(mapUInt32UInt32));
333
	//Put data in message
334
1
	char* iterUIntUInt32 = (char*)messageUInt32UInt32.data();
335

1
	data_stream_assert(data_message_save(iterUIntUInt32, mapUInt32UInt32));			//Save the message
336
1
	char* loadIterUIntUInt32 = (char*)messageUInt32UInt32.data();
337
2
	std::map<unsigned int, unsigned int> outVecUInt32UInt32;
338

1
	data_stream_assert(data_message_load(loadIterUIntUInt32, outVecUInt32UInt32));		//Load the message
339

1
	data_stream_assert(checkValue("std::map<unsigned int, unsigned int>", outVecUInt32UInt32, mapUInt32UInt32));
340
341
2
	std::map<unsigned short, unsigned short> mapUInt16UInt16;
342
11
	for(size_t i(0lu); i < nbValue; ++i){mapUInt16UInt16[i] = 2lu*i;}
343
2
	std::vector<char> messageUInt16UInt16(data_size(mapUInt16UInt16));
344
	//Put data in message
345
1
	char* iterUIntUInt16 = (char*)messageUInt16UInt16.data();
346

1
	data_stream_assert(data_message_save(iterUIntUInt16, mapUInt16UInt16));			//Save the message
347
1
	char* loadIterUIntUInt16 = (char*)messageUInt16UInt16.data();
348
2
	std::map<unsigned short, unsigned short> outVecUInt16UInt16;
349

1
	data_stream_assert(data_message_load(loadIterUIntUInt16, outVecUInt16UInt16));		//Load the message
350

1
	data_stream_assert(checkValue("std::map<unsigned short, unsigned short>", outVecUInt16UInt16, mapUInt16UInt16));
351
352
2
	std::map<unsigned char, unsigned char> mapUInt8UInt8;
353
11
	for(size_t i(0lu); i < nbValue; ++i){mapUInt8UInt8[i] = 2lu*i;}
354
2
	std::vector<char> messageUInt8UInt8(data_size(mapUInt8UInt8));
355
	//Put data in message
356
1
	char* iterUIntUInt8 = (char*)messageUInt8UInt8.data();
357

1
	data_stream_assert(data_message_save(iterUIntUInt8, mapUInt8UInt8));			//Save the message
358
1
	char* loadIterUIntUInt8 = (char*)messageUInt8UInt8.data();
359
2
	std::map<unsigned char, unsigned char> outVecUInt8UInt8;
360

1
	data_stream_assert(data_message_load(loadIterUIntUInt8, outVecUInt8UInt8));		//Load the message
361

1
	data_stream_assert(checkValue("std::map<unsigned char, unsigned char>", outVecUInt8UInt8, mapUInt8UInt8));
362
363
364
2
	std::map<long int, long int> mapInt64Int64;
365
11
	for(size_t i(0lu); i < nbValue; ++i){mapInt64Int64[i] = 2lu*i;}
366
2
	std::vector<char> messageInt64Int64(data_size(mapInt64Int64));
367
	//Put data in message
368
1
	char* iterIntInt64 = (char*)messageInt64Int64.data();
369

1
	data_stream_assert(data_message_save(iterIntInt64, mapInt64Int64));			//Save the message
370
1
	char* loadIterIntInt64 = (char*)messageInt64Int64.data();
371
2
	std::map<long int, long int> outVecInt64Int64;
372

1
	data_stream_assert(data_message_load(loadIterIntInt64, outVecInt64Int64));		//Load the message
373

1
	data_stream_assert(checkValue("std::map<long int, long int>", outVecInt64Int64, mapInt64Int64));
374
375
2
	std::map<int, int> mapInt32Int32;
376
11
	for(size_t i(0lu); i < nbValue; ++i){mapInt32Int32[i] = 2lu*i;}
377
2
	std::vector<char> messageInt32Int32(data_size(mapInt32Int32));
378
	//Put data in message
379
1
	char* iterIntInt32 = (char*)messageInt32Int32.data();
380

1
	data_stream_assert(data_message_save(iterIntInt32, mapInt32Int32));			//Save the message
381
1
	char* loadIterIntInt32 = (char*)messageInt32Int32.data();
382
2
	std::map<int, int> outVecInt32Int32;
383

1
	data_stream_assert(data_message_load(loadIterIntInt32, outVecInt32Int32));		//Load the message
384

1
	data_stream_assert(checkValue("std::map<int, int>", outVecInt32Int32, mapInt32Int32));
385
386
2
	std::map<short, short> mapInt16Int16;
387
11
	for(size_t i(0lu); i < nbValue; ++i){mapInt16Int16[i] = 2lu*i;}
388
2
	std::vector<char> messageInt16Int16(data_size(mapInt16Int16));
389
	//Put data in message
390
1
	char* iterIntInt16 = (char*)messageInt16Int16.data();
391

1
	data_stream_assert(data_message_save(iterIntInt16, mapInt16Int16));			//Save the message
392
1
	char* loadIterIntInt16 = (char*)messageInt16Int16.data();
393
2
	std::map<short, short> outVecInt16Int16;
394

1
	data_stream_assert(data_message_load(loadIterIntInt16, outVecInt16Int16));		//Load the message
395

1
	data_stream_assert(checkValue("std::map<short, short>", outVecInt16Int16, mapInt16Int16));
396
397
2
	std::map<char, char> mapInt8Int8;
398
11
	for(size_t i(0lu); i < nbValue; ++i){mapInt8Int8[i] = 2lu*i;}
399
2
	std::vector<char> messageInt8Int8(data_size(mapInt8Int8));
400
	//Put data in message
401
1
	char* iterIntInt8 = (char*)messageInt8Int8.data();
402

1
	data_stream_assert(data_message_save(iterIntInt8, mapInt8Int8));			//Save the message
403
1
	char* loadIterIntInt8 = (char*)messageInt8Int8.data();
404
1
	std::map<char, char> outVecInt8Int8;
405

1
	data_stream_assert(data_message_load(loadIterIntInt8, outVecInt8Int8));		//Load the message
406

1
	data_stream_assert(checkValue("std::map<char, char>", outVecInt8Int8, mapInt8Int8));
407
1
}
408
409
///Test if data size is Ok
410
1
void testVectorPairDataMessage(){
411
1
	size_t nbValue(10lu);
412
413
2
	std::vector<std::pair<long unsigned int, long unsigned int> > vecUInt64;
414
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt64.push_back(std::pair<long unsigned int, long unsigned int>(i,2lu*i));}
415
2
	std::vector<char> messageUInt64(data_size(vecUInt64));
416
	//Put data in message
417
1
	char* iterUInt64 = (char*)messageUInt64.data();
418

1
	data_stream_assert(data_message_save(iterUInt64, vecUInt64));			//Save the message
419
1
	char* loadIterUInt64 = (char*)messageUInt64.data();
420
2
	std::vector<std::pair<long unsigned int, long unsigned int> > outVecUInt64(0lu);
421

1
	data_stream_assert(data_message_load(loadIterUInt64, outVecUInt64));		//Load the message
422

1
	data_stream_assert(checkValue("std::vector<std::pair<long unsigned int, long unsigned int> >", outVecUInt64, vecUInt64));
423
424
2
	std::vector<std::pair<unsigned int, unsigned int> > vecUInt32;
425
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt32.push_back(std::pair<unsigned int, unsigned int>(i,2lu*i));}
426
2
	std::vector<char> messageUInt32(data_size(vecUInt32));
427
	//Put data in message
428
1
	char* iterUInt32 = (char*)messageUInt32.data();
429

1
	data_stream_assert(data_message_save(iterUInt32, vecUInt32));			//Save the message
430
1
	char* loadIterUInt32 = (char*)messageUInt32.data();
431
2
	std::vector<std::pair<unsigned int, unsigned int> > outVecUInt32(0lu);
432

1
	data_stream_assert(data_message_load(loadIterUInt32, outVecUInt32));		//Load the message
433

1
	data_stream_assert(checkValue("std::vector<std::pair<unsigned int, unsigned int> >", outVecUInt32, vecUInt32));
434
435
2
	std::vector<std::pair<unsigned short, unsigned short> > vecUInt16;
436
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt16.push_back(std::pair<unsigned short, unsigned short>(i,2lu*i));}
437
2
	std::vector<char> messageUInt16(data_size(vecUInt16));
438
	//Put data in message
439
1
	char* iterUInt16 = (char*)messageUInt16.data();
440

1
	data_stream_assert(data_message_save(iterUInt16, vecUInt16));			//Save the message
441
1
	char* loadIterUInt16 = (char*)messageUInt16.data();
442
2
	std::vector<std::pair<unsigned short, unsigned short> > outVecUInt16(0lu);
443

1
	data_stream_assert(data_message_load(loadIterUInt16, outVecUInt16));		//Load the message
444

1
	data_stream_assert(checkValue("std::vector<std::pair<unsigned short, unsigned short> >", outVecUInt16, vecUInt16));
445
446
2
	std::vector<std::pair<unsigned char, unsigned char> > vecUInt8;
447
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt8.push_back(std::pair<unsigned char, unsigned char>(i,2lu*i));}
448
2
	std::vector<char> messageUInt8(data_size(vecUInt8));
449
	//Put data in message
450
1
	char* iterUInt8 = (char*)messageUInt8.data();
451

1
	data_stream_assert(data_message_save(iterUInt8, vecUInt8));			//Save the message
452
1
	char* loadIterUInt8 = (char*)messageUInt8.data();
453
2
	std::vector<std::pair<unsigned char, unsigned char> > outVecUInt8(0lu);
454

1
	data_stream_assert(data_message_load(loadIterUInt8, outVecUInt8));		//Load the message
455

1
	data_stream_assert(checkValue("std::vector<std::pair<unsigned char, unsigned char> >", outVecUInt8, vecUInt8));
456
457
458
2
	std::vector<std::pair<long int, long int> > vecInt64;
459
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt64.push_back(std::pair<long int, long int>(i,2lu*i));}
460
2
	std::vector<char> messageInt64(data_size(vecInt64));
461
	//Put data in message
462
1
	char* iterInt64 = (char*)messageInt64.data();
463

1
	data_stream_assert(data_message_save(iterInt64, vecInt64));			//Save the message
464
1
	char* loadIterInt64 = (char*)messageInt64.data();
465
2
	std::vector<std::pair<long int, long int> > outVecInt64(0lu);
466

1
	data_stream_assert(data_message_load(loadIterInt64, outVecInt64));		//Load the message
467

1
	data_stream_assert(checkValue("std::vector<std::pair<long int, long int> >", outVecInt64, vecInt64));
468
469
2
	std::vector<std::pair<int, int> > vecInt32;
470
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt32.push_back(std::pair<int, int>(i,2lu*i));}
471
2
	std::vector<char> messageInt32(data_size(vecInt32));
472
	//Put data in message
473
1
	char* iterInt32 = (char*)messageInt32.data();
474

1
	data_stream_assert(data_message_save(iterInt32, vecInt32));			//Save the message
475
1
	char* loadIterInt32 = (char*)messageInt32.data();
476
2
	std::vector<std::pair<int, int> > outVecInt32(0lu);
477

1
	data_stream_assert(data_message_load(loadIterInt32, outVecInt32));		//Load the message
478

1
	data_stream_assert(checkValue("std::vector<std::pair<int, int> >", outVecInt32, vecInt32));
479
480
2
	std::vector<std::pair<short, short> > vecInt16;
481
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt16.push_back(std::pair<short, short>(i,2lu*i));}
482
2
	std::vector<char> messageInt16(data_size(vecInt16));
483
	//Put data in message
484
1
	char* iterInt16 = (char*)messageInt16.data();
485

1
	data_stream_assert(data_message_save(iterInt16, vecInt16));			//Save the message
486
1
	char* loadIterInt16 = (char*)messageInt16.data();
487
2
	std::vector<std::pair<short, short> > outVecInt16(0lu);
488

1
	data_stream_assert(data_message_load(loadIterInt16, outVecInt16));		//Load the message
489

1
	data_stream_assert(checkValue("std::vector<std::pair<short, short> >", outVecInt16, vecInt16));
490
491
2
	std::vector<std::pair<char, char> > vecInt8;
492
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt8.push_back(std::pair<char, char>(i,2lu*i));}
493
2
	std::vector<char> messageInt8(data_size(vecInt8));
494
	//Put data in message
495
1
	char* iterInt8 = (char*)messageInt8.data();
496

1
	data_stream_assert(data_message_save(iterInt8, vecInt8));			//Save the message
497
1
	char* loadIterInt8 = (char*)messageInt8.data();
498
1
	std::vector<std::pair<char, char> > outVecInt8(0lu);
499

1
	data_stream_assert(data_message_load(loadIterInt8, outVecInt8));		//Load the message
500

1
	data_stream_assert(checkValue("std::vector<std::pair<char, char> >", outVecInt8, vecInt8));
501
1
}
502
503
///Test if data size is Ok
504
1
void testListPairDataMessage(){
505
1
	size_t nbValue(10lu);
506
507
2
	std::list<std::pair<long unsigned int, long unsigned int> > vecUInt64;
508
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt64.push_back(std::pair<long unsigned int, long unsigned int>(i,i));}
509
1
	size_t sizeVecUInt64 = data_size(vecUInt64);
510

1
	data_stream_assert(checkValue("std::list<std::pair<long unsigned int, long unsigned int> >", sizeVecUInt64, 2lu*8lu*nbValue + 8lu));
511
512
2
	std::list<std::pair<unsigned int, unsigned int> > vecUInt32;
513
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt32.push_back(std::pair<unsigned int, unsigned int>(i,i));}
514
1
	size_t sizeVecUInt32 = data_size(vecUInt32);
515

1
	data_stream_assert(checkValue("std::list<std::pair<unsigned int, unsigned int> >", sizeVecUInt32, 2lu*4lu*nbValue + 8lu));
516
517
2
	std::list<std::pair<unsigned short, unsigned short> > vecUInt16;
518
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt16.push_back(std::pair<unsigned short, unsigned short>(i,i));}
519
1
	size_t sizeVecUInt16 = data_size(vecUInt16);
520

1
	data_stream_assert(checkValue("std::list<std::pair<unsigned short, unsigned short> >", sizeVecUInt16, 2lu*2lu*nbValue + 8lu));
521
522
2
	std::list<std::pair<unsigned char, unsigned char> > vecUInt8;
523
11
	for(size_t i(0lu); i < nbValue; ++i){vecUInt8.push_back(std::pair<unsigned char, unsigned char>(i,i));}
524
1
	size_t sizeVecUInt8 = data_size(vecUInt8);
525

1
	data_stream_assert(checkValue("std::list<std::pair<unsigned char, unsigned char> >", sizeVecUInt8, 2lu*1lu*nbValue + 8lu));
526
527
528
2
	std::list<std::pair<long int, long int> > vecInt64;
529
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt64.push_back(std::pair<long int, long int>(i,i));}
530
1
	size_t sizeVecInt64 = data_size(vecInt64);
531

1
	data_stream_assert(checkValue("std::list<std::pair<long int, long int> >", sizeVecInt64, 2lu*8lu*nbValue + 8lu));
532
533
2
	std::list<std::pair<int,int> > vecInt32;
534
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt32.push_back(std::pair<int,int>(i,i));}
535
1
	size_t sizeVecInt32 = data_size(vecInt32);
536

1
	data_stream_assert(checkValue("std::list<std::pair<int,int> >", sizeVecInt32, 2lu*4lu*nbValue + 8lu));
537
538
2
	std::list<std::pair<short, short> > vecInt16;
539
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt16.push_back(std::pair<short, short>(i,i));}
540
1
	size_t sizeVecInt16 = data_size(vecInt16);
541

1
	data_stream_assert(checkValue("std::list<std::pair<short, short> >", sizeVecInt16, 2lu*2lu*nbValue + 8lu));
542
543
1
	std::list<std::pair<char, char> > vecInt8;
544
11
	for(size_t i(0lu); i < nbValue; ++i){vecInt8.push_back(std::pair<char, char>(i,i));}
545
1
	size_t sizeVecInt8 = data_size(vecInt8);
546

1
	data_stream_assert(checkValue("std::list<std::pair<char, char> >", sizeVecInt8, 2lu*1lu*nbValue + 8lu));
547
1
}
548
549
///Test if data size is Ok
550
1
void testStringDataMessage(){
551
2
	std::string str("One thing to say");
552
2
	std::vector<char> messageStr(data_size(str));
553
1
	char* iterStr = (char*)messageStr.data();
554

1
	data_stream_assert(data_message_save(iterStr, str));			//Save the message
555
1
	std::string outStr("");
556
1
	char* loadIterStr = (char*)messageStr.data();
557

1
	data_stream_assert(data_message_load(loadIterStr, outStr));		//Load the message
558
559
// 	std::cout << "testStringDataMessage : outStr("<<outStr<<"), str("<<str<<")" << std::endl;
560

1
	data_stream_assert(str == outStr);
561
1
}
562
563
1
int main(int argc, char** argv){
564
1
	testSimpleDataMessage();
565
1
	testVectorDataMessage();
566
1
	testListDataMessage();
567
1
	testMapDataMessage();
568
1
	testVectorPairDataMessage();
569
1
	testListPairDataMessage();
570
1
	testStringDataMessage();
571
1
	return 0;
572
}
573