ReactOS 0.4.15-dev-7958-gcd0bb1a
ListTest Class Reference
Inheritance diagram for ListTest:
Collaboration diagram for ListTest:

Protected Member Functions

void list1 ()
 
void list2 ()
 
void list3 ()
 
void list4 ()
 
void erase ()
 
void resize ()
 
void push_back ()
 
void push_front ()
 
void allocator_with_state ()
 
void swap ()
 
void adl ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (ListTest)
 
 CPPUNIT_TEST (list1)
 
 CPPUNIT_TEST (list2)
 
 CPPUNIT_TEST (list3)
 
 CPPUNIT_TEST (list4)
 
 CPPUNIT_TEST (erase)
 
 CPPUNIT_TEST (resize)
 
 CPPUNIT_TEST (push_back)
 
 CPPUNIT_TEST (push_front)
 
 CPPUNIT_TEST (allocator_with_state)
 
 CPPUNIT_TEST (swap)
 
 CPPUNIT_TEST (adl)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 18 of file list_test.cpp.

Member Function Documentation

◆ adl()

void ListTest::adl ( )
protected

Definition at line 451 of file list_test.cpp.

452{
453 list<foo::bar> lbar;
454 CPPUNIT_ASSERT( lbar.size() == 0);
455}
Definition: list.h:37
size_type size() const
Definition: _list.h:379
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200

◆ allocator_with_state()

void ListTest::allocator_with_state ( )
protected

Definition at line 272 of file list_test.cpp.

273{
274 char buf1[1024];
275 StackAllocator<int> stack1(buf1, buf1 + sizeof(buf1));
276
277 char buf2[1024];
278 StackAllocator<int> stack2(buf2, buf2 + sizeof(buf2));
279
280 typedef list<int, StackAllocator<int> > ListInt;
281 {
282 //Swap with both list non empty
283 ListInt lint1(10, 0, stack1);
284 ListInt lint1Cpy(lint1);
285
286 ListInt lint2(10, 1, stack2);
287 ListInt lint2Cpy(lint2);
288
289 lint1.swap(lint2);
290
291 CPPUNIT_ASSERT( lint1.get_allocator().swaped() );
292 CPPUNIT_ASSERT( lint2.get_allocator().swaped() );
293
294 CPPUNIT_ASSERT( lint1 == lint2Cpy );
295 CPPUNIT_ASSERT( lint2 == lint1Cpy );
296 CPPUNIT_ASSERT( lint1.get_allocator() == stack2 );
297 CPPUNIT_ASSERT( lint2.get_allocator() == stack1 );
298 }
299 CPPUNIT_CHECK( stack1.ok() );
300 CPPUNIT_CHECK( stack2.ok() );
301 stack1.reset(); stack2.reset();
302
303 {
304 //Swap with empty calle list
305 ListInt lint1(10, 0, stack1);
306 ListInt lint1Cpy(lint1);
307
308 ListInt lint2(stack2);
309 ListInt lint2Cpy(lint2);
310
311 lint1.swap(lint2);
312
313 CPPUNIT_ASSERT( lint1.get_allocator().swaped() );
314 CPPUNIT_ASSERT( lint2.get_allocator().swaped() );
315
316 CPPUNIT_ASSERT( lint1 == lint2Cpy );
317 CPPUNIT_ASSERT( lint2 == lint1Cpy );
318 CPPUNIT_ASSERT( lint1.get_allocator() == stack2 );
319 CPPUNIT_ASSERT( lint2.get_allocator() == stack1 );
320 }
321 CPPUNIT_CHECK( stack1.ok() );
322 CPPUNIT_CHECK( stack2.ok() );
323 stack1.reset(); stack2.reset();
324
325 {
326 //Swap with empty caller list
327 ListInt lint1(stack1);
328 ListInt lint1Cpy(lint1);
329
330 ListInt lint2(10, 0, stack2);
331 ListInt lint2Cpy(lint2);
332
333 lint1.swap(lint2);
334
335 CPPUNIT_ASSERT( lint1.get_allocator().swaped() );
336 CPPUNIT_ASSERT( lint2.get_allocator().swaped() );
337
338 CPPUNIT_ASSERT( lint1 == lint2Cpy );
339 CPPUNIT_ASSERT( lint2 == lint1Cpy );
340 CPPUNIT_ASSERT( lint1.get_allocator() == stack2 );
341 CPPUNIT_ASSERT( lint2.get_allocator() == stack1 );
342 }
343 CPPUNIT_CHECK( stack1.ok() );
344 CPPUNIT_CHECK( stack2.ok() );
345 stack1.reset(); stack2.reset();
346
347 {
348 ListInt lint1(10, 0, stack1);
349 ListInt lint2(10, 1, stack2);
350
351 lint1.splice(lint1.begin(), lint2);
352 CPPUNIT_ASSERT( lint1.size() == 20 );
353 CPPUNIT_ASSERT( lint2.empty() );
354 }
355 CPPUNIT_CHECK( stack1.ok() );
356 CPPUNIT_CHECK( stack2.ok() );
357 stack1.reset(); stack2.reset();
358
359 {
360 ListInt lint1(10, 0, stack1);
361 ListInt lint2(10, 1, stack2);
362
363 lint1.splice(lint1.begin(), lint2, lint2.begin());
364 CPPUNIT_ASSERT( lint1.size() == 11 );
365 CPPUNIT_ASSERT( lint2.size() == 9 );
366 }
367 CPPUNIT_CHECK( stack1.ok() );
368 CPPUNIT_CHECK( stack2.ok() );
369 stack1.reset(); stack2.reset();
370
371 {
372 ListInt lint1(10, 0, stack1);
373 ListInt lint2(10, 1, stack2);
374
375 ListInt::iterator lit(lint2.begin());
376 advance(lit, 5);
377 lint1.splice(lint1.begin(), lint2, lint2.begin(), lit);
378 CPPUNIT_ASSERT( lint1.size() == 15 );
379 CPPUNIT_ASSERT( lint2.size() == 5 );
380 }
381 CPPUNIT_CHECK( stack1.ok() );
382 CPPUNIT_CHECK( stack2.ok() );
383 stack1.reset(); stack2.reset();
384
385 {
386 ListInt lint1(10, 0, stack1);
387 ListInt lint2(10, 1, stack2);
388
389 ListInt lintref(stack2);
390 lintref.insert(lintref.begin(), 10, 1);
391 lintref.insert(lintref.begin(), 10, 0);
392
393 lint1.merge(lint2);
394 CPPUNIT_ASSERT( lint1.size() == 20 );
395 CPPUNIT_ASSERT( lint1 == lintref );
396 CPPUNIT_ASSERT( lint2.empty() );
397 }
398 CPPUNIT_CHECK( stack1.ok() );
399 CPPUNIT_CHECK( stack2.ok() );
400
401#if defined (STLPORT) && !defined (_STLP_NO_MEMBER_TEMPLATES) && \
402 (!defined (_MSC_VER) || (_MSC_VER >= 1300))
403 {
404 //This is a compile time test.
405 //We check that sort implementation is correct when list is instanciated
406 //with an allocator that do not have a default constructor.
407 ListInt lint1(10, 0, stack1);
408 lint1.sort();
409 lint1.sort(greater<int>());
410 }
411#endif
412}
_STLP_MOVE_TO_STD_NAMESPACE void _STLP_CALL advance(_InputIterator &__i, _Distance __n)
#define CPPUNIT_CHECK(X)
Definition: cppunit_mini.h:195

