1 | // |
2 | // TuplesTest.cpp |
3 | // |
4 | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. |
5 | // and Contributors. |
6 | // |
7 | // SPDX-License-Identifier: BSL-1.0 |
8 | // |
9 | |
10 | |
11 | #include "TuplesTest.h" |
12 | #include "Poco/CppUnit/TestCaller.h" |
13 | #include "Poco/CppUnit/TestSuite.h" |
14 | #include "Poco/Tuple.h" |
15 | #include "Poco/Void.h" |
16 | #include "Poco/Nullable.h" |
17 | #include <algorithm> |
18 | #include <map> |
19 | |
20 | |
21 | using Poco::TypeList; |
22 | using Poco::NullTypeList; |
23 | using Poco::TypeListType; |
24 | using Poco::TypeGetter; |
25 | using Poco::TypeLocator; |
26 | using Poco::TypeAppender; |
27 | using Poco::TypeOneEraser; |
28 | using Poco::TypeAllEraser; |
29 | using Poco::TypeDuplicateEraser; |
30 | using Poco::TypeOneReplacer; |
31 | using Poco::TypeAllReplacer; |
32 | using Poco::Tuple; |
33 | using Poco::Void; |
34 | using Poco::Nullable; |
35 | using Poco::Int8; |
36 | using Poco::UInt8; |
37 | using Poco::Int16; |
38 | using Poco::UInt16; |
39 | using Poco::Int32; |
40 | using Poco::UInt32; |
41 | using Poco::Int8; |
42 | using Poco::UInt8; |
43 | using Poco::Int16; |
44 | using Poco::UInt16; |
45 | using Poco::Int32; |
46 | using Poco::UInt32; |
47 | |
48 | |
49 | namespace { |
50 | |
51 | class NonDefaultConstructible |
52 | { |
53 | public: |
54 | NonDefaultConstructible(int val):_val(val) |
55 | { |
56 | } |
57 | |
58 | NonDefaultConstructible& operator=(int val) |
59 | { |
60 | _val = val; |
61 | return *this; |
62 | } |
63 | |
64 | bool operator==(const NonDefaultConstructible& other) const |
65 | { |
66 | return (_val == other._val); |
67 | } |
68 | |
69 | bool operator<(const NonDefaultConstructible& other) const |
70 | { |
71 | return (_val < other._val); |
72 | } |
73 | |
74 | int value() const |
75 | { |
76 | return _val; |
77 | } |
78 | |
79 | private: |
80 | NonDefaultConstructible(); |
81 | |
82 | int _val; |
83 | }; |
84 | |
85 | } |
86 | |
87 | |
88 | TuplesTest::TuplesTest(const std::string& rName): CppUnit::TestCase(rName) |
89 | { |
90 | } |
91 | |
92 | |
93 | TuplesTest::~TuplesTest() |
94 | { |
95 | } |
96 | |
97 | |
98 | void TuplesTest::testTuple1() |
99 | { |
100 | Tuple<int> t; |
101 | assertTrue (t.length == 1); |
102 | t.set<0>(-1); |
103 | assertTrue (t.get<0>() == -1); |
104 | |
105 | Tuple<int> t2(-1); |
106 | assertTrue (t2.get<0>() == -1); |
107 | |
108 | Tuple<int> tCpy (t2); |
109 | assertTrue (t2.get<0>() == tCpy.get<0>()); |
110 | assertTrue (t2 == tCpy); |
111 | |
112 | Tuple<int> tCpy2 = t2; |
113 | assertTrue (t2.get<0>() == tCpy2.get<0>()); |
114 | assertTrue (t2 == tCpy2); |
115 | tCpy2.set<0>(888); |
116 | assertTrue (t2 != tCpy2); |
117 | assertTrue (t < tCpy2); |
118 | |
119 | Tuple<int, std::string> t3(0); |
120 | assertTrue (t3.get<1>().empty()); |
121 | |
122 | Tuple<int, std::string, std::vector<std::string> > t4(0); |
123 | assertTrue (t4.get<1>().empty()); |
124 | assertTrue (t4.get<2>().empty()); |
125 | } |
126 | |
127 | |
128 | void TuplesTest::testTuple2() |
129 | { |
130 | Tuple<int, Void> dummy1; |
131 | assertTrue (dummy1.length == 2); |
132 | dummy1.set<0>(-1); |
133 | assertTrue (dummy1.get<0>() == -1); |
134 | //test partial init |
135 | Tuple<int, Void> dummy11(0); |
136 | |
137 | Tuple<Void, int> dummy2; |
138 | dummy2.set<1>(-1); |
139 | assertTrue (dummy2.get<1>() == -1); |
140 | |
141 | Tuple<Void, int> dummy3; |
142 | dummy3.set<1>(-1); |
143 | assertTrue (dummy3.get<1>() == -1); |
144 | |
145 | Tuple<std::string, int> aTuple; |
146 | aTuple.set<0>("str" ); |
147 | aTuple.set<1>(1); |
148 | assertTrue (aTuple.get<0>() == "str" ); |
149 | assertTrue (aTuple.get<1>() == 1); |
150 | |
151 | Tuple<std::string, int> aTuple2(aTuple); |
152 | assertTrue (aTuple == aTuple2); |
153 | aTuple2.set<1>(99); |
154 | assertTrue (aTuple != aTuple2); |
155 | aTuple2.set<1>(100000); |
156 | assertTrue (aTuple < aTuple2); |
157 | } |
158 | |
159 | |
160 | void TuplesTest::testTuple3() |
161 | { |
162 | Tuple<int, Void, Void> dummy1; |
163 | assertTrue (dummy1.length == 3); |
164 | dummy1.set<0>(-1); |
165 | assertTrue (dummy1.get<0>() == -1); |
166 | //test partial init |
167 | Tuple<int, Void, Void> dummy11(0); |
168 | |
169 | Tuple<Void, int, Void> dummy2; |
170 | dummy2.set<1>(-1); |
171 | assertTrue (dummy2.get<1>() == -1); |
172 | |
173 | Tuple<Void, Void, int> dummy3; |
174 | dummy3.set<2>(-1); |
175 | assertTrue (dummy3.get<2>() == -1); |
176 | |
177 | Tuple<std::string, int, bool> aTuple; |
178 | aTuple.set<0>("str" ); |
179 | aTuple.set<1>(1); |
180 | aTuple.set<2>(true); |
181 | assertTrue (aTuple.get<0>() == "str" ); |
182 | assertTrue (aTuple.get<1>() == 1); |
183 | assertTrue (aTuple.get<2>()); |
184 | |
185 | Tuple<std::string, int, bool> aTuple2(aTuple); |
186 | assertTrue (aTuple == aTuple2); |
187 | aTuple2.set<2>(false); |
188 | assertTrue (aTuple != aTuple2); |
189 | aTuple2.set<1>(100000); |
190 | assertTrue (aTuple < aTuple2); |
191 | } |
192 | |
193 | |
194 | void TuplesTest::testTuple4() |
195 | { |
196 | Tuple<int, Void, Void, Void> dummy1; |
197 | assertTrue (dummy1.length == 4); |
198 | dummy1.set<0>(-1); |
199 | assertTrue (dummy1.get<0>() == -1); |
200 | //test partial init |
201 | Tuple<int, Void, Void, Void> dummy11(0); |
202 | |
203 | Tuple<Void, int, Void, Void> dummy2; |
204 | dummy2.set<1>(-1); |
205 | assertTrue (dummy2.get<1>() == -1); |
206 | |
207 | Tuple<Void, Void, Void, int> dummy3; |
208 | dummy3.set<3>(-1); |
209 | assertTrue (dummy3.get<3>() == -1); |
210 | |
211 | Tuple<std::string, int, bool, float> aTuple; |
212 | aTuple.set<0>("str" ); |
213 | aTuple.set<1>(1); |
214 | aTuple.set<2>(true); |
215 | aTuple.set<3>(3.14f); |
216 | assertTrue (aTuple.get<0>() == "str" ); |
217 | assertTrue (aTuple.get<1>() == 1); |
218 | assertTrue (aTuple.get<2>()); |
219 | assertTrue (aTuple.get<3>() >= 3.13f && aTuple.get<3>() <= 3.15f); |
220 | |
221 | Tuple<std::string, int, bool, float> aTuple2(aTuple); |
222 | assertTrue (aTuple == aTuple2); |
223 | aTuple2.set<2>(false); |
224 | assertTrue (aTuple != aTuple2); |
225 | aTuple2.set<1>(100000); |
226 | assertTrue (aTuple < aTuple2); |
227 | } |
228 | |
229 | |
230 | void TuplesTest::testTuple5() |
231 | { |
232 | Tuple<int, Void, Void, Void, Void> dummy1; |
233 | assertTrue (dummy1.length == 5); |
234 | dummy1.set<0>(-1); |
235 | assertTrue (dummy1.get<0>() == -1); |
236 | //test partial init |
237 | Tuple<int, Void, Void, Void, Void> dummy11(0); |
238 | |
239 | Tuple<Void, int, Void, Void, Void> dummy2; |
240 | dummy2.set<1>(-1); |
241 | assertTrue (dummy2.get<1>() == -1); |
242 | |
243 | Tuple<Void, Void, Void, Void, int> dummy3; |
244 | dummy3.set<4>(-1); |
245 | assertTrue (dummy3.get<4>() == -1); |
246 | |
247 | Tuple<std::string, int, bool, float, char> aTuple; |
248 | aTuple.set<0>("str" ); |
249 | aTuple.set<1>(1); |
250 | aTuple.set<2>(true); |
251 | aTuple.set<3>(3.14f); |
252 | aTuple.set<4>(' '); |
253 | assertTrue (aTuple.get<0>() == "str" ); |
254 | assertTrue (aTuple.get<1>() == 1); |
255 | assertTrue (aTuple.get<2>()); |
256 | assertTrue (aTuple.get<3>() >= 3.13f && aTuple.get<3>() <= 3.15f); |
257 | assertTrue (aTuple.get<4>() == ' '); |
258 | |
259 | Tuple<std::string, int, bool, float, char> aTuple2(aTuple); |
260 | assertTrue (aTuple == aTuple2); |
261 | aTuple2.set<2>(false); |
262 | assertTrue (aTuple != aTuple2); |
263 | aTuple2.set<1>(100000); |
264 | assertTrue (aTuple < aTuple2); |
265 | } |
266 | |
267 | |
268 | void TuplesTest::testTuple6() |
269 | { |
270 | Tuple<std::string, int, bool, float, char, long> aTuple; |
271 | assertTrue (aTuple.length == 6); |
272 | Tuple<std::string, int, bool, float, char, long> |
273 | aTuple2("1" , 1, true, 3.14f, 'c', 999); |
274 | assertTrue (aTuple != aTuple2); |
275 | aTuple = aTuple2; |
276 | assertTrue (aTuple == aTuple2); |
277 | aTuple2.get<1>()++; |
278 | assertTrue (aTuple < aTuple2); |
279 | } |
280 | |
281 | |
282 | void TuplesTest::testTuple7() |
283 | { |
284 | Tuple<std::string, int, bool, float, char, long, double> aTuple; |
285 | assertTrue (aTuple.length == 7); |
286 | Tuple<std::string, int, bool, float, char, long, double> |
287 | aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14); |
288 | assertTrue (aTuple != aTuple2); |
289 | aTuple = aTuple2; |
290 | assertTrue (aTuple == aTuple2); |
291 | aTuple2.get<1>()++; |
292 | assertTrue (aTuple < aTuple2); |
293 | } |
294 | |
295 | |
296 | void TuplesTest::testTuple8() |
297 | { |
298 | Tuple<std::string, int, bool, float, char, long, double, short> aTuple; |
299 | assertTrue (aTuple.length == 8); |
300 | Tuple<std::string, int, bool, float, char, long, double, short> |
301 | aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700); |
302 | assertTrue (aTuple != aTuple2); |
303 | aTuple = aTuple2; |
304 | assertTrue (aTuple == aTuple2); |
305 | aTuple2.get<1>()++; |
306 | assertTrue (aTuple < aTuple2); |
307 | } |
308 | |
309 | void TuplesTest::testTuple9() |
310 | { |
311 | Tuple<std::string, int, bool, float, char, long, double, short, std::string> aTuple; |
312 | assertTrue (aTuple.length == 9); |
313 | Tuple<std::string, int, bool, float, char, long, double, short, std::string> |
314 | aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" ); |
315 | assertTrue (aTuple != aTuple2); |
316 | aTuple = aTuple2; |
317 | assertTrue (aTuple == aTuple2); |
318 | aTuple2.get<1>()++; |
319 | assertTrue (aTuple < aTuple2); |
320 | } |
321 | |
322 | |
323 | void TuplesTest::testTuple10() |
324 | { |
325 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int> TupleType; |
326 | |
327 | TupleType aTuple; |
328 | assertTrue (aTuple.length == 10); |
329 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2); |
330 | assertTrue (aTuple != aTuple2); |
331 | aTuple = aTuple2; |
332 | assertTrue (aTuple == aTuple2); |
333 | aTuple2.get<1>()++; |
334 | assertTrue (aTuple < aTuple2); |
335 | } |
336 | |
337 | |
338 | void TuplesTest::testTuple11() |
339 | { |
340 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
341 | std::string> TupleType; |
342 | |
343 | TupleType aTuple; |
344 | assertTrue (aTuple.length == 11); |
345 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2, "1" ); |
346 | assertTrue (aTuple != aTuple2); |
347 | aTuple = aTuple2; |
348 | assertTrue (aTuple == aTuple2); |
349 | aTuple2.get<1>()++; |
350 | assertTrue (aTuple < aTuple2); |
351 | } |
352 | |
353 | |
354 | void TuplesTest::testTuple12() |
355 | { |
356 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
357 | std::string, int> TupleType; |
358 | |
359 | TupleType aTuple; |
360 | assertTrue (aTuple.length == 12); |
361 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2, "1" , 1); |
362 | assertTrue (aTuple != aTuple2); |
363 | aTuple = aTuple2; |
364 | assertTrue (aTuple == aTuple2); |
365 | aTuple2.get<1>()++; |
366 | assertTrue (aTuple < aTuple2); |
367 | } |
368 | |
369 | |
370 | void TuplesTest::testTuple13() |
371 | { |
372 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
373 | std::string, int, bool> TupleType; |
374 | |
375 | TupleType aTuple; |
376 | assertTrue (aTuple.length == 13); |
377 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2, "1" , 1, true); |
378 | assertTrue (aTuple != aTuple2); |
379 | aTuple = aTuple2; |
380 | assertTrue (aTuple == aTuple2); |
381 | aTuple2.get<1>()++; |
382 | assertTrue (aTuple < aTuple2); |
383 | } |
384 | |
385 | |
386 | void TuplesTest::testTuple14() |
387 | { |
388 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
389 | std::string, int, bool, float> TupleType; |
390 | |
391 | TupleType aTuple; |
392 | assertTrue (aTuple.length == 14); |
393 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2, "1" , 1, true, 3.14f); |
394 | assertTrue (aTuple != aTuple2); |
395 | aTuple = aTuple2; |
396 | assertTrue (aTuple == aTuple2); |
397 | aTuple2.get<1>()++; |
398 | assertTrue (aTuple < aTuple2); |
399 | } |
400 | |
401 | |
402 | void TuplesTest::testTuple15() |
403 | { |
404 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
405 | std::string, int, bool, float, char> TupleType; |
406 | |
407 | TupleType aTuple; |
408 | assertTrue (aTuple.length == 15); |
409 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2, "1" , 1, true, 3.14f, 'c'); |
410 | assertTrue (aTuple != aTuple2); |
411 | aTuple = aTuple2; |
412 | assertTrue (aTuple == aTuple2); |
413 | aTuple2.get<1>()++; |
414 | assertTrue (aTuple < aTuple2); |
415 | } |
416 | |
417 | |
418 | void TuplesTest::testTuple16() |
419 | { |
420 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
421 | std::string, int, bool, float, char, long> TupleType; |
422 | |
423 | TupleType aTuple; |
424 | assertTrue (aTuple.length == 16); |
425 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2, "1" , 1, true, 3.14f, 'c', 999); |
426 | assertTrue (aTuple != aTuple2); |
427 | aTuple = aTuple2; |
428 | assertTrue (aTuple == aTuple2); |
429 | aTuple2.get<1>()++; |
430 | assertTrue (aTuple < aTuple2); |
431 | } |
432 | |
433 | |
434 | void TuplesTest::testTuple17() |
435 | { |
436 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
437 | std::string, int, bool, float, char, long, double> TupleType; |
438 | |
439 | TupleType aTuple; |
440 | assertTrue (aTuple.length == 17); |
441 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2, "1" , 1, true, 3.14f, 'c', 999, 33.14); |
442 | assertTrue (aTuple != aTuple2); |
443 | aTuple = aTuple2; |
444 | assertTrue (aTuple == aTuple2); |
445 | aTuple2.get<1>()++; |
446 | assertTrue (aTuple < aTuple2); |
447 | } |
448 | |
449 | |
450 | void TuplesTest::testTuple18() |
451 | { |
452 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
453 | std::string, int, bool, float, char, long, double, short> TupleType; |
454 | |
455 | TupleType aTuple; |
456 | assertTrue (aTuple.length == 18); |
457 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2, "1" , 1, true, 3.14f, 'c', 999, 33.14, 32700); |
458 | assertTrue (aTuple != aTuple2); |
459 | aTuple = aTuple2; |
460 | assertTrue (aTuple == aTuple2); |
461 | aTuple2.get<1>()++; |
462 | assertTrue (aTuple < aTuple2); |
463 | } |
464 | |
465 | |
466 | void TuplesTest::testTuple19() |
467 | { |
468 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
469 | std::string, int, bool, float, char, long, double, short, std::string> TupleType; |
470 | |
471 | TupleType aTuple; |
472 | assertTrue (aTuple.length == 19); |
473 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2, "1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" ); |
474 | assertTrue (aTuple != aTuple2); |
475 | aTuple = aTuple2; |
476 | assertTrue (aTuple == aTuple2); |
477 | aTuple2.get<1>()++; |
478 | assertTrue (aTuple < aTuple2); |
479 | } |
480 | |
481 | |
482 | void TuplesTest::testTuple20() |
483 | { |
484 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
485 | std::string, int, bool, float, char, long, double, short, std::string, int> TupleType; |
486 | |
487 | TupleType aTuple; |
488 | assertTrue (aTuple.length == 20); |
489 | |
490 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2, |
491 | "1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2); |
492 | assertTrue (aTuple != aTuple2); |
493 | aTuple = aTuple2; |
494 | assertTrue (aTuple == aTuple2); |
495 | aTuple2.get<1>()++; |
496 | assertTrue (aTuple < aTuple2); |
497 | } |
498 | |
499 | |
500 | void TuplesTest::testTuple21() |
501 | { |
502 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
503 | std::string, int, bool, float, char, long, double, short, std::string, int, |
504 | std::string> TupleType; |
505 | |
506 | TupleType aTuple; |
507 | assertTrue (aTuple.length == 21); |
508 | |
509 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
510 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
511 | "5" ); |
512 | assertTrue (aTuple != aTuple2); |
513 | TupleType aTuple3(aTuple2); |
514 | assertTrue (aTuple3 == aTuple2); |
515 | aTuple = aTuple2; |
516 | assertTrue (aTuple == aTuple2); |
517 | aTuple2.get<1>()++; |
518 | assertTrue (aTuple < aTuple2); |
519 | } |
520 | |
521 | |
522 | void TuplesTest::testTuple22() |
523 | { |
524 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
525 | std::string, int, bool, float, char, long, double, short, std::string, int, |
526 | std::string, int> TupleType; |
527 | |
528 | TupleType aTuple; |
529 | assertTrue (aTuple.length == 22); |
530 | |
531 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
532 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
533 | "5" , 5); |
534 | assertTrue (aTuple != aTuple2); |
535 | TupleType aTuple3(aTuple2); |
536 | assertTrue (aTuple3 == aTuple2); |
537 | aTuple = aTuple2; |
538 | assertTrue (aTuple == aTuple2); |
539 | aTuple2.get<1>()++; |
540 | assertTrue (aTuple < aTuple2); |
541 | } |
542 | |
543 | |
544 | void TuplesTest::testTuple23() |
545 | { |
546 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
547 | std::string, int, bool, float, char, long, double, short, std::string, int, |
548 | std::string, int, bool> TupleType; |
549 | |
550 | TupleType aTuple; |
551 | assertTrue (aTuple.length == 23); |
552 | |
553 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
554 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
555 | "5" , 5, true); |
556 | assertTrue (aTuple != aTuple2); |
557 | TupleType aTuple3(aTuple2); |
558 | assertTrue (aTuple3 == aTuple2); |
559 | aTuple = aTuple2; |
560 | assertTrue (aTuple == aTuple2); |
561 | aTuple2.get<1>()++; |
562 | assertTrue (aTuple < aTuple2); |
563 | } |
564 | |
565 | |
566 | void TuplesTest::testTuple24() |
567 | { |
568 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
569 | std::string, int, bool, float, char, long, double, short, std::string, int, |
570 | std::string, int, bool, float> TupleType; |
571 | |
572 | TupleType aTuple; |
573 | assertTrue (aTuple.length == 24); |
574 | |
575 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
576 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
577 | "5" , 5, true, 3.14f); |
578 | assertTrue (aTuple != aTuple2); |
579 | TupleType aTuple3(aTuple2); |
580 | assertTrue (aTuple3 == aTuple2); |
581 | aTuple = aTuple2; |
582 | assertTrue (aTuple == aTuple2); |
583 | aTuple2.get<1>()++; |
584 | assertTrue (aTuple < aTuple2); |
585 | } |
586 | |
587 | |
588 | void TuplesTest::testTuple25() |
589 | { |
590 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
591 | std::string, int, bool, float, char, long, double, short, std::string, int, |
592 | std::string, int, bool, float, char> TupleType; |
593 | |
594 | TupleType aTuple; |
595 | assertTrue (aTuple.length == 25); |
596 | |
597 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
598 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
599 | "5" , 5, true, 3.14f, 'c'); |
600 | assertTrue (aTuple != aTuple2); |
601 | TupleType aTuple3(aTuple2); |
602 | assertTrue (aTuple3 == aTuple2); |
603 | aTuple = aTuple2; |
604 | assertTrue (aTuple == aTuple2); |
605 | aTuple2.get<1>()++; |
606 | assertTrue (aTuple < aTuple2); |
607 | } |
608 | |
609 | |
610 | void TuplesTest::testTuple26() |
611 | { |
612 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
613 | std::string, int, bool, float, char, long, double, short, std::string, int, |
614 | std::string, int, bool, float, char, long> TupleType; |
615 | |
616 | TupleType aTuple; |
617 | assertTrue (aTuple.length == 26); |
618 | |
619 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
620 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
621 | "5" , 5, true, 3.14f, 'c', 999); |
622 | assertTrue (aTuple != aTuple2); |
623 | TupleType aTuple3(aTuple2); |
624 | assertTrue (aTuple3 == aTuple2); |
625 | aTuple = aTuple2; |
626 | assertTrue (aTuple == aTuple2); |
627 | aTuple2.get<1>()++; |
628 | assertTrue (aTuple < aTuple2); |
629 | } |
630 | |
631 | |
632 | void TuplesTest::testTuple27() |
633 | { |
634 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
635 | std::string, int, bool, float, char, long, double, short, std::string, int, |
636 | std::string, int, bool, float, char, long, double> TupleType; |
637 | |
638 | TupleType aTuple; |
639 | assertTrue (aTuple.length == 27); |
640 | |
641 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
642 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
643 | "5" , 5, true, 3.14f, 'c', 999, 33.14); |
644 | assertTrue (aTuple != aTuple2); |
645 | TupleType aTuple3(aTuple2); |
646 | assertTrue (aTuple3 == aTuple2); |
647 | aTuple = aTuple2; |
648 | assertTrue (aTuple == aTuple2); |
649 | aTuple2.get<1>()++; |
650 | assertTrue (aTuple < aTuple2); |
651 | } |
652 | |
653 | |
654 | void TuplesTest::testTuple28() |
655 | { |
656 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
657 | std::string, int, bool, float, char, long, double, short, std::string, int, |
658 | std::string, int, bool, float, char, long, double, short> TupleType; |
659 | |
660 | TupleType aTuple; |
661 | assertTrue (aTuple.length == 28); |
662 | |
663 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
664 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
665 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700); |
666 | assertTrue (aTuple != aTuple2); |
667 | TupleType aTuple3(aTuple2); |
668 | assertTrue (aTuple3 == aTuple2); |
669 | aTuple = aTuple2; |
670 | assertTrue (aTuple == aTuple2); |
671 | aTuple2.get<1>()++; |
672 | assertTrue (aTuple < aTuple2); |
673 | } |
674 | |
675 | |
676 | void TuplesTest::testTuple29() |
677 | { |
678 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
679 | std::string, int, bool, float, char, long, double, short, std::string, int, |
680 | std::string, int, bool, float, char, long, double, short, std::string> TupleType; |
681 | |
682 | TupleType aTuple; |
683 | assertTrue (aTuple.length == 29); |
684 | |
685 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
686 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
687 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" ); |
688 | assertTrue (aTuple != aTuple2); |
689 | TupleType aTuple3(aTuple2); |
690 | assertTrue (aTuple3 == aTuple2); |
691 | aTuple = aTuple2; |
692 | assertTrue (aTuple == aTuple2); |
693 | aTuple2.get<1>()++; |
694 | assertTrue (aTuple < aTuple2); |
695 | } |
696 | |
697 | |
698 | void TuplesTest::testTuple30() |
699 | { |
700 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
701 | std::string, int, bool, float, char, long, double, short, std::string, int, |
702 | std::string, int, bool, float, char, long, double, short, std::string, int> TupleType; |
703 | |
704 | TupleType aTuple; |
705 | assertTrue (aTuple.length == 30); |
706 | |
707 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
708 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
709 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" , 6); |
710 | assertTrue (aTuple != aTuple2); |
711 | TupleType aTuple3(aTuple2); |
712 | assertTrue (aTuple3 == aTuple2); |
713 | aTuple = aTuple2; |
714 | assertTrue (aTuple == aTuple2); |
715 | aTuple2.get<1>()++; |
716 | assertTrue (aTuple < aTuple2); |
717 | } |
718 | |
719 | |
720 | void TuplesTest::testTuple31() |
721 | { |
722 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
723 | std::string, int, bool, float, char, long, double, short, std::string, int, |
724 | std::string, int, bool, float, char, long, double, short, std::string, int, |
725 | std::string> TupleType; |
726 | |
727 | TupleType aTuple; |
728 | assertTrue (aTuple.length == 31); |
729 | |
730 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
731 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
732 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" , 6, |
733 | "7" ); |
734 | assertTrue (aTuple != aTuple2); |
735 | TupleType aTuple3(aTuple2); |
736 | assertTrue (aTuple3 == aTuple2); |
737 | aTuple = aTuple2; |
738 | assertTrue (aTuple == aTuple2); |
739 | aTuple2.get<1>()++; |
740 | assertTrue (aTuple < aTuple2); |
741 | } |
742 | |
743 | |
744 | void TuplesTest::testTuple32() |
745 | { |
746 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
747 | std::string, int, bool, float, char, long, double, short, std::string, int, |
748 | std::string, int, bool, float, char, long, double, short, std::string, int, |
749 | std::string, int> TupleType; |
750 | |
751 | TupleType aTuple; |
752 | assertTrue (aTuple.length == 32); |
753 | |
754 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
755 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
756 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" , 6, |
757 | "7" , 7); |
758 | assertTrue (aTuple != aTuple2); |
759 | TupleType aTuple3(aTuple2); |
760 | assertTrue (aTuple3 == aTuple2); |
761 | aTuple = aTuple2; |
762 | assertTrue (aTuple == aTuple2); |
763 | aTuple2.get<1>()++; |
764 | assertTrue (aTuple < aTuple2); |
765 | } |
766 | |
767 | |
768 | void TuplesTest::testTuple33() |
769 | { |
770 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
771 | std::string, int, bool, float, char, long, double, short, std::string, int, |
772 | std::string, int, bool, float, char, long, double, short, std::string, int, |
773 | std::string, int, bool> TupleType; |
774 | |
775 | TupleType aTuple; |
776 | assertTrue (aTuple.length == 33); |
777 | |
778 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
779 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
780 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" , 6, |
781 | "7" , 7, true); |
782 | assertTrue (aTuple != aTuple2); |
783 | TupleType aTuple3(aTuple2); |
784 | assertTrue (aTuple3 == aTuple2); |
785 | aTuple = aTuple2; |
786 | assertTrue (aTuple == aTuple2); |
787 | aTuple2.get<1>()++; |
788 | assertTrue (aTuple < aTuple2); |
789 | } |
790 | |
791 | |
792 | void TuplesTest::testTuple34() |
793 | { |
794 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
795 | std::string, int, bool, float, char, long, double, short, std::string, int, |
796 | std::string, int, bool, float, char, long, double, short, std::string, int, |
797 | std::string, int, bool, float> TupleType; |
798 | |
799 | TupleType aTuple; |
800 | assertTrue (aTuple.length == 34); |
801 | |
802 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
803 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
804 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" , 6, |
805 | "7" , 7, true, 3.14f); |
806 | assertTrue (aTuple != aTuple2); |
807 | TupleType aTuple3(aTuple2); |
808 | assertTrue (aTuple3 == aTuple2); |
809 | aTuple = aTuple2; |
810 | assertTrue (aTuple == aTuple2); |
811 | aTuple2.get<1>()++; |
812 | assertTrue (aTuple < aTuple2); |
813 | } |
814 | |
815 | |
816 | void TuplesTest::testTuple35() |
817 | { |
818 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
819 | std::string, int, bool, float, char, long, double, short, std::string, int, |
820 | std::string, int, bool, float, char, long, double, short, std::string, int, |
821 | std::string, int, bool, float, char> TupleType; |
822 | |
823 | TupleType aTuple; |
824 | assertTrue (aTuple.length == 35); |
825 | |
826 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
827 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
828 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" , 6, |
829 | "7" , 7, true, 3.14f, 'd'); |
830 | assertTrue (aTuple != aTuple2); |
831 | TupleType aTuple3(aTuple2); |
832 | assertTrue (aTuple3 == aTuple2); |
833 | aTuple = aTuple2; |
834 | assertTrue (aTuple == aTuple2); |
835 | aTuple2.get<1>()++; |
836 | assertTrue (aTuple < aTuple2); |
837 | } |
838 | |
839 | |
840 | void TuplesTest::testTuple36() |
841 | { |
842 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
843 | std::string, int, bool, float, char, long, double, short, std::string, int, |
844 | std::string, int, bool, float, char, long, double, short, std::string, int, |
845 | std::string, int, bool, float, char, long> TupleType; |
846 | |
847 | TupleType aTuple; |
848 | assertTrue (aTuple.length == 36); |
849 | |
850 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
851 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
852 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" , 6, |
853 | "7" , 7, true, 3.14f, 'd', 999); |
854 | assertTrue (aTuple != aTuple2); |
855 | TupleType aTuple3(aTuple2); |
856 | assertTrue (aTuple3 == aTuple2); |
857 | aTuple = aTuple2; |
858 | assertTrue (aTuple == aTuple2); |
859 | aTuple2.get<1>()++; |
860 | assertTrue (aTuple < aTuple2); |
861 | } |
862 | |
863 | |
864 | void TuplesTest::testTuple37() |
865 | { |
866 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
867 | std::string, int, bool, float, char, long, double, short, std::string, int, |
868 | std::string, int, bool, float, char, long, double, short, std::string, int, |
869 | std::string, int, bool, float, char, long, double> TupleType; |
870 | |
871 | TupleType aTuple; |
872 | assertTrue (aTuple.length == 37); |
873 | |
874 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
875 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
876 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" , 6, |
877 | "7" , 7, true, 3.14f, 'd', 999, 33.14); |
878 | assertTrue (aTuple != aTuple2); |
879 | TupleType aTuple3(aTuple2); |
880 | assertTrue (aTuple3 == aTuple2); |
881 | aTuple = aTuple2; |
882 | assertTrue (aTuple == aTuple2); |
883 | aTuple2.get<1>()++; |
884 | assertTrue (aTuple < aTuple2); |
885 | } |
886 | |
887 | |
888 | void TuplesTest::testTuple38() |
889 | { |
890 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
891 | std::string, int, bool, float, char, long, double, short, std::string, int, |
892 | std::string, int, bool, float, char, long, double, short, std::string, int, |
893 | std::string, int, bool, float, char, long, double, short> TupleType; |
894 | |
895 | TupleType aTuple; |
896 | assertTrue (aTuple.length == 38); |
897 | |
898 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
899 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
900 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" , 6, |
901 | "7" , 7, true, 3.14f, 'd', 999, 33.14, 32700); |
902 | assertTrue (aTuple != aTuple2); |
903 | TupleType aTuple3(aTuple2); |
904 | assertTrue (aTuple3 == aTuple2); |
905 | aTuple = aTuple2; |
906 | assertTrue (aTuple == aTuple2); |
907 | aTuple2.get<1>()++; |
908 | assertTrue (aTuple < aTuple2); |
909 | } |
910 | |
911 | |
912 | void TuplesTest::testTuple39() |
913 | { |
914 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
915 | std::string, int, bool, float, char, long, double, short, std::string, int, |
916 | std::string, int, bool, float, char, long, double, short, std::string, int, |
917 | std::string, int, bool, float, char, long, double, short, std::string> TupleType; |
918 | |
919 | TupleType aTuple; |
920 | assertTrue (aTuple.length == 39); |
921 | |
922 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
923 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
924 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" , 6, |
925 | "7" , 7, true, 3.14f, 'd', 999, 33.14, 32700, "8" ); |
926 | assertTrue (aTuple != aTuple2); |
927 | TupleType aTuple3(aTuple2); |
928 | assertTrue (aTuple3 == aTuple2); |
929 | aTuple = aTuple2; |
930 | assertTrue (aTuple == aTuple2); |
931 | aTuple2.get<1>()++; |
932 | assertTrue (aTuple < aTuple2); |
933 | } |
934 | |
935 | |
936 | void TuplesTest::testTuple40() |
937 | { |
938 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
939 | std::string, int, bool, float, char, long, double, short, std::string, int, |
940 | std::string, int, bool, float, char, long, double, short, std::string, int, |
941 | std::string, int, bool, float, char, long, double, short, std::string, int> TupleType; |
942 | |
943 | TupleType aTuple; |
944 | assertTrue (aTuple.length == 40); |
945 | |
946 | assertTrue (aTuple.get<0>() == "" ); |
947 | assertTrue (aTuple.get<1>() == 0); |
948 | assertTrue (aTuple.get<2>() == false); |
949 | assertTrue (aTuple.get<4>() == 0); |
950 | assertTrue (aTuple.get<5>() == 0); |
951 | assertTrue (aTuple.get<7>() == 0); |
952 | assertTrue (aTuple.get<8>() == "" ); |
953 | assertTrue (aTuple.get<9>() == 0); |
954 | |
955 | assertTrue (aTuple.get<10>() == "" ); |
956 | assertTrue (aTuple.get<11>() == 0); |
957 | assertTrue (aTuple.get<12>() == false); |
958 | assertTrue (aTuple.get<14>() == 0); |
959 | assertTrue (aTuple.get<15>() == 0); |
960 | assertTrue (aTuple.get<17>() == 0); |
961 | assertTrue (aTuple.get<18>() == "" ); |
962 | assertTrue (aTuple.get<19>() == 0); |
963 | |
964 | assertTrue (aTuple.get<20>() == "" ); |
965 | assertTrue (aTuple.get<21>() == 0); |
966 | assertTrue (aTuple.get<22>() == false); |
967 | assertTrue (aTuple.get<24>() == 0); |
968 | assertTrue (aTuple.get<25>() == 0); |
969 | assertTrue (aTuple.get<27>() == 0); |
970 | assertTrue (aTuple.get<28>() == "" ); |
971 | assertTrue (aTuple.get<29>() == 0); |
972 | |
973 | assertTrue (aTuple.get<30>() == "" ); |
974 | assertTrue (aTuple.get<31>() == 0); |
975 | assertTrue (aTuple.get<32>() == false); |
976 | assertTrue (aTuple.get<34>() == 0); |
977 | assertTrue (aTuple.get<35>() == 0); |
978 | assertTrue (aTuple.get<37>() == 0); |
979 | assertTrue (aTuple.get<38>() == "" ); |
980 | assertTrue (aTuple.get<39>() == 0); |
981 | |
982 | |
983 | TupleType aTuple2("1" , 1, true, 3.14f, 'a', 999, 33.14, 32700, "2" , 2, |
984 | "3" , 3, true, 3.14f, 'b', 999, 33.14, 32700, "4" , 4, |
985 | "5" , 5, true, 3.14f, 'c', 999, 33.14, 32700, "6" , 6, |
986 | "7" , 7, true, 3.14f, 'd', 999, 33.14, 32700, "8" , 8); |
987 | |
988 | assertTrue (aTuple2.get<0>() == "1" ); |
989 | assertTrue (aTuple2.get<1>() == 1); |
990 | assertTrue (aTuple2.get<2>() == true); |
991 | assertTrue (aTuple2.get<4>() == 'a'); |
992 | assertTrue (aTuple2.get<5>() == 999); |
993 | assertTrue (aTuple2.get<7>() == 32700); |
994 | assertTrue (aTuple2.get<8>() == "2" ); |
995 | assertTrue (aTuple2.get<9>() == 2); |
996 | |
997 | assertTrue (aTuple2.get<10>() == "3" ); |
998 | assertTrue (aTuple2.get<11>() == 3); |
999 | assertTrue (aTuple2.get<12>() == true); |
1000 | assertTrue (aTuple2.get<14>() == 'b'); |
1001 | assertTrue (aTuple2.get<15>() == 999); |
1002 | assertTrue (aTuple2.get<17>() == 32700); |
1003 | assertTrue (aTuple2.get<18>() == "4" ); |
1004 | assertTrue (aTuple2.get<19>() == 4); |
1005 | |
1006 | assertTrue (aTuple2.get<20>() == "5" ); |
1007 | assertTrue (aTuple2.get<21>() == 5); |
1008 | assertTrue (aTuple2.get<22>() == true); |
1009 | assertTrue (aTuple2.get<24>() == 'c'); |
1010 | assertTrue (aTuple2.get<25>() == 999); |
1011 | assertTrue (aTuple2.get<27>() == 32700); |
1012 | assertTrue (aTuple2.get<28>() == "6" ); |
1013 | assertTrue (aTuple2.get<29>() == 6); |
1014 | |
1015 | assertTrue (aTuple2.get<30>() == "7" ); |
1016 | assertTrue (aTuple2.get<31>() == 7); |
1017 | assertTrue (aTuple2.get<32>() == true); |
1018 | assertTrue (aTuple2.get<34>() == 'd'); |
1019 | assertTrue (aTuple2.get<35>() == 999); |
1020 | assertTrue (aTuple2.get<37>() == 32700); |
1021 | assertTrue (aTuple2.get<38>() == "8" ); |
1022 | assertTrue (aTuple2.get<39>() == 8); |
1023 | |
1024 | assertTrue (aTuple != aTuple2); |
1025 | TupleType aTuple3(aTuple2); |
1026 | assertTrue (aTuple3.get<0>() == "1" ); |
1027 | assertTrue (aTuple3.get<1>() == 1); |
1028 | assertTrue (aTuple3.get<2>() == true); |
1029 | assertTrue (aTuple3.get<4>() == 'a'); |
1030 | assertTrue (aTuple3.get<5>() == 999); |
1031 | assertTrue (aTuple3.get<7>() == 32700); |
1032 | assertTrue (aTuple3.get<8>() == "2" ); |
1033 | assertTrue (aTuple3.get<9>() == 2); |
1034 | |
1035 | assertTrue (aTuple3.get<10>() == "3" ); |
1036 | assertTrue (aTuple3.get<11>() == 3); |
1037 | assertTrue (aTuple3.get<12>() == true); |
1038 | assertTrue (aTuple3.get<14>() == 'b'); |
1039 | assertTrue (aTuple3.get<15>() == 999); |
1040 | assertTrue (aTuple3.get<17>() == 32700); |
1041 | assertTrue (aTuple3.get<18>() == "4" ); |
1042 | assertTrue (aTuple3.get<19>() == 4); |
1043 | |
1044 | assertTrue (aTuple3.get<20>() == "5" ); |
1045 | assertTrue (aTuple3.get<21>() == 5); |
1046 | assertTrue (aTuple3.get<22>() == true); |
1047 | assertTrue (aTuple3.get<24>() == 'c'); |
1048 | assertTrue (aTuple3.get<25>() == 999); |
1049 | assertTrue (aTuple3.get<27>() == 32700); |
1050 | assertTrue (aTuple3.get<28>() == "6" ); |
1051 | assertTrue (aTuple3.get<29>() == 6); |
1052 | |
1053 | assertTrue (aTuple3.get<30>() == "7" ); |
1054 | assertTrue (aTuple3.get<31>() == 7); |
1055 | assertTrue (aTuple3.get<32>() == true); |
1056 | assertTrue (aTuple3.get<34>() == 'd'); |
1057 | assertTrue (aTuple3.get<35>() == 999); |
1058 | assertTrue (aTuple3.get<37>() == 32700); |
1059 | assertTrue (aTuple3.get<38>() == "8" ); |
1060 | assertTrue (aTuple3.get<39>() == 8); |
1061 | assertTrue (aTuple3 == aTuple2); |
1062 | |
1063 | aTuple = aTuple2; |
1064 | assertTrue (aTuple.get<0>() == "1" ); |
1065 | assertTrue (aTuple.get<1>() == 1); |
1066 | assertTrue (aTuple.get<2>() == true); |
1067 | assertTrue (aTuple.get<4>() == 'a'); |
1068 | assertTrue (aTuple.get<5>() == 999); |
1069 | assertTrue (aTuple.get<7>() == 32700); |
1070 | assertTrue (aTuple.get<8>() == "2" ); |
1071 | assertTrue (aTuple.get<9>() == 2); |
1072 | |
1073 | assertTrue (aTuple.get<10>() == "3" ); |
1074 | assertTrue (aTuple.get<11>() == 3); |
1075 | assertTrue (aTuple.get<12>() == true); |
1076 | assertTrue (aTuple.get<14>() == 'b'); |
1077 | assertTrue (aTuple.get<15>() == 999); |
1078 | assertTrue (aTuple.get<17>() == 32700); |
1079 | assertTrue (aTuple.get<18>() == "4" ); |
1080 | assertTrue (aTuple.get<19>() == 4); |
1081 | |
1082 | assertTrue (aTuple.get<20>() == "5" ); |
1083 | assertTrue (aTuple.get<21>() == 5); |
1084 | assertTrue (aTuple.get<22>() == true); |
1085 | assertTrue (aTuple.get<24>() == 'c'); |
1086 | assertTrue (aTuple.get<25>() == 999); |
1087 | assertTrue (aTuple.get<27>() == 32700); |
1088 | assertTrue (aTuple.get<28>() == "6" ); |
1089 | assertTrue (aTuple.get<29>() == 6); |
1090 | |
1091 | assertTrue (aTuple.get<30>() == "7" ); |
1092 | assertTrue (aTuple.get<31>() == 7); |
1093 | assertTrue (aTuple.get<32>() == true); |
1094 | assertTrue (aTuple.get<34>() == 'd'); |
1095 | assertTrue (aTuple.get<35>() == 999); |
1096 | assertTrue (aTuple.get<37>() == 32700); |
1097 | assertTrue (aTuple.get<38>() == "8" ); |
1098 | assertTrue (aTuple.get<39>() == 8); |
1099 | assertTrue (aTuple == aTuple2); |
1100 | aTuple2.get<1>()++; |
1101 | assertTrue (aTuple < aTuple2); |
1102 | } |
1103 | |
1104 | |
1105 | void TuplesTest::testTupleOrder() |
1106 | { |
1107 | typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int, |
1108 | std::string, int, bool, float, char, long, double, short, std::string, int> TupleType; |
1109 | |
1110 | TupleType aTuple; |
1111 | assertTrue (aTuple.length == 20); |
1112 | |
1113 | TupleType aTuple2("1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2, "1" , 1, true, 3.14f, 'c', 999, 33.14, 32700, "2" , 2); |
1114 | assertTrue (aTuple != aTuple2); |
1115 | aTuple = aTuple2; |
1116 | assertTrue (aTuple == aTuple2); |
1117 | aTuple2.get<1>()++; |
1118 | assertTrue (aTuple < aTuple2); |
1119 | |
1120 | TupleType aTuple3; |
1121 | aTuple3 = aTuple2; |
1122 | aTuple3.get<1>()++; |
1123 | assertTrue (aTuple2 < aTuple3); |
1124 | |
1125 | testTupleStrictWeak(aTuple, aTuple2, aTuple3); |
1126 | |
1127 | std::vector<TupleType> tv; |
1128 | tv.push_back(aTuple3); |
1129 | tv.push_back(aTuple); |
1130 | tv.push_back(aTuple2); |
1131 | |
1132 | assertTrue (tv[0] == aTuple3); |
1133 | assertTrue (tv[1] == aTuple); |
1134 | assertTrue (tv[2] == aTuple2); |
1135 | |
1136 | std::sort(tv.begin(), tv.end()); |
1137 | |
1138 | assertTrue (tv[0] == aTuple); |
1139 | assertTrue (tv[1] == aTuple2); |
1140 | assertTrue (tv[2] == aTuple3); |
1141 | |
1142 | std::map<TupleType, int> tm; |
1143 | std::pair<std::map<TupleType, int>::iterator, bool> mIt = tm.insert(std::map<TupleType, int>::value_type(aTuple2, 2)); |
1144 | assertTrue (mIt.second); |
1145 | mIt = tm.insert(std::map<TupleType, int>::value_type(aTuple, 1)); |
1146 | assertTrue (mIt.second); |
1147 | mIt = tm.insert(std::map<TupleType, int>::value_type(aTuple3, 3)); |
1148 | assertTrue (mIt.second); |
1149 | |
1150 | std::map<TupleType, int>::iterator fIt = tm.find(aTuple2); |
1151 | assertTrue (2 == fIt->second); |
1152 | |
1153 | typedef Tuple<std::string, std::string, std::string, std::string> StrTup; |
1154 | typedef std::map<StrTup, int> StrTupMap; |
1155 | |
1156 | StrTup st1("123" , "456" , "789" , "101112" ); |
1157 | StrTup st2("123" , "456" , "101112" , "789" ); |
1158 | StrTup st3("123" , "789" , "789" , "101112" ); |
1159 | StrTup st4("123" , "101112" , "456" , "789" ); |
1160 | |
1161 | testTupleStrictWeak(st2, st1, st3); |
1162 | |
1163 | StrTupMap strMap; |
1164 | strMap.insert(StrTupMap::value_type(st1, 1)); |
1165 | strMap.insert(StrTupMap::value_type(st2, 2)); |
1166 | strMap.insert(StrTupMap::value_type(st3, 3)); |
1167 | strMap.insert(StrTupMap::value_type(st4, 4)); |
1168 | |
1169 | assertTrue (1 == strMap[st1]); |
1170 | assertTrue (2 == strMap[st2]); |
1171 | assertTrue (3 == strMap[st3]); |
1172 | assertTrue (4 == strMap[st4]); |
1173 | |
1174 | StrTupMap::iterator it = strMap.begin(); |
1175 | assertTrue (st4 == it->first); ++it; |
1176 | assertTrue (st2 == it->first); ++it; |
1177 | assertTrue (st1 == it->first); ++it; |
1178 | assertTrue (st3 == it->first); ++it; |
1179 | assertTrue (it == strMap.end()); |
1180 | } |
1181 | |
1182 | |
1183 | void TuplesTest::testTupleNullable() |
1184 | { |
1185 | typedef Poco::Tuple<Nullable<Poco::Int32>, Nullable<std::string> , Nullable<NonDefaultConstructible>> Info; |
1186 | Info info(0, std::string("Address" ), Nullable<NonDefaultConstructible>(10)); |
1187 | assertTrue (info.get<0>() == 0); |
1188 | assertTrue (info.get<1>() == "Address" ); |
1189 | assertTrue (info.get<2>() == NonDefaultConstructible(10)); |
1190 | } |
1191 | |
1192 | |
1193 | void TuplesTest::testMemOverhead() |
1194 | { |
1195 | Tuple<short> smallOne(0); |
1196 | int sz = sizeof(smallOne); |
1197 | assertTrue (sz == 4 || sz == 8); //depending on architecture and alignment |
1198 | Tuple<long> notSoSmall(0); |
1199 | sz = sizeof(notSoSmall); |
1200 | assertTrue (sz == 8 || sz == 16); //depending on architecture and alignment |
1201 | } |
1202 | |
1203 | |
1204 | void TuplesTest::setUp() |
1205 | { |
1206 | } |
1207 | |
1208 | |
1209 | void TuplesTest::tearDown() |
1210 | { |
1211 | } |
1212 | |
1213 | |
1214 | CppUnit::Test* TuplesTest::suite() |
1215 | { |
1216 | CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TuplesTest" ); |
1217 | |
1218 | CppUnit_addTest(pSuite, TuplesTest, testTuple1); |
1219 | CppUnit_addTest(pSuite, TuplesTest, testTuple2); |
1220 | CppUnit_addTest(pSuite, TuplesTest, testTuple3); |
1221 | CppUnit_addTest(pSuite, TuplesTest, testTuple4); |
1222 | CppUnit_addTest(pSuite, TuplesTest, testTuple5); |
1223 | CppUnit_addTest(pSuite, TuplesTest, testTuple6); |
1224 | CppUnit_addTest(pSuite, TuplesTest, testTuple7); |
1225 | CppUnit_addTest(pSuite, TuplesTest, testTuple8); |
1226 | CppUnit_addTest(pSuite, TuplesTest, testTuple9); |
1227 | CppUnit_addTest(pSuite, TuplesTest, testTuple10); |
1228 | CppUnit_addTest(pSuite, TuplesTest, testTuple11); |
1229 | CppUnit_addTest(pSuite, TuplesTest, testTuple12); |
1230 | CppUnit_addTest(pSuite, TuplesTest, testTuple13); |
1231 | CppUnit_addTest(pSuite, TuplesTest, testTuple14); |
1232 | CppUnit_addTest(pSuite, TuplesTest, testTuple15); |
1233 | CppUnit_addTest(pSuite, TuplesTest, testTuple16); |
1234 | CppUnit_addTest(pSuite, TuplesTest, testTuple17); |
1235 | CppUnit_addTest(pSuite, TuplesTest, testTuple18); |
1236 | CppUnit_addTest(pSuite, TuplesTest, testTuple19); |
1237 | CppUnit_addTest(pSuite, TuplesTest, testTuple20); |
1238 | CppUnit_addTest(pSuite, TuplesTest, testTuple21); |
1239 | CppUnit_addTest(pSuite, TuplesTest, testTuple22); |
1240 | CppUnit_addTest(pSuite, TuplesTest, testTuple23); |
1241 | CppUnit_addTest(pSuite, TuplesTest, testTuple24); |
1242 | CppUnit_addTest(pSuite, TuplesTest, testTuple25); |
1243 | CppUnit_addTest(pSuite, TuplesTest, testTuple26); |
1244 | CppUnit_addTest(pSuite, TuplesTest, testTuple27); |
1245 | CppUnit_addTest(pSuite, TuplesTest, testTuple28); |
1246 | CppUnit_addTest(pSuite, TuplesTest, testTuple29); |
1247 | CppUnit_addTest(pSuite, TuplesTest, testTuple30); |
1248 | CppUnit_addTest(pSuite, TuplesTest, testTuple31); |
1249 | CppUnit_addTest(pSuite, TuplesTest, testTuple32); |
1250 | CppUnit_addTest(pSuite, TuplesTest, testTuple33); |
1251 | CppUnit_addTest(pSuite, TuplesTest, testTuple34); |
1252 | CppUnit_addTest(pSuite, TuplesTest, testTuple35); |
1253 | CppUnit_addTest(pSuite, TuplesTest, testTuple36); |
1254 | CppUnit_addTest(pSuite, TuplesTest, testTuple37); |
1255 | CppUnit_addTest(pSuite, TuplesTest, testTuple38); |
1256 | CppUnit_addTest(pSuite, TuplesTest, testTuple39); |
1257 | CppUnit_addTest(pSuite, TuplesTest, testTuple40); |
1258 | CppUnit_addTest(pSuite, TuplesTest, testTupleOrder); |
1259 | CppUnit_addTest(pSuite, TuplesTest, testTupleNullable); |
1260 | CppUnit_addTest(pSuite, TuplesTest, testMemOverhead); |
1261 | |
1262 | return pSuite; |
1263 | } |
1264 | |