ReactOS 0.4.15-dev-7934-g1dc8d80
SetTest Class Reference
Inheritance diagram for SetTest:
Collaboration diagram for SetTest:

Protected Member Functions

void set1 ()
 
void set2 ()
 
void erase ()
 
void insert ()
 
void find ()
 
void bounds ()
 
void specialized_less ()
 
void implementation_check ()
 
void allocator_with_state ()
 
void reverse_iterator_test ()
 
void template_methods ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (SetTest)
 
 CPPUNIT_TEST (set1)
 
 CPPUNIT_TEST (set2)
 
 CPPUNIT_TEST (erase)
 
 CPPUNIT_TEST (insert)
 
 CPPUNIT_TEST (find)
 
 CPPUNIT_TEST (bounds)
 
 CPPUNIT_TEST (specialized_less)
 
 CPPUNIT_TEST (implementation_check)
 
 CPPUNIT_TEST (allocator_with_state)
 
 CPPUNIT_TEST (reverse_iterator_test)
 
 CPPUNIT_TEST (template_methods)
 
 CPPUNIT_TEST_SUITE_END ()
 

Private Attributes

 CPPUNIT_IGNORE
 

Detailed Description

Definition at line 17 of file set_test.cpp.

Member Function Documentation

◆ allocator_with_state()

void SetTest::allocator_with_state ( )
protected

Definition at line 276 of file set_test.cpp.

277{
278 char buf1[1024];
279 StackAllocator<int> stack1(buf1, buf1 + sizeof(buf1));
280
281 char buf2[1024];
282 StackAllocator<int> stack2(buf2, buf2 + sizeof(buf2));
283
284 int i;
286 less<int> intLess;
287
288 {
289 SetInt sint1(intLess, stack1);
290 for (i = 0; i < 5; ++i)
291 sint1.insert(i);
292 SetInt sint1Cpy(sint1);
293
294 SetInt sint2(intLess, stack2);
295 for (; i < 10; ++i)
296 sint2.insert(i);
297 SetInt sint2Cpy(sint2);
298
299 sint1.swap(sint2);
300
301 CPPUNIT_ASSERT( sint1.get_allocator().swaped() );
302 CPPUNIT_ASSERT( sint2.get_allocator().swaped() );
303
304 CPPUNIT_ASSERT( sint1 == sint2Cpy );
305 CPPUNIT_ASSERT( sint2 == sint1Cpy );
306 CPPUNIT_ASSERT( sint1.get_allocator() == stack2 );
307 CPPUNIT_ASSERT( sint2.get_allocator() == stack1 );
308 }
309 CPPUNIT_ASSERT( stack1.ok() );
310 CPPUNIT_ASSERT( stack2.ok() );
311 stack1.reset(); stack2.reset();
312
313 {
314 SetInt sint1(intLess, stack1);
315 SetInt sint1Cpy(sint1);
316
317 SetInt sint2(intLess, stack2);
318 for (i = 0; i < 10; ++i)
319 sint2.insert(i);
320 SetInt sint2Cpy(sint2);
321
322 sint1.swap(sint2);
323
324 CPPUNIT_ASSERT( sint1.get_allocator().swaped() );
325 CPPUNIT_ASSERT( sint2.get_allocator().swaped() );
326
327 CPPUNIT_ASSERT( sint1 == sint2Cpy );
328 CPPUNIT_ASSERT( sint2 == sint1Cpy );
329 CPPUNIT_ASSERT( sint1.get_allocator() == stack2 );
330 CPPUNIT_ASSERT( sint2.get_allocator() == stack1 );
331 }
332 CPPUNIT_ASSERT( stack1.ok() );
333 CPPUNIT_ASSERT( stack2.ok() );
334 stack1.reset(); stack2.reset();
335
336 {
337 SetInt sint1(intLess, stack1);
338 for (i = 0; i < 10; ++i)
339 sint1.insert(i);
340 SetInt sint1Cpy(sint1);
341
342 SetInt sint2(intLess, stack2);
343 SetInt sint2Cpy(sint2);
344
345 sint1.swap(sint2);
346
347 CPPUNIT_ASSERT( sint1.get_allocator().swaped() );
348 CPPUNIT_ASSERT( sint2.get_allocator().swaped() );
349
350 CPPUNIT_ASSERT( sint1 == sint2Cpy );
351 CPPUNIT_ASSERT( sint2 == sint1Cpy );
352 CPPUNIT_ASSERT( sint1.get_allocator() == stack2 );
353 CPPUNIT_ASSERT( sint2.get_allocator() == stack1 );
354 }
355 CPPUNIT_ASSERT( stack1.ok() );
356 CPPUNIT_ASSERT( stack2.ok() );
357 stack1.reset(); stack2.reset();
358}
Definition: _set.h:50
#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
@ SetInt
Definition: shader.c:1966