◆ CPPUNIT_TEST() [1/11]

ListTest::CPPUNIT_TEST ( adl  )
private

◆ CPPUNIT_TEST() [2/11]

ListTest::CPPUNIT_TEST ( allocator_with_state  )
private

◆ CPPUNIT_TEST() [3/11]

ListTest::CPPUNIT_TEST ( erase  )
private

◆ CPPUNIT_TEST() [4/11]

ListTest::CPPUNIT_TEST ( list1  )
private

◆ CPPUNIT_TEST() [5/11]

ListTest::CPPUNIT_TEST ( list2  )
private

◆ CPPUNIT_TEST() [6/11]

ListTest::CPPUNIT_TEST ( list3  )
private

◆ CPPUNIT_TEST() [7/11]

ListTest::CPPUNIT_TEST ( list4  )
private

◆ CPPUNIT_TEST() [8/11]

ListTest::CPPUNIT_TEST ( push_back  )
private

◆ CPPUNIT_TEST() [9/11]

ListTest::CPPUNIT_TEST ( push_front  )
private

◆ CPPUNIT_TEST() [10/11]

ListTest::CPPUNIT_TEST ( resize  )
private

◆ CPPUNIT_TEST() [11/11]

ListTest::CPPUNIT_TEST ( swap  )
private

◆ CPPUNIT_TEST_SUITE()

