ReactOS 0.4.16-dev-340-g0540c21
mvctor_traits_test.cpp
Go to the documentation of this file.
1#include <vector>
2#include <deque>
3
4#include "mvctor_test.h"
5
6#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
7using namespace std;
8#endif
9
15
16#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
17# if defined (_STLP_USE_NAMESPACES)
18namespace std {
19# endif
22 typedef __true_type implemented;
23 typedef __false_type complete;
24 };
25# if defined (_STLP_USE_NAMESPACES)
26}
27# endif
28#endif
29
33#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
35#endif
37
40 return *this;
41 }
42 static void reset() {
46 }
47
48 static size_t nb_dft_construct_call;
49 static size_t nb_cpy_construct_call;
50 static size_t nb_mv_construct_call;
51 static size_t nb_assignment_call;
52 static size_t nb_destruct_call;
53
54 //See MovableStruct
55 void* dummy_data[2];
56};
57
63
64#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
65# if defined (_STLP_USE_NAMESPACES)
66namespace std {
67# endif
70 typedef __true_type implemented;
71 typedef __true_type complete;
72 };
73# if defined (_STLP_USE_NAMESPACES)
74}
75# endif
76#endif
77
79{
84}
85
87{
88 {
89 {
90 vector<MovableStruct> vect;
91 vect.push_back(MovableStruct());
92 vect.push_back(MovableStruct());
93 vect.push_back(MovableStruct());
94 vect.push_back(MovableStruct());
95
96 // vect contains 4 elements
98#if defined (STLPORT)
99# if !defined (_STLP_NO_MOVE_SEMANTIC)
102# else
104# endif
106#elif !defined (_MSC_VER)
109#else
112#endif
114
115 // Following test violate requirements to sequiences (23.1.1 Table 67)
116 /*
117 vect.insert(vect.begin() + 2, vect.begin(), vect.end());
118 // vect contains 8 elements
119 CPPUNIT_ASSERT( MovableStruct::nb_dft_construct_call == 4 );
120 CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 8 );
121 CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 7 );
122 CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 11 );
123 */
124
126 vector<MovableStruct> v2 = vect;
132
134 vect.insert(vect.begin() + 2, v2.begin(), v2.end() );
135
136 // vect contains 8 elements
138#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
141#else
143#endif
146
148 vect.erase(vect.begin(), vect.begin() + 2 );
149
150 // vect contains 6 elements
151#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
154#else
157#endif
158
160 vect.erase(vect.end() - 2, vect.end());
161
162 // vect contains 4 elements
165
167 vect.erase(vect.begin());
168
169 // vect contains 3 elements
170#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
173#else
176#endif
177
179 }
180 //vect with 3 elements and v2 with 4 elements are now out of scope
182 }
183}
184
186{
187 {
188 {
189 vector<CompleteMovableStruct> vect;
190 vect.push_back(CompleteMovableStruct());
191 vect.push_back(CompleteMovableStruct());
192 vect.push_back(CompleteMovableStruct());
193 vect.push_back(CompleteMovableStruct());
194
195 // vect contains 4 elements
197#if defined (STLPORT)
198# if !defined (_STLP_NO_MOVE_SEMANTIC)
202# else
205# endif
206#elif !defined (_MSC_VER)
209#else
212#endif
213
214 // Following test violate requirements to sequiences (23.1.1 Table 67)
215 /*
216 vect.insert(vect.begin() + 2, vect.begin(), vect.end());
217
218 // vect contains 8 elements
219 CPPUNIT_ASSERT( CompleteMovableStruct::nb_dft_construct_call == 4 );
220 CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 8 );
221 CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 7 );
222 CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 4 );
223 */
224
226 vector<CompleteMovableStruct> v2 = vect;
227
232
234 vect.insert(vect.begin() + 2, v2.begin(), v2.end());
235
236 // vect contains 8 elements
238#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
242#else
245#endif
246
248 vect.erase(vect.begin(), vect.begin() + 2);
249
250 // vect contains 6 elements
251#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
253#else
255#endif
257
259 vect.erase(vect.end() - 2, vect.end());
260
261 // vect contains 4 elements
264
266 vect.erase(vect.begin());
267
268 // vect contains 3 elements
269#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
271#else
273#endif
275
277 }
278 //vect with 3 elements and v2 with 4 elements are now out of scope
280 }
281}
282
284{
285 {
287 {
293
294 // deq contains 4 elements
299
300 // Following test violate requirements to sequiences (23.1.1 Table 67)
301 /*
302 deq.insert(deq.begin() + 2, deq.begin(), deq.end());
303 // deq contains 8 elements
304 CPPUNIT_ASSERT( MovableStruct::nb_dft_construct_call == 4 );
305 CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 8 );
306 CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 7 );
307 CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 11 );
308 */
309
311 deque<MovableStruct> d2 = deq;
312
317
319 deq.insert(deq.begin() + 2, d2.begin(), d2.end() );
320
321 // deq contains 8 elements
324#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
327#else
330#endif
331
333 deq.erase(deq.begin() + 1, deq.begin() + 3 );
334
335 // deq contains 6 elements
336#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
339#else
340 //Following check is highly deque implementation dependant so
341 //it might not always work...
344#endif
345
347 deq.erase(deq.end() - 3, deq.end() - 1);
348
349 // deq contains 4 elements
350#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
353#else
356#endif
357
359 deq.erase(deq.begin());
360
361 // deq contains 3 elements
362#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
364#else
366#endif
368
370 }
371 //deq with 3 elements and d2 with 4 elements are now out of scope
373 }
374}
375
377{
378 {
380 {
386
387 // deq contains 4 elements
392
393 // Following test violate requirements to sequiences (23.1.1 Table 67)
394 /*
395 deq.insert(deq.begin() + 2, deq.begin(), deq.end());
396
397 // deq contains 8 elements
398 CPPUNIT_ASSERT( CompleteMovableStruct::nb_dft_construct_call == 4 );
399 CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 8 );
400 CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 7 );
401 CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 4 );
402 */
403
406
411
413 deq.insert(deq.begin() + 2, d2.begin(), d2.end());
414
415 // deq contains 8 elements
418#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
420#else
422#endif
424
426 deq.erase(deq.begin() + 1, deq.begin() + 3);
427
428 // deq contains 6 elements
429#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
431#else
433#endif
435
437 deq.erase(deq.end() - 3, deq.end() - 1);
438
439 // deq contains 4 elements
440#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
442#else
444#endif
446
448 deq.erase(deq.begin());
449
450 // deq contains 3 elements
454
456 }
457 //deq with 3 elements and v2 with 4 elements are now out of scope
459 }
460}
Definition: _deque.h:404
iterator erase(iterator __pos)
Definition: _deque.h:835
iterator insert(iterator __pos, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _deque.h:730
iterator end()
Definition: _deque.h:433
void push_back(const value_type &__t=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _deque.h:668
iterator begin()
Definition: _deque.h:432
#define CPPUNIT_ASSERT_EQUAL(X, Y)
Definition: cppunit_mini.h:211
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
#define _STLP_TEMPLATE_NULL
Definition: features.h:652
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
static BOOL complete
Definition: htmldoc.c:198
Definition: features.h:417
static size_t nb_mv_construct_call
static size_t nb_assignment_call
static size_t nb_cpy_construct_call
CompleteMovableStruct(CompleteMovableStruct const &)
CompleteMovableStruct & operator=(const CompleteMovableStruct &)
static size_t nb_dft_construct_call
static void reset()
Definition: mvctor_test.h:80
static size_t nb_dft_construct_call
Definition: mvctor_test.h:86
static size_t nb_mv_construct_call
Definition: mvctor_test.h:88
static size_t nb_cpy_construct_call
Definition: mvctor_test.h:87
static size_t nb_destruct_call
Definition: mvctor_test.h:90
static size_t nb_assignment_call
Definition: mvctor_test.h:89