◆ bounds()

void SetTest::bounds ( )
protected

Definition at line 123 of file set_test.cpp.

124{
125 int array1 [] = { 1, 3, 6, 7 };
126 set<int> s(array1, array1 + sizeof(array1) / sizeof(array1[0]));
127 set<int> const& crs = s;
128
133
134 //Check iterator on mutable set
135 sit = s.lower_bound(2);
136 CPPUNIT_ASSERT( sit != s.end() );
137 CPPUNIT_ASSERT( *sit == 3 );
138
139 sit = s.upper_bound(5);
140 CPPUNIT_ASSERT( sit != s.end() );
141 CPPUNIT_ASSERT( *sit == 6 );
142
143 pit = s.equal_range(6);
144 CPPUNIT_ASSERT( pit.first != pit.second );
145 CPPUNIT_ASSERT( pit.first != s.end() );
146 CPPUNIT_ASSERT( *pit.first == 6 );
147 CPPUNIT_ASSERT( pit.second != s.end() );
148 CPPUNIT_ASSERT( *pit.second == 7 );
149
150 pit = s.equal_range(4);
151 CPPUNIT_ASSERT( pit.first == pit.second );
152 CPPUNIT_ASSERT( pit.first != s.end() );
153 CPPUNIT_ASSERT( *pit.first == 6 );
154 CPPUNIT_ASSERT( pit.second != s.end() );
155 CPPUNIT_ASSERT( *pit.second == 6 );
156
157 //Check const_iterator on mutable set
158 scit = s.lower_bound(2);
159 CPPUNIT_ASSERT( scit != s.end() );
160 CPPUNIT_ASSERT( *scit == 3 );
161
162 scit = s.upper_bound(5);
163 CPPUNIT_ASSERT( scit != s.end() );
164 CPPUNIT_ASSERT( *scit == 6 );
165
166#ifdef _STLP_MEMBER_TEMPLATES
167 pcit = s.equal_range(6);
168 CPPUNIT_ASSERT( pcit.first != pcit.second );
169 CPPUNIT_ASSERT( pcit.first != s.end() );
170 CPPUNIT_ASSERT( *pcit.first == 6 );
171 CPPUNIT_ASSERT( pcit.second != s.end() );
172 CPPUNIT_ASSERT( *pcit.second == 7 );
173#endif
174
175 //Check const_iterator on const set
176 scit = crs.lower_bound(2);
177 CPPUNIT_ASSERT( scit != crs.end() );
178 CPPUNIT_ASSERT( *scit == 3 );
179
180 scit = crs.upper_bound(5);
181 CPPUNIT_ASSERT( scit != crs.end() );
182 CPPUNIT_ASSERT( *scit == 6 );
183
184 pcit = crs.equal_range(6);
185 CPPUNIT_ASSERT( pcit.first != pcit.second );
186 CPPUNIT_ASSERT( pcit.first != crs.end() );
187 CPPUNIT_ASSERT( *pcit.first == 6 );
188 CPPUNIT_ASSERT( pcit.second != crs.end() );
189 CPPUNIT_ASSERT( *pcit.second == 7 );
190}
_STLP_TEMPLATE_FOR_CONT_EXT iterator upper_bound(const _KT &__x)
Definition: _set.h:200
_STLP_TEMPLATE_FOR_CONT_EXT iterator lower_bound(const _KT &__x)
Definition: _set.h:196
_Rep_type::const_iterator const_iterator
Definition: _set.h:74
_Rep_type::iterator iterator
Definition: _set.h:73
GLdouble s
Definition: gl.h:2039
static const WCHAR crs[]
Definition: _pair.h:47
_T2 second
Definition: _pair.h:52
_T1 first
Definition: _pair.h:51