ListTest::CPPUNIT_TEST_SUITE ( ListTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

ListTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ erase()

void ListTest::erase ( )
protected

Definition at line 174 of file list_test.cpp.

175{
176 list<int> l;
177 l.push_back( 1 );
178 l.erase(l.begin());
179 CPPUNIT_ASSERT( l.empty() );
180
181 int array[] = { 0, 1, 2, 3 };
182 l.assign(array, array + 4);
184 lit = l.erase(l.begin());
185 CPPUNIT_ASSERT( *lit == 1 );
186
187 lit = l.erase(l.begin(), --l.end());
188 CPPUNIT_ASSERT( *lit == 3 );
189
190 l.clear();
191 CPPUNIT_ASSERT( l.empty() );
192}
r l[0]
Definition: byte_order.h:168
_STLP_PRIV _List_iterator< _Tp, _Nonconst_traits< _Tp > > iterator
Definition: _list.h:275

◆ list1()

void ListTest::list1 ( )
protected

Definition at line 55 of file list_test.cpp.

56{
57 int array1 [] = { 9, 16, 36 };
58 int array2 [] = { 1, 4 };
59
60 list<int> l1(array1, array1 + 3);
61 list<int> l2(array2, array2 + 2);
62 list<int>::iterator i1 = l1.begin();
63 list<int>::iterator i2 = l2.begin();
66 l1.splice(i1, l2);
67 i1 = l1.begin();
68 CPPUNIT_ASSERT( *i1++ == 1 );
69 CPPUNIT_ASSERT( *i1++ == 4 );
70 CPPUNIT_ASSERT( *i1++ == 9 );
71 CPPUNIT_ASSERT( *i1++ == 16 );
72 CPPUNIT_ASSERT( *i1++ == 36 );
73
74#if defined (STLPORT) && \
75 (!defined (_STLP_DEBUG) || (_STLP_DEBUG_LEVEL != _STLP_STANDARD_DBG_LEVEL))
76 CPPUNIT_ASSERT( i2 == l1.begin() );
77#endif
78
79 //Default construct check (_STLP_DEF_CONST_PLCT_NEW_BUG)
80 list<int> l(2);
81 i1 = l.begin();
82 CPPUNIT_ASSERT( *(i1++) == 0 );
83 CPPUNIT_ASSERT( *i1 == 0 );
84#if 0
85 //A small compilation time check to be activated from time to time,
86 //compilation should fail.
87 {
88 list<char>::iterator l_char_ite;
89 list<int>::iterator l_int_ite;
90 CPPUNIT_ASSERT( l_char_ite != l_int_ite );
91 }
92#endif
93}
_STLP_PRIV _List_iterator< _Tp, _Const_traits< _Tp > > const_iterator
Definition: _list.h:276
iterator begin()
Definition: _list.h:367

◆ list2()

void ListTest::list2 ( )
protected

Definition at line 95 of file list_test.cpp.

96{
97 int array1 [] = { 1, 16 };
98 int array2 [] = { 4, 9 };
99
100 list<int> l1(array1, array1 + 2);
101 list<int> l2(array2, array2 + 2);
102 list<int>::iterator i = l1.begin();
103 i++;
104 l1.splice(i, l2, l2.begin(), l2.end());
105 i = l1.begin();
106 CPPUNIT_ASSERT(*i++==1);
107 CPPUNIT_ASSERT(*i++==4);
108 CPPUNIT_ASSERT(*i++==9);
109 CPPUNIT_ASSERT(*i++==16);
110}
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

◆ list3()

void ListTest::list3 ( )
protected

Definition at line 112 of file list_test.cpp.

113{
114 char array [] = { 'x', 'l', 'x', 't', 's', 's' };
115
118
119 str.reverse();
120 i = str.begin();
121 CPPUNIT_ASSERT(*i++=='s');
122 CPPUNIT_ASSERT(*i++=='s');
123 CPPUNIT_ASSERT(*i++=='t');
124 CPPUNIT_ASSERT(*i++=='x');
125 CPPUNIT_ASSERT(*i++=='l');
126 CPPUNIT_ASSERT(*i++=='x');
127
128 str.remove('x');
129 i = str.begin();
130 CPPUNIT_ASSERT(*i++=='s');
131 CPPUNIT_ASSERT(*i++=='s');
132 CPPUNIT_ASSERT(*i++=='t');
133 CPPUNIT_ASSERT(*i++=='l');
134
135 str.unique();
136 i = str.begin();
137 CPPUNIT_ASSERT(*i++=='s');
138 CPPUNIT_ASSERT(*i++=='t');
139 CPPUNIT_ASSERT(*i++=='l');
140
141 str.sort();
142 i = str.begin();
143 CPPUNIT_ASSERT(*i++=='l');
144 CPPUNIT_ASSERT(*i++=='s');
145 CPPUNIT_ASSERT(*i++=='t');
146}
const WCHAR * str

◆ list4()

void ListTest::list4 ( )
protected

Definition at line 148 of file list_test.cpp.

149{
150 int array1 [] = { 1, 3, 6, 7 };
151 int array2 [] = { 2, 4 };
152
153 list<int> l1(array1, array1 + 4);
154 list<int> l2(array2, array2 + 2);
155 l1.merge(l2);
156 list<int>::iterator i = l1.begin();
157 CPPUNIT_ASSERT(*i++==1);
158 CPPUNIT_ASSERT(*i++==2);
159 CPPUNIT_ASSERT(*i++==3);
160 CPPUNIT_ASSERT(*i++==4);
161 CPPUNIT_ASSERT(*i++==6);
162 CPPUNIT_ASSERT(*i++==7);
163
164 //We use distance to avoid a simple call to an internal counter
165 CPPUNIT_ASSERT(distance(l1.begin(), l1.end()) == 6);
166 CPPUNIT_ASSERT(distance(l2.begin(), l2.end()) == 0);
167
168 l1.swap(l2);
169
170 CPPUNIT_ASSERT(distance(l1.begin(), l1.end()) == 0);
171 CPPUNIT_ASSERT(distance(l2.begin(), l2.end()) == 6);
172}
GLsizei GLsizei GLfloat distance
Definition: glext.h:11755

◆ push_back()

void ListTest::push_back ( )
protected

Definition at line 232 of file list_test.cpp.

233{
234 list<int> l;
235 l.push_back( 1 );
236 l.push_back( 2 );
237 l.push_back( 3 );
238
240
241 CPPUNIT_ASSERT( *r == 3 );
242 l.push_back( 4 );
243 /*
244 * Following lines are commented, because ones show standard contradiction
245 * (24.4.1 and 23.2.2.3); but present behaviour is valid, 24.4.1, paragraphs 1 and 2,
246 * 24.4.1.3.3 and 23.1 paragraph 9 (Table 66). The 24.4.1 is more common rule,
247 * so it has preference under 23.2.2.3, by my opinion.
248 *
249 * - ptr
250 */
251 // CPPUNIT_ASSERT( *r == 3 );
252 // ++r;
253 // CPPUNIT_ASSERT( *r == 2 );
254}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055

◆ push_front()

void ListTest::push_front ( )
protected

Definition at line 256 of file list_test.cpp.

257{
258 list<int> l;
259 l.push_back( 1 );
260 l.push_back( 2 );
261 l.push_back( 3 );
262
263 list<int>::iterator i = l.begin();
264
265 CPPUNIT_ASSERT( *i == 1 );
266 l.push_front( 0 );
267 CPPUNIT_ASSERT( *i == 1 );
268 ++i;
269 CPPUNIT_ASSERT( *i == 2 );
270}

◆ resize()

void ListTest::resize ( )
protected

Definition at line 195 of file list_test.cpp.

196{
197 {
198 list<int> l;
199 l.resize(5, 1);
200
201 size_t i;
202 list<int>::iterator lit(l.begin());
203 for (i = 0; i < 5; ++i) {
204 CPPUNIT_ASSERT( lit != l.end() );
205 CPPUNIT_ASSERT( *(lit++) == 1 );
206 }
207 CPPUNIT_ASSERT( lit == l.end() );
208
209 l.resize(3);
210 lit = l.begin();
211 for (i = 0; i < 3; ++i) {
212 CPPUNIT_ASSERT( lit != l.end() );
213 CPPUNIT_ASSERT( *(lit++) == 1 );
214 }
215 CPPUNIT_ASSERT( lit == l.end() );
216 }
217
218 {
219 list<int> l;
220 l.resize(5);
221
222 size_t i;
223 list<int>::iterator lit(l.begin());
224 for (i = 0; i < 5; ++i) {
225 CPPUNIT_ASSERT( lit != l.end() );
226 CPPUNIT_ASSERT( *(lit++) == 0 );
227 }
228 CPPUNIT_ASSERT( lit == l.end() );
229 }
230}

◆ swap()

void ListTest::swap ( )
protected

Definition at line 422 of file list_test.cpp.

423{
426
427 lst1.push_back(1);
428 lst2.push_back(2);
429
430 lst1.swap( lst2 );
431
432 CPPUNIT_CHECK( lst1.front() == 2 );
433 CPPUNIT_CHECK( lst2.front() == 1 );
434 CPPUNIT_CHECK( lst1.size() == 1 );
435 CPPUNIT_CHECK( lst2.size() == 1 );
436
437 lst1.pop_front();
438 lst2.pop_front();
439
440 CPPUNIT_CHECK( lst1.empty() );
441 CPPUNIT_CHECK( lst2.empty() );
442}
#define lst2
Definition: dlgs.h:96
#define lst1
Definition: dlgs.h:95

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