ReactOS  0.4.15-dev-3723-g8d70159
MoveConstructorTest Class Reference

#include <mvctor_test.h>

Inheritance diagram for MoveConstructorTest:
Collaboration diagram for MoveConstructorTest:

Protected Member Functions

void move_construct_test ()
 
void deque_test ()
 
void vector_test ()
 
void move_traits ()
 
void movable_declaration ()
 
void movable_declaration_assoc ()
 
void movable_declaration_hash ()
 
void nb_destructor_calls ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (MoveConstructorTest)
 
 CPPUNIT_TEST (move_construct_test)
 
 CPPUNIT_TEST (deque_test)
 
 CPPUNIT_TEST (vector_test)
 
 CPPUNIT_TEST (move_traits)
 
 CPPUNIT_TEST_SUITE_END ()
 
void move_traits_vec ()
 
void move_traits_vec_complete ()
 
void move_traits_deq ()
 
void move_traits_deq_complete ()
 

Private Attributes

 CPPUNIT_IGNORE
 

Detailed Description

Definition at line 8 of file mvctor_test.h.

Member Function Documentation

◆ CPPUNIT_TEST() [1/4]

MoveConstructorTest::CPPUNIT_TEST ( move_construct_test  )
private

◆ CPPUNIT_TEST() [2/4]

MoveConstructorTest::CPPUNIT_TEST ( deque_test  )
private

◆ CPPUNIT_TEST() [3/4]

MoveConstructorTest::CPPUNIT_TEST ( vector_test  )
private

◆ CPPUNIT_TEST() [4/4]

MoveConstructorTest::CPPUNIT_TEST ( move_traits  )
private

◆ CPPUNIT_TEST_SUITE()