◆ CPPUNIT_TEST() [1/11]

SetTest::CPPUNIT_TEST ( allocator_with_state  )
private

◆ CPPUNIT_TEST() [2/11]

SetTest::CPPUNIT_TEST ( bounds  )
private

◆ CPPUNIT_TEST() [3/11]

SetTest::CPPUNIT_TEST ( erase  )
private

◆ CPPUNIT_TEST() [4/11]

SetTest::CPPUNIT_TEST ( find  )
private

◆ CPPUNIT_TEST() [5/11]

SetTest::CPPUNIT_TEST ( implementation_check  )
private

◆ CPPUNIT_TEST() [6/11]

SetTest::CPPUNIT_TEST ( insert  )
private

◆ CPPUNIT_TEST() [7/11]

SetTest::CPPUNIT_TEST ( reverse_iterator_test  )
private

◆ CPPUNIT_TEST() [8/11]

SetTest::CPPUNIT_TEST ( set1  )
private

◆ CPPUNIT_TEST() [9/11]

SetTest::CPPUNIT_TEST ( set2  )
private

◆ CPPUNIT_TEST() [10/11]

SetTest::CPPUNIT_TEST ( specialized_less  )
private

◆ CPPUNIT_TEST() [11/11]

SetTest::CPPUNIT_TEST ( template_methods  )
private

◆ CPPUNIT_TEST_SUITE()

SetTest::CPPUNIT_TEST_SUITE ( SetTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

SetTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ erase()

void SetTest::erase ( )
protected

Definition at line 94 of file set_test.cpp.

95{
97 s.insert(1);
98 s.erase(s.begin());
99 CPPUNIT_ASSERT( s.empty() );
100
101 size_t nb = s.erase(1);
102 CPPUNIT_ASSERT(nb == 0);
103}

◆ find()

void SetTest::find ( )
protected

Definition at line 112 of file set_test.cpp.

113{
114 set<int> s;
115
116 CPPUNIT_ASSERT( s.find(0) == s.end() );
117
118 set<int> const& crs = s;
119
120 CPPUNIT_ASSERT( crs.find(0) == crs.end() );
121}

◆ implementation_check()

void SetTest::implementation_check ( )
protected

Definition at line 238 of file set_test.cpp.

239{
241 tree.insert(1);
242 set<int>::iterator it = tree.begin();
243 int const& int_ref = *it++;
244 CPPUNIT_ASSERT( int_ref == 1 );
245
246 CPPUNIT_ASSERT( it == tree.end() );
247 CPPUNIT_ASSERT( it != tree.begin() );
248
249 set<int>::const_iterator cit = tree.begin();
250 int const& int_cref = *cit++;
251 CPPUNIT_ASSERT( int_cref == 1 );
252}
struct _tree tree

◆ insert()

void SetTest::insert ( )
protected

Definition at line 105 of file set_test.cpp.

106{
107 set<int> s;
108 set<int>::iterator i = s.insert( s.end(), 0 );
109 CPPUNIT_ASSERT( *i == 0 );
110}

◆ reverse_iterator_test()

void SetTest::reverse_iterator_test ( )
protected

Definition at line 254 of file set_test.cpp.

255{
257 tree.insert(1);
258 tree.insert(2);
259
260 {
261 set<int>::reverse_iterator rit(tree.rbegin());
262 CPPUNIT_ASSERT( *(rit++) == 2 );
263 CPPUNIT_ASSERT( *(rit++) == 1 );
264 CPPUNIT_ASSERT( rit == tree.rend() );
265 }
266
267 {
268 set<int> const& ctree = tree;
270 CPPUNIT_ASSERT( *(rit++) == 2 );
271 CPPUNIT_ASSERT( *(rit++) == 1 );
272 CPPUNIT_ASSERT( rit == ctree.rend() );
273 }
274}
_Rep_type::reverse_iterator reverse_iterator
Definition: _set.h:75
_Rep_type::const_reverse_iterator const_reverse_iterator
Definition: _set.h:76
reverse_iterator rbegin()
Definition: _set.h:155
reverse_iterator rend()
Definition: _set.h:156

◆ set1()

void SetTest::set1 ( )
protected

Definition at line 56 of file set_test.cpp.

57{
59 CPPUNIT_ASSERT (s.count(42) == 0);
60 s.insert(42);
61 CPPUNIT_ASSERT (s.count(42) == 1);
62 s.insert(42);
63 CPPUNIT_ASSERT (s.count(42) == 1);
64 size_t count = s.erase(42);
65 CPPUNIT_ASSERT (count == 1);
66}
GLuint GLuint GLsizei count
Definition: gl.h:1545

◆ set2()

void SetTest::set2 ( )
protected

Definition at line 68 of file set_test.cpp.

69{
70 typedef set<int, less<int> > int_set;
71 int_set s;
73 CPPUNIT_ASSERT (p.second == true);
74 p = s.insert(42);
75 CPPUNIT_ASSERT (p.second == false);
76
77 int array1 [] = { 1, 3, 6, 7 };
78 s.insert(array1, array1 + 4);
79 CPPUNIT_ASSERT (distance(s.begin(), s.end()) == 5);
80
81 int_set s2;
82 s2.swap(s);
83 CPPUNIT_ASSERT (distance(s2.begin(), s2.end()) == 5);
84 CPPUNIT_ASSERT (distance(s.begin(), s.end()) == 0);
85
86 int_set s3;
87 s3.swap(s);
88 s3.swap(s2);
89 CPPUNIT_ASSERT (distance(s.begin(), s.end()) == 0);
90 CPPUNIT_ASSERT (distance(s2.begin(), s2.end()) == 0);
91 CPPUNIT_ASSERT (distance(s3.begin(), s3.end()) == 5);
92}
GLsizei GLsizei GLfloat distance
Definition: glext.h:11755
GLfloat GLfloat p
Definition: glext.h:8902
struct S2 s2

◆ specialized_less()

void SetTest::specialized_less ( )
protected

Definition at line 223 of file set_test.cpp.

224{
226 s.insert(SetTestClass(1));
227 s.insert(SetTestClass(3));
228 s.insert(SetTestClass(2));
229 s.insert(SetTestClass(0));
230
231 set<SetTestClass>::iterator sit(s.begin()), sitEnd(s.end());
232 int i = 0;
233 for (; sit != sitEnd; ++sit, ++i) {
234 CPPUNIT_ASSERT( sit->data() == i );
235 }
236}

◆ template_methods()

void SetTest::template_methods ( )
protected

Definition at line 392 of file set_test.cpp.

393{
394#if defined (STLPORT) && defined (_STLP_USE_CONTAINERS_EXTENSION)
395 {
396 typedef set<Key, KeyCmp> KeySet;
397 KeySet keySet;
398 keySet.insert(Key(1));
399 keySet.insert(Key(2));
400 keySet.insert(Key(3));
401 keySet.insert(Key(4));
402
403 CPPUNIT_ASSERT( keySet.count(Key(1)) == 1 );
404 CPPUNIT_ASSERT( keySet.count(1) == 1 );
405 CPPUNIT_ASSERT( keySet.count(5) == 0 );
406
407 CPPUNIT_ASSERT( keySet.find(2) != keySet.end() );
408 CPPUNIT_ASSERT( keySet.lower_bound(2) != keySet.end() );
409 CPPUNIT_ASSERT( keySet.upper_bound(2) != keySet.end() );
410 CPPUNIT_ASSERT( keySet.equal_range(2) != make_pair(keySet.begin(), keySet.end()) );
411
412 KeySet const& ckeySet = keySet;
413 CPPUNIT_ASSERT( ckeySet.find(2) != ckeySet.end() );
414 CPPUNIT_ASSERT( ckeySet.lower_bound(2) != ckeySet.end() );
415 CPPUNIT_ASSERT( ckeySet.upper_bound(2) != ckeySet.end() );
416 CPPUNIT_ASSERT( ckeySet.equal_range(2) != make_pair(ckeySet.begin(), ckeySet.end()) );
417 }
418
419 {
420 typedef set<Key*, KeyCmpPtr> KeySet;
421 KeySet keySet;
422 Key key1(1), key2(2), key3(3), key4(4);
423 keySet.insert(&key1);
424 keySet.insert(&key2);
425 keySet.insert(&key3);
426 keySet.insert(&key4);
427
428 CPPUNIT_ASSERT( keySet.count(1) == 1 );
429 CPPUNIT_ASSERT( keySet.count(5) == 0 );
430
431 CPPUNIT_ASSERT( keySet.find(2) != keySet.end() );
432 CPPUNIT_ASSERT( keySet.lower_bound(2) != keySet.end() );
433 CPPUNIT_ASSERT( keySet.upper_bound(2) != keySet.end() );
434 CPPUNIT_ASSERT( keySet.equal_range(2) != make_pair(keySet.begin(), keySet.end()) );
435
436 KeySet const& ckeySet = keySet;
437 CPPUNIT_ASSERT( ckeySet.find(2) != ckeySet.end() );
438 CPPUNIT_ASSERT( ckeySet.lower_bound(2) != ckeySet.end() );
439 CPPUNIT_ASSERT( ckeySet.upper_bound(2) != ckeySet.end() );
440 CPPUNIT_ASSERT( ckeySet.equal_range(2) != make_pair(ckeySet.begin(), ckeySet.end()) );
441 }
442 {
443 typedef multiset<Key, KeyCmp> KeySet;
444 KeySet keySet;
445 keySet.insert(Key(1));
446 keySet.insert(Key(2));
447 keySet.insert(Key(3));
448 keySet.insert(Key(4));
449
450 CPPUNIT_ASSERT( keySet.count(Key(1)) == 1 );
451 CPPUNIT_ASSERT( keySet.count(1) == 1 );
452 CPPUNIT_ASSERT( keySet.count(5) == 0 );
453
454 CPPUNIT_ASSERT( keySet.find(2) != keySet.end() );
455 CPPUNIT_ASSERT( keySet.lower_bound(2) != keySet.end() );
456 CPPUNIT_ASSERT( keySet.upper_bound(2) != keySet.end() );
457 CPPUNIT_ASSERT( keySet.equal_range(2) != make_pair(keySet.begin(), keySet.end()) );
458
459 KeySet const& ckeySet = keySet;
460 CPPUNIT_ASSERT( ckeySet.find(2) != ckeySet.end() );
461 CPPUNIT_ASSERT( ckeySet.lower_bound(2) != ckeySet.end() );
462 CPPUNIT_ASSERT( ckeySet.upper_bound(2) != ckeySet.end() );
463 CPPUNIT_ASSERT( ckeySet.equal_range(2) != make_pair(ckeySet.begin(), ckeySet.end()) );
464 }
465
466 {
468 KeySet keySet;
469 Key key1(1), key2(2), key3(3), key4(4);
470 keySet.insert(&key1);
471 keySet.insert(&key2);
472 keySet.insert(&key3);
473 keySet.insert(&key4);
474
475 CPPUNIT_ASSERT( keySet.count(1) == 1 );
476 CPPUNIT_ASSERT( keySet.count(5) == 0 );
477
478 CPPUNIT_ASSERT( keySet.find(2) != keySet.end() );
479 CPPUNIT_ASSERT( keySet.lower_bound(2) != keySet.end() );
480 CPPUNIT_ASSERT( keySet.upper_bound(2) != keySet.end() );
481 CPPUNIT_ASSERT( keySet.equal_range(2) != make_pair(keySet.begin(), keySet.end()) );
482
483 KeySet const& ckeySet = keySet;
484 CPPUNIT_ASSERT( ckeySet.find(2) != ckeySet.end() );
485 CPPUNIT_ASSERT( ckeySet.lower_bound(2) != ckeySet.end() );
486 CPPUNIT_ASSERT( ckeySet.upper_bound(2) != ckeySet.end() );
487 CPPUNIT_ASSERT( ckeySet.equal_range(2) != make_pair(ckeySet.begin(), ckeySet.end()) );
488 }
489#endif
490}
pair< _T1, _T2 > _STLP_CALL make_pair(_T1 __x, _T2 __y)
Definition: _pair.h:124
Definition: _set.h:220
iterator insert(const value_type &__x)
Definition: _set.h:339
pair< iterator, bool > insert(const value_type &__x)
Definition: _set.h:168
GLuint64EXT GLuint GLuint GLenum GLenum GLuint GLuint GLenum GLuint GLuint key1
Definition: glext.h:10608

Member Data Documentation

◆ CPPUNIT_IGNORE

SetTest::CPPUNIT_IGNORE
private

Definition at line 31 of file set_test.cpp.


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