MoveConstructorTest::CPPUNIT_TEST_SUITE ( MoveConstructorTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

MoveConstructorTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ deque_test()

void MoveConstructorTest::deque_test ( )
protected

Definition at line 172 of file mvctor_test.cpp.

173 {
174  //Check the insert range method.
175  //To the front:
176  {
177 # if !defined (STLPORT) || !defined (_STLP_DEBUG) || !defined (_STLP_NO_MEMBER_TEMPLATES)
178  deque<vector<int> > vect_deque;
179  vector<int*> bufs;
180  vect_deque.assign(3, vector<int>(10));
181  bufs.push_back(&vect_deque[0].front());
182  bufs.push_back(&vect_deque[1].front());
183  bufs.push_back(&vect_deque[2].front());
184 
185  int nb_insert = 5;
186  //Initialize to 1 to generate a front insertion:
187  int pos = 1;
188  while (nb_insert--) {
189  vector<vector<int> > vect_vect(2, vector<int>(10));
190  vect_deque.insert(vect_deque.begin() + pos, vect_vect.begin(), vect_vect.end());
191  bufs.insert(bufs.begin() + pos, &vect_deque[pos].front());
192  bufs.insert(bufs.begin() + pos + 1, &vect_deque[pos + 1].front());
193  ++pos;
194  }
195  CPPUNIT_ASSERT( vect_deque.size() == 13 );
196 # if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
197  for (int i = 0; i < 5; ++i) {
198  CPPUNIT_ASSERT( bufs[i] == &vect_deque[i].front() );
199  CPPUNIT_ASSERT( bufs[11 - i] == &vect_deque[11 - i].front() );
200  }
201 # endif
202 # endif
203  }
204 
205  //To the back
206  {
207 # if !defined (STLPORT) || !defined (_STLP_DEBUG) || !defined (_STLP_NO_MEMBER_TEMPLATES)
208  deque<vector<int> > vect_deque;
209  vector<int*> bufs;
210  vect_deque.assign(3, vector<int>(10));
211  bufs.push_back(&vect_deque[0].front());
212  bufs.push_back(&vect_deque[1].front());
213  bufs.push_back(&vect_deque[2].front());
214 
215  int nb_insert = 5;
216  //Initialize to 2 to generate a back insertion:
217  int pos = 2;
218  while (nb_insert--) {
219  vector<vector<int> > vect_vect(2, vector<int>(10));
220  vect_deque.insert(vect_deque.begin() + pos, vect_vect.begin(), vect_vect.end());
221  bufs.insert(bufs.begin() + pos, &vect_deque[pos].front());
222  bufs.insert(bufs.begin() + pos + 1, &vect_deque[pos + 1].front());
223  ++pos;
224  }
225  CPPUNIT_ASSERT( vect_deque.size() == 13 );
226 # if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
227  for (int i = 0; i < 5; ++i) {
228  CPPUNIT_ASSERT( bufs[i + 1] == &vect_deque[i + 1].front() );
229  CPPUNIT_ASSERT( bufs[12 - i] == &vect_deque[12 - i].front() );
230  }
231 # endif
232 # endif
233  }
234 
235  //Check the different erase methods.
236  {
237  deque<vector<int> > vect_deque;
238  vect_deque.assign(20, vector<int>(10));
239  deque<vector<int> >::iterator vdit(vect_deque.begin()), vditEnd(vect_deque.end());
240  vector<int*> bufs;
241  for (; vdit != vditEnd; ++vdit) {
242  bufs.push_back(&vdit->front());
243  }
244 
245  {
246  // This check, repeated after each operation, check the deque consistency:
247  deque<vector<int> >::iterator it = vect_deque.end() - 5;
248  int nb_incr = 0;
249  for (; it != vect_deque.end() && nb_incr <= 6; ++nb_incr, ++it) {}
250  CPPUNIT_ASSERT( nb_incr == 5 );
251  }
252 
253  {
254  //erase in front:
255  vect_deque.erase(vect_deque.begin() + 2);
256  bufs.erase(bufs.begin() + 2);
257  CPPUNIT_ASSERT( vect_deque.size() == 19 );
258  deque<vector<int> >::iterator dit(vect_deque.begin()), ditEnd(vect_deque.end());
259 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
260  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
261  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
262  }
263 #endif
264  }
265 
266  {
267  deque<vector<int> >::iterator it = vect_deque.end() - 5;
268  int nb_incr = 0;
269  for (; it != vect_deque.end() && nb_incr <= 6; ++nb_incr, ++it) {}
270  CPPUNIT_ASSERT( nb_incr == 5 );
271  }
272 
273  {
274  //erase in the back:
275  vect_deque.erase(vect_deque.end() - 2);
276  bufs.erase(bufs.end() - 2);
277  CPPUNIT_ASSERT( vect_deque.size() == 18 );
278  deque<vector<int> >::iterator dit(vect_deque.begin()), ditEnd(vect_deque.end());
279 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
280  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
281  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
282  }
283 #endif
284  }
285 
286  {
287  deque<vector<int> >::iterator it = vect_deque.end() - 5;
288  int nb_incr = 0;
289  for (; it != vect_deque.end() && nb_incr < 6; ++nb_incr, ++it) {}
290  CPPUNIT_ASSERT( nb_incr == 5 );
291  }
292 
293  {
294  //range erase in front
295  vect_deque.erase(vect_deque.begin() + 3, vect_deque.begin() + 5);
296  bufs.erase(bufs.begin() + 3, bufs.begin() + 5);
297  CPPUNIT_ASSERT( vect_deque.size() == 16 );
298  deque<vector<int> >::iterator dit(vect_deque.begin()), ditEnd(vect_deque.end());
299 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
300  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
301  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
302  }
303 #endif
304  }
305 
306  {
307  deque<vector<int> >::iterator it = vect_deque.end() - 5;
308  int nb_incr = 0;
309  for (; it != vect_deque.end() && nb_incr <= 6; ++nb_incr, ++it) {}
310  CPPUNIT_ASSERT( nb_incr == 5 );
311  }
312 
313  {
314  //range erase in back
315  vect_deque.erase(vect_deque.end() - 5, vect_deque.end() - 3);
316  bufs.erase(bufs.end() - 5, bufs.end() - 3);
317  CPPUNIT_ASSERT( vect_deque.size() == 14 );
318  deque<vector<int> >::iterator dit(vect_deque.begin()), ditEnd(vect_deque.end());
319 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
320  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
321  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
322  }
323 #endif
324  }
325  }
326 
327  //Check the insert value(s)
328  {
329  deque<vector<int> > vect_deque;
330  vect_deque.assign(20, vector<int>(10));
331  deque<vector<int> >::iterator vdit(vect_deque.begin()), vditEnd(vect_deque.end());
332  vector<int*> bufs;
333  for (; vdit != vditEnd; ++vdit) {
334  bufs.push_back(&vdit->front());
335  }
336 
337  {
338  //2 values in front:
339  vect_deque.insert(vect_deque.begin() + 2, 2, vector<int>(10));
340  bufs.insert(bufs.begin() + 2, &vect_deque[2].front());
341  bufs.insert(bufs.begin() + 3, &vect_deque[3].front());
342  CPPUNIT_ASSERT( vect_deque.size() == 22 );
343  deque<vector<int> >::iterator dit(vect_deque.begin()), ditEnd(vect_deque.end());
344 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
345  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
346  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
347  }
348 #endif
349  }
350 
351  {
352  //2 values in back:
353  vect_deque.insert(vect_deque.end() - 2, 2, vector<int>(10));
354  bufs.insert(bufs.end() - 2, &vect_deque[20].front());
355  bufs.insert(bufs.end() - 2, &vect_deque[21].front());
356  CPPUNIT_ASSERT( vect_deque.size() == 24 );
357 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
358  deque<vector<int> >::iterator dit(vect_deque.begin()), ditEnd(vect_deque.end());
359  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
360  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
361  }
362 #endif
363  }
364 
365  {
366  //1 value in front:
368  ret = vect_deque.insert(vect_deque.begin() + 2, vector<int>(10));
369  bufs.insert(bufs.begin() + 2, &vect_deque[2].front());
370  CPPUNIT_ASSERT( vect_deque.size() == 25 );
371 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
372  CPPUNIT_ASSERT( &ret->front() == bufs[2] );
373  deque<vector<int> >::iterator dit(vect_deque.begin()), ditEnd(vect_deque.end());
374  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
375  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
376  }
377 #endif
378  }
379 
380  {
381  //1 value in back:
383  ret = vect_deque.insert(vect_deque.end() - 2, vector<int>(10));
384  bufs.insert(bufs.end() - 2, &vect_deque[23].front());
385  CPPUNIT_ASSERT( vect_deque.size() == 26 );
386 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
387  CPPUNIT_ASSERT( &ret->front() == bufs[23] );
388  deque<vector<int> >::iterator dit(vect_deque.begin()), ditEnd(vect_deque.end());
389  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
390  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
391  }
392 #endif
393  }
394  }
395 }
reference front()
Definition: _deque.h:458
const GLenum * bufs
Definition: glext.h:6026
iterator end()
Definition: _deque.h:433
iterator begin()
Definition: _deque.h:432
static struct address_cache * front
Definition: rpcb_clnt.c:83
Definition: _deque.h:400
int ret
WDF_CHILD_LIST_ITERATOR iterator
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
void assign(size_type __n, const _Tp &__val)
Definition: _deque.h:598
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
size_type size() const
Definition: _deque.h:471
iterator insert(iterator __pos, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _deque.h:730
iterator erase(iterator __pos)
Definition: _deque.h:835

◆ movable_declaration()

void MoveConstructorTest::movable_declaration ( )
protected

Definition at line 165 of file mvctor_declaration_test.cpp.

166 {
167 #if defined (STLPORT) && !defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) && \
168  !defined (_STLP_NO_MOVE_SEMANTIC)
169  //This test purpose is to check correct detection of the STL movable
170  //traits declaration
171  {
172  //string, wstring:
173  CPPUNIT_ASSERT( is_movable(string()) );
174 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
175  CPPUNIT_ASSERT( is_move_complete(string()) );
176 # else
177  CPPUNIT_ASSERT( !is_move_complete(string()) );
178 # endif
179 # if defined (_STLP_HAS_WCHAR_T)
180  CPPUNIT_ASSERT( is_movable(wstring()) );
181 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
182  CPPUNIT_ASSERT( is_move_complete(wstring()) );
183 # else
184  CPPUNIT_ASSERT( !is_move_complete(wstring()) );
185 # endif
186 # endif
187  }
188 
189 # if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
190  {
191  //crope, wrope:
192  CPPUNIT_ASSERT( is_movable(crope()) );
193 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
194  CPPUNIT_ASSERT( is_move_complete(crope()) );
195 # else
196  CPPUNIT_ASSERT( !is_move_complete(crope()) );
197 # endif
198 # if defined (_STLP_HAS_WCHAR_T)
199  CPPUNIT_ASSERT( is_movable(wrope()) );
200 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
201  CPPUNIT_ASSERT( is_move_complete(wrope()) );
202 # else
203  CPPUNIT_ASSERT( !is_move_complete(wrope()) );
204 # endif
205 # endif
206  }
207 # endif
208 
209  {
210  //vector:
211  CPPUNIT_ASSERT( is_movable(vector<char>()) );
212  CPPUNIT_ASSERT( is_movable(vector<specially_allocated_struct>()) );
213 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
214  CPPUNIT_ASSERT( is_move_complete(vector<char>()) );
215  CPPUNIT_ASSERT( !is_move_complete(vector<specially_allocated_struct>()) );
216 # else
217  CPPUNIT_ASSERT( !is_move_complete(vector<char>()) );
218 # endif
219  }
220 
221  {
222  //deque:
223  CPPUNIT_ASSERT( is_movable(deque<char>()) );
225 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
226  CPPUNIT_ASSERT( is_move_complete(deque<char>()) );
227  CPPUNIT_ASSERT( !is_move_complete(deque<specially_allocated_struct>()) );
228 # else
229  CPPUNIT_ASSERT( !is_move_complete(deque<char>()) );
230 # endif
231  }
232 
233  {
234  //list:
235  CPPUNIT_ASSERT( is_movable(list<char>()) );
236  CPPUNIT_ASSERT( is_movable(list<specially_allocated_struct>()) );
237 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
238  CPPUNIT_ASSERT( is_move_complete(list<char>()) );
239  CPPUNIT_ASSERT( !is_move_complete(list<specially_allocated_struct>()) );
240 # else
241  CPPUNIT_ASSERT( !is_move_complete(list<char>()) );
242 # endif
243  }
244 
245 # if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
246  {
247  //slist:
248  CPPUNIT_ASSERT( is_movable(slist<char>()) );
250 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
251  CPPUNIT_ASSERT( is_move_complete(slist<char>()) );
252  CPPUNIT_ASSERT( !is_move_complete(slist<specially_allocated_struct>()) );
253 # else
254  CPPUNIT_ASSERT( !is_move_complete(slist<char>()) );
255 # endif
256  }
257 # endif
258 
259  {
260  //queue:
261  CPPUNIT_ASSERT( is_movable(queue<char>()) );
263 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
264  CPPUNIT_ASSERT( is_move_complete(queue<char>()) );
265  CPPUNIT_ASSERT( !is_move_complete(queue<specially_allocated_struct>()) );
266 # else
267  CPPUNIT_ASSERT( !is_move_complete(queue<char>()) );
268 # endif
269  }
270 
271  {
272  //stack:
273  CPPUNIT_ASSERT( is_movable(stack<char>()) );
275 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
276  CPPUNIT_ASSERT( is_move_complete(stack<char>()) );
277  CPPUNIT_ASSERT( !is_move_complete(stack<specially_allocated_struct>()) );
278 # else
279  CPPUNIT_ASSERT( !is_move_complete(stack<char>()) );
280 # endif
281  }
282 
283 #endif
284 }
Definition: _slist.h:198
Definition: _queue.h:59
Definition: _stack.h:47
rope< char, allocator< char > > crope
Definition: _rope.h:2297
Definition: _deque.h:400
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200

◆ movable_declaration_assoc()

void MoveConstructorTest::movable_declaration_assoc ( )
protected

Definition at line 286 of file mvctor_declaration_test.cpp.

287 {
288 #if defined (STLPORT) && !defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) && \
289  !defined (_STLP_NO_MOVE_SEMANTIC)
290  {
291  //associative containers, set multiset, map, multimap:
292 
293  //For associative containers it is important that less is correctly recognize as
294  //the STLport less or a user specialized less:
295 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
296  CPPUNIT_ASSERT( is_move_complete(less<char>()) );
297 # endif
298  CPPUNIT_ASSERT( !is_move_complete(less<struct_with_specialized_less>()) );
299 
300  //set
301  CPPUNIT_ASSERT( is_movable(set<char>()) );
303 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
304  CPPUNIT_ASSERT( is_move_complete(set<char>()) );
305  CPPUNIT_ASSERT( !is_move_complete(set<specially_allocated_struct>()) );
306 # else
307  CPPUNIT_ASSERT( !is_move_complete(set<char>()) );
308 # endif
309 
310  //multiset
311  CPPUNIT_ASSERT( is_movable(multiset<char>()) );
313 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
314  CPPUNIT_ASSERT( is_move_complete(multiset<char>()) );
316 # else
317  CPPUNIT_ASSERT( !is_move_complete(multiset<char>()) );
318 # endif
319 
320  //map
321  CPPUNIT_ASSERT( is_movable(map<char, char>()) );
322  CPPUNIT_ASSERT( is_movable(map<specially_allocated_struct, char>()) );
323 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
324  CPPUNIT_ASSERT( is_move_complete(map<char, char>()) );
325  //Here even if allocator has been specialized for specially_allocated_struct
326  //this pecialization won't be used in default map instanciation as the default
327  //allocator is allocator<pair<specially_allocated_struct, char> >
328  CPPUNIT_ASSERT( is_move_complete(map<specially_allocated_struct, char>()) );
329 # else
330  CPPUNIT_ASSERT( !is_move_complete(map<char, char>()) );
331 # endif
332 
333  //multimap
334  CPPUNIT_ASSERT( is_movable(multimap<char, char>()) );
336 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
337  CPPUNIT_ASSERT( is_move_complete(multimap<char, char>()) );
338  //Idem map remark
340 # else
341  CPPUNIT_ASSERT( !is_move_complete(multimap<char, char>()) );
342 # endif
343  }
344 #endif
345 }
Definition: _set.h:216
Definition: _map.h:237
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
Definition: _set.h:46

◆ movable_declaration_hash()

void MoveConstructorTest::movable_declaration_hash ( )
protected

Definition at line 347 of file mvctor_declaration_test.cpp.

348 {
349 #if defined (STLPORT) && !defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) && \
350  !defined (_STLP_NO_MOVE_SEMANTIC)
351  {
352  //hashed containers, unordered_set unordered_multiset, unordered_map, unordered_multimap,
353  // hash_set, hash_multiset, hash_map, hash_multimap:
354 
355  //We only check that they are movable, completness is not yet supported
356  CPPUNIT_ASSERT( is_movable(unordered_set<char>()) );
357  CPPUNIT_ASSERT( is_movable(unordered_multiset<char>()) );
358  CPPUNIT_ASSERT( is_movable(unordered_map<char, char>()) );
360 # if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
361  CPPUNIT_ASSERT( is_movable(hash_set<char>()) );
362  CPPUNIT_ASSERT( is_movable(hash_multiset<char>()) );
363  CPPUNIT_ASSERT( is_movable(hash_map<char, char>()) );
364  CPPUNIT_ASSERT( is_movable(hash_multimap<char, char>()) );
365 # endif
366  }
367 #endif
368 }
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200

◆ move_construct_test()

void MoveConstructorTest::move_construct_test ( )
protected

Definition at line 28 of file mvctor_test.cpp.

29 {
30  //cout << "vector<vector<int>>";
31  vector<int> const ref_vec(10, 0);
32  vector<vector<int> > v_v_ints(1, ref_vec);
33 
34 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
35  int *pint = &(v_v_ints.front().front());
36 #endif
37 
38  size_t cur_capacity = v_v_ints.capacity();
39  while (v_v_ints.capacity() <= cur_capacity) {
40  v_v_ints.push_back(ref_vec);
41  }
42 
43  //v_v_ints has been resized
44 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
45  CPPUNIT_ASSERT((pint == &v_v_ints.front().front()));
46 #endif
47 
48  //cout << "vector<vector<int>>::erase";
49  //We need at least 3 elements:
50  while (v_v_ints.size() < 3) {
51  v_v_ints.push_back(ref_vec);
52  }
53 
54  //We erase the 2nd
55 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
56  pint = &v_v_ints[2].front();
57 #endif
58  v_v_ints.erase(v_v_ints.begin() + 1);
59 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
60  CPPUNIT_ASSERT((pint == &v_v_ints[1].front()));
61 #endif
62 
63  //cout << "vector<string>";
64  string const ref_str("ref string, big enough to be a dynamic one");
65  vector<string> vec_strs(1, ref_str);
66 
67 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
68  char const* pstr = vec_strs.front().c_str();
69 #endif
70  cur_capacity = vec_strs.capacity();
71  while (vec_strs.capacity() <= cur_capacity) {
72  vec_strs.push_back(ref_str);
73  }
74 
75  //vec_str has been resized
76 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
77  CPPUNIT_ASSERT((pstr == vec_strs.front().c_str()));
78 #endif
79 
80  //cout << "vector<string>::erase";
81  //We need at least 3 elements:
82  while (vec_strs.size() < 3) {
83  vec_strs.push_back(ref_str);
84  }
85 
86  //We erase the 2nd
87 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
88  pstr = vec_strs[2].c_str();
89 #endif
90  vec_strs.erase(vec_strs.begin() + 1);
91 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
92  CPPUNIT_ASSERT((pstr == vec_strs[1].c_str()));
93 #endif
94 
95  //cout << "swap(vector<int>, vector<int>)";
96  vector<int> elem1(10, 0), elem2(10, 0);
97 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
98  int *p1 = &elem1.front();
99  int *p2 = &elem2.front();
100 #endif
101  swap(elem1, elem2);
102 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
103  CPPUNIT_ASSERT(((p1 == &elem2.front()) && (p2 == &elem1.front())));
104 #endif
105 
106  {
107  vector<bool> bit_vec(5, true);
108  bit_vec.insert(bit_vec.end(), 5, false);
109  vector<vector<bool> > v_v_bits(1, bit_vec);
110 
111  /*
112  * This is a STLport specific test as we are using internal implementation
113  * details to check that the move has been correctly handled. For other
114  * STL implementation it is only a compile check.
115  */
116 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
117 # if defined (_STLP_DEBUG)
118  unsigned int *punit = v_v_bits.front().begin()._M_iterator._M_p;
119 # else
120  unsigned int *punit = v_v_bits.front().begin()._M_p;
121 # endif
122 #endif
123 
124  cur_capacity = v_v_bits.capacity();
125  while (v_v_bits.capacity() <= cur_capacity) {
126  v_v_bits.push_back(bit_vec);
127  }
128 
129 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
130  //v_v_bits has been resized
131 # if defined (_STLP_DEBUG)
132  CPPUNIT_ASSERT( punit == v_v_bits.front().begin()._M_iterator._M_p );
133 # else
134  CPPUNIT_ASSERT( punit == v_v_bits.front().begin()._M_p );
135 # endif
136 #endif
137  }
138 
139  // zero: don't like this kind of tests
140  // because of template test function
141  // we should find another way to provide
142  // move constructor testing...
143 
144 /*
145  standard_test1(list<int>(10));
146 
147 
148  standard_test1(slist<int>(10));
149 
150  standard_test1(deque<int>(10));
151 */
152 
153  /*
154  int int_values[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
155 
156  set<int> int_set(int_values, int_values + sizeof(in_values) / sizeof(int));
157  standard_test1(int_set);
158 
159  multiset<int> int_multiset(int_values, int_values + sizeof(in_values) / sizeof(int));
160  standard_test1(int_multiset);
161  */
162 
163  /*
164  CheckFullMoveSupport(string());
165  CheckFullMoveSupport(vector<int>());
166  CheckFullMoveSupport(deque<int>());
167  CheckFullMoveSupport(list<int>());
168  CheckFullMoveSupport(slist<int>());
169  */
170 }
#define swap(a, b)
Definition: qsort.c:63
static struct address_cache * front
Definition: rpcb_clnt.c:83
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200

◆ move_traits()

void MoveConstructorTest::move_traits ( )
protected

◆ move_traits_deq()

void MoveConstructorTest::move_traits_deq ( )
private

Definition at line 283 of file mvctor_traits_test.cpp.

284 {
285  {
287  {
289  deq.push_back(MovableStruct());
290  deq.push_back(MovableStruct());
291  deq.push_back(MovableStruct());
292  deq.push_back(MovableStruct());
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 }
static size_t nb_cpy_construct_call
Definition: mvctor_test.h:87
void push_back(const value_type &__t=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _deque.h:668
iterator end()
Definition: _deque.h:433
static size_t nb_destruct_call
Definition: mvctor_test.h:90
static size_t nb_dft_construct_call
Definition: mvctor_test.h:86
static size_t nb_mv_construct_call
Definition: mvctor_test.h:88
iterator begin()
Definition: _deque.h:432
Definition: _deque.h:400
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
static size_t nb_assignment_call
Definition: mvctor_test.h:89
static void reset()
Definition: mvctor_test.h:80
iterator insert(iterator __pos, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _deque.h:730
iterator erase(iterator __pos)
Definition: _deque.h:835

◆ move_traits_deq_complete()

void MoveConstructorTest::move_traits_deq_complete ( )
private

Definition at line 376 of file mvctor_traits_test.cpp.

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 }
void push_back(const value_type &__t=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _deque.h:668
iterator end()
Definition: _deque.h:433
static size_t nb_cpy_construct_call
static size_t nb_dft_construct_call
static size_t nb_assignment_call
iterator begin()
Definition: _deque.h:432
Definition: _deque.h:400
static size_t nb_mv_construct_call
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
iterator insert(iterator __pos, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _deque.h:730
iterator erase(iterator __pos)
Definition: _deque.h:835

◆ move_traits_vec()

void MoveConstructorTest::move_traits_vec ( )
private

Definition at line 86 of file mvctor_traits_test.cpp.

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 }
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_dft_construct_call
Definition: mvctor_test.h:86
static size_t nb_mv_construct_call
Definition: mvctor_test.h:88
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
static size_t nb_assignment_call
Definition: mvctor_test.h:89
#define CPPUNIT_ASSERT_EQUAL(X, Y)
Definition: cppunit_mini.h:211
static void reset()
Definition: mvctor_test.h:80

◆ move_traits_vec_complete()

void MoveConstructorTest::move_traits_vec_complete ( )
private

Definition at line 185 of file mvctor_traits_test.cpp.

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 }
static size_t nb_cpy_construct_call
static size_t nb_dft_construct_call
static size_t nb_assignment_call
static size_t nb_mv_construct_call
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063

◆ nb_destructor_calls()

void MoveConstructorTest::nb_destructor_calls ( )
protected

◆ vector_test()

void MoveConstructorTest::vector_test ( )
protected

Definition at line 397 of file mvctor_test.cpp.

398 {
399  //Check the insert range method.
400  //To the front:
401  {
402  vector<vector<int> > vect_vector;
403  vector<int*> bufs;
404  vect_vector.assign(3, vector<int>(10));
405  bufs.push_back(&vect_vector[0].front());
406  bufs.push_back(&vect_vector[1].front());
407  bufs.push_back(&vect_vector[2].front());
408 
409  int nb_insert = 5;
410  int pos = 1;
411  while (nb_insert--) {
412  vector<vector<int> > vect_vect(2, vector<int>(10));
413  vect_vector.insert(vect_vector.begin() + pos, vect_vect.begin(), vect_vect.end());
414  bufs.insert(bufs.begin() + pos, &vect_vector[pos].front());
415  bufs.insert(bufs.begin() + pos + 1, &vect_vector[pos + 1].front());
416  ++pos;
417  }
418  CPPUNIT_ASSERT( vect_vector.size() == 13 );
419 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
420  for (int i = 0; i < 5; ++i) {
421  CPPUNIT_ASSERT( bufs[i] == &vect_vector[i].front() );
422  CPPUNIT_ASSERT( bufs[11 - i] == &vect_vector[11 - i].front() );
423  }
424 #endif
425  }
426 
427  //To the back
428  {
429  vector<vector<int> > vect_vector;
430  vector<int*> bufs;
431  vect_vector.assign(3, vector<int>(10));
432  bufs.push_back(&vect_vector[0].front());
433  bufs.push_back(&vect_vector[1].front());
434  bufs.push_back(&vect_vector[2].front());
435 
436  int nb_insert = 5;
437  //Initialize to 2 to generate a back insertion:
438  int pos = 2;
439  while (nb_insert--) {
440  vector<vector<int> > vect_vect(2, vector<int>(10));
441  vect_vector.insert(vect_vector.begin() + pos, vect_vect.begin(), vect_vect.end());
442  bufs.insert(bufs.begin() + pos, &vect_vector[pos].front());
443  bufs.insert(bufs.begin() + pos + 1, &vect_vector[pos + 1].front());
444  ++pos;
445  }
446  CPPUNIT_ASSERT( vect_vector.size() == 13 );
447 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
448  for (int i = 0; i < 5; ++i) {
449  CPPUNIT_ASSERT( bufs[i + 1] == &vect_vector[i + 1].front() );
450  CPPUNIT_ASSERT( bufs[12 - i] == &vect_vector[12 - i].front() );
451  }
452 #endif
453  }
454 
455  //Check the different erase methods.
456  {
457  vector<vector<int> > vect_vector;
458  vect_vector.assign(20, vector<int>(10));
459  vector<vector<int> >::iterator vdit(vect_vector.begin()), vditEnd(vect_vector.end());
460  vector<int*> bufs;
461  for (; vdit != vditEnd; ++vdit) {
462  bufs.push_back(&vdit->front());
463  }
464 
465  {
466  // This check, repeated after each operation, check the vector consistency:
467  vector<vector<int> >::iterator it = vect_vector.end() - 5;
468  int nb_incr = 0;
469  for (; it != vect_vector.end() && nb_incr <= 6; ++nb_incr, ++it) {}
470  CPPUNIT_ASSERT( nb_incr == 5 );
471  }
472 
473  {
474  //erase in front:
475  vect_vector.erase(vect_vector.begin() + 2);
476  bufs.erase(bufs.begin() + 2);
477  CPPUNIT_ASSERT( vect_vector.size() == 19 );
478 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
479  vector<vector<int> >::iterator dit(vect_vector.begin()), ditEnd(vect_vector.end());
480  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
481  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
482  }
483 #endif
484  }
485 
486  {
487  vector<vector<int> >::iterator it = vect_vector.end() - 5;
488  int nb_incr = 0;
489  for (; it != vect_vector.end() && nb_incr <= 6; ++nb_incr, ++it) {}
490  CPPUNIT_ASSERT( nb_incr == 5 );
491  }
492 
493  {
494  //erase in the back:
495  vect_vector.erase(vect_vector.end() - 2);
496  bufs.erase(bufs.end() - 2);
497  CPPUNIT_ASSERT( vect_vector.size() == 18 );
498 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
499  vector<vector<int> >::iterator dit(vect_vector.begin()), ditEnd(vect_vector.end());
500  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
501  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
502  }
503 #endif
504  }
505 
506  {
507  vector<vector<int> >::iterator it = vect_vector.end() - 5;
508  int nb_incr = 0;
509  for (; it != vect_vector.end() && nb_incr < 6; ++nb_incr, ++it) {}
510  CPPUNIT_ASSERT( nb_incr == 5 );
511  }
512 
513  {
514  //range erase in front
515  vect_vector.erase(vect_vector.begin() + 3, vect_vector.begin() + 5);
516  bufs.erase(bufs.begin() + 3, bufs.begin() + 5);
517  CPPUNIT_ASSERT( vect_vector.size() == 16 );
518 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
519  vector<vector<int> >::iterator dit(vect_vector.begin()), ditEnd(vect_vector.end());
520  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
521  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
522  }
523 #endif
524  }
525 
526  {
527  vector<vector<int> >::iterator it = vect_vector.end() - 5;
528  int nb_incr = 0;
529  for (; it != vect_vector.end() && nb_incr <= 6; ++nb_incr, ++it) {}
530  CPPUNIT_ASSERT( nb_incr == 5 );
531  }
532 
533  {
534  //range erase in back
535  vect_vector.erase(vect_vector.end() - 5, vect_vector.end() - 3);
536  bufs.erase(bufs.end() - 5, bufs.end() - 3);
537  CPPUNIT_ASSERT( vect_vector.size() == 14 );
538 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
539  vector<vector<int> >::iterator dit(vect_vector.begin()), ditEnd(vect_vector.end());
540  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
541  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
542  }
543 #endif
544  }
545  }
546 
547  //Check the insert value(s)
548  {
549  vector<vector<int> > vect_vector;
550  vect_vector.assign(20, vector<int>(10));
551  vector<vector<int> >::iterator vdit(vect_vector.begin()), vditEnd(vect_vector.end());
552  vector<int*> bufs;
553  for (; vdit != vditEnd; ++vdit) {
554  bufs.push_back(&vdit->front());
555  }
556 
557  {
558  //2 values in front:
559  vect_vector.insert(vect_vector.begin() + 2, 2, vector<int>(10));
560  bufs.insert(bufs.begin() + 2, &vect_vector[2].front());
561  bufs.insert(bufs.begin() + 3, &vect_vector[3].front());
562  CPPUNIT_ASSERT( vect_vector.size() == 22 );
563 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
564  vector<vector<int> >::iterator dit(vect_vector.begin()), ditEnd(vect_vector.end());
565  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
566  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
567  }
568 #endif
569  }
570 
571  {
572  //2 values in back:
573  vect_vector.insert(vect_vector.end() - 2, 2, vector<int>(10));
574  bufs.insert(bufs.end() - 2, &vect_vector[20].front());
575  bufs.insert(bufs.end() - 2, &vect_vector[21].front());
576  CPPUNIT_ASSERT( vect_vector.size() == 24 );
577 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
578  vector<vector<int> >::iterator dit(vect_vector.begin()), ditEnd(vect_vector.end());
579  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
580  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
581  }
582 #endif
583  }
584 
585  {
586  //1 value in front:
587 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
588  vector<vector<int> >::iterator ret =
589 #endif
590  vect_vector.insert(vect_vector.begin() + 2, vector<int>(10));
591  bufs.insert(bufs.begin() + 2, &vect_vector[2].front());
592  CPPUNIT_ASSERT( vect_vector.size() == 25 );
593 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
594  CPPUNIT_ASSERT( &ret->front() == bufs[2] );
595  vector<vector<int> >::iterator dit(vect_vector.begin()), ditEnd(vect_vector.end());
596  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
597  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
598  }
599 #endif
600  }
601 
602  {
603  //1 value in back:
604 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
605  vector<vector<int> >::iterator ret =
606 #endif
607  vect_vector.insert(vect_vector.end() - 2, vector<int>(10));
608  bufs.insert(bufs.end() - 2, &vect_vector[23].front());
609  CPPUNIT_ASSERT( vect_vector.size() == 26 );
610 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
611  CPPUNIT_ASSERT( &ret->front() == bufs[23] );
612  vector<vector<int> >::iterator dit(vect_vector.begin()), ditEnd(vect_vector.end());
613  for (size_t i = 0; dit != ditEnd; ++dit, ++i) {
614  CPPUNIT_ASSERT( bufs[i] == &dit->front() );
615  }
616 #endif
617  }
618  }
619 
620  //The following tests are checking move contructor implementations:
621  const string long_str("long enough string to force dynamic allocation");
622  {
623  //vector move contructor:
624  vector<vector<string> > vect(10, vector<string>(10, long_str));
625  vector<string> strs;
626  size_t index = 0;
627  for (;;) {
628  vector<vector<string> >::iterator it(vect.begin());
629  advance(it, index % vect.size());
630  strs.push_back(it->front());
631  it->erase(it->begin());
632  if (it->empty()) {
633  vect.erase(it);
634  if (vect.empty())
635  break;
636  }
637  index += 3;
638  }
639  CPPUNIT_ASSERT( strs.size() == 10 * 10 );
640  vector<string>::iterator it(strs.begin()), itEnd(strs.end());
641  for (; it != itEnd; ++it) {
642  CPPUNIT_ASSERT( *it == long_str );
643  }
644  }
645 
646  {
647  //deque move contructor:
648 # if !defined (__DMC__)
649  vector<deque<string> > vect(10, deque<string>(10, long_str));
650 # else
651  deque<string> deq_str = deque<string>(10, long_str);
652  vector<deque<string> > vect(10, deq_str);
653 # endif
654  vector<string> strs;
655  size_t index = 0;
656  for (;;) {
657  vector<deque<string> >::iterator it(vect.begin());
658  advance(it, index % vect.size());
659  strs.push_back(it->front());
660  it->pop_front();
661  if (it->empty()) {
662  vect.erase(it);
663  if (vect.empty())
664  break;
665  }
666  index += 3;
667  }
668  CPPUNIT_ASSERT( strs.size() == 10 * 10 );
669  vector<string>::iterator it(strs.begin()), itEnd(strs.end());
670  for (; it != itEnd; ++it) {
671  CPPUNIT_ASSERT( *it == long_str );
672  }
673  }
674 
675  {
676  //list move contructor:
677  vector<list<string> > vect(10, list<string>(10, long_str));
678  vector<string> strs;
679  size_t index = 0;
680  for (;;) {
681  vector<list<string> >::iterator it(vect.begin());
682  advance(it, index % vect.size());
683  strs.push_back(it->front());
684  it->pop_front();
685  if (it->empty()) {
686  vect.erase(it);
687  if (vect.empty())
688  break;
689  }
690  index += 3;
691  }
692  CPPUNIT_ASSERT( strs.size() == 10 * 10 );
693  vector<string>::iterator it(strs.begin()), itEnd(strs.end());
694  for (; it != itEnd; ++it) {
695  CPPUNIT_ASSERT( *it == long_str );
696  }
697  }
698 
699 #if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
700  {
701  //slist move contructor:
702  vector<slist<string> > vect(10, slist<string>(10, long_str));
703  vector<string> strs;
704  size_t index = 0;
705  while (true) {
706  vector<slist<string> >::iterator it(vect.begin());
707  advance(it, index % vect.size());
708  strs.push_back(it->front());
709  it->pop_front();
710  if (it->empty()) {
711  vect.erase(it);
712  if (vect.empty())
713  break;
714  }
715  index += 3;
716  }
717  CPPUNIT_ASSERT( strs.size() == 10 * 10 );
718  vector<string>::iterator it(strs.begin()), itEnd(strs.end());
719  for (; it != itEnd; ++it) {
720  CPPUNIT_ASSERT( *it == long_str );
721  }
722  }
723 #endif
724 
725  {
726  //binary tree move contructor:
728  for (size_t i = 0; i < 10; ++i) {
729  ref.insert(long_str);
730  }
731  vector<multiset<string> > vect(10, ref);
732  vector<string> strs;
733  size_t index = 0;
734  for (;;) {
735  vector<multiset<string> >::iterator it(vect.begin());
736  advance(it, index % vect.size());
737  strs.push_back(*it->begin());
738  it->erase(it->begin());
739  if (it->empty()) {
740  vect.erase(it);
741  if (vect.empty())
742  break;
743  }
744  index += 3;
745  }
746  CPPUNIT_ASSERT( strs.size() == 10 * 10 );
747  vector<string>::iterator it(strs.begin()), itEnd(strs.end());
748  for (; it != itEnd; ++it) {
749  CPPUNIT_ASSERT( *it == long_str );
750  }
751  }
752 
753 #if defined (STLPORT)
754 # if !defined (__DMC__)
755  {
756  //hash container move contructor:
758  for (size_t i = 0; i < 10; ++i) {
759  ref.insert(long_str);
760  }
761  vector<unordered_multiset<string> > vect(10, ref);
762  vector<string> strs;
763  size_t index = 0;
764  while (true) {
765  vector<unordered_multiset<string> >::iterator it(vect.begin());
766  advance(it, index % vect.size());
767  strs.push_back(*it->begin());
768  it->erase(it->begin());
769  if (it->empty()) {
770  vect.erase(it);
771  if (vect.empty())
772  break;
773  }
774  index += 3;
775  }
776  CPPUNIT_ASSERT( strs.size() == 10 * 10 );
777  vector<string>::iterator it(strs.begin()), itEnd(strs.end());
778  for (; it != itEnd; ++it) {
779  CPPUNIT_ASSERT( *it == long_str );
780  }
781  }
782 # endif
783 #endif
784 }
const GLenum * bufs
Definition: glext.h:6026
Definition: _slist.h:198
Definition: _set.h:216
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
GLuint index
Definition: glext.h:6031
value_type * iterator
Definition: _vector.h:124
static struct address_cache * front
Definition: rpcb_clnt.c:83
Definition: _deque.h:400
int ret
_STLP_MOVE_TO_STD_NAMESPACE void _STLP_CALL advance(_InputIterator &__i, _Distance __n)
WDF_CHILD_LIST_ITERATOR iterator
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Member Data Documentation

◆ CPPUNIT_IGNORE

MoveConstructorTest::CPPUNIT_IGNORE
private

Definition at line 18 of file mvctor_test.h.


The documentation for this class was generated from the following files: