ReactOS 0.4.15-dev-7942-gd23573b
HashTest Class Reference
Inheritance diagram for HashTest:
Collaboration diagram for HashTest:

Protected Member Functions

void hmap1 ()
 
void hmmap1 ()
 
void hmmap2 ()
 
void hmset1 ()
 
void hset2 ()
 
void insert_erase ()
 
void allocator_with_state ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (HashTest)
 
 CPPUNIT_TEST (hmap1)
 
 CPPUNIT_TEST (hmmap1)
 
 CPPUNIT_TEST (hmmap2)
 
 CPPUNIT_TEST (hmset1)
 
 CPPUNIT_TEST (hset2)
 
 CPPUNIT_TEST (insert_erase)
 
 CPPUNIT_TEST (allocator_with_state)
 
 CPPUNIT_TEST_SUITE_END ()
 

Private Attributes

 CPPUNIT_IGNORE
 

Detailed Description

Definition at line 33 of file hash_test.cpp.

Member Function Documentation

◆ allocator_with_state()

void HashTest::allocator_with_state ( )
protected

Definition at line 377 of file hash_test.cpp.

378{
379#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
380 char buf1[2048];
381 StackAllocator<int> stack1(buf1, buf1 + sizeof(buf1));
382
383 char buf2[2048];
384 StackAllocator<int> stack2(buf2, buf2 + sizeof(buf2));
385
386 {
388 HashSetInt hint1(10, hash<int>(), equal_to<int>(), stack1);
389
390 int i;
391 for (i = 0; i < 5; ++i)
392 hint1.insert(i);
393 HashSetInt hint1Cpy(hint1);
394
395 HashSetInt hint2(10, hash<int>(), equal_to<int>(), stack2);
396 for (; i < 10; ++i)
397 hint2.insert(i);
398 HashSetInt hint2Cpy(hint2);
399
400 hint1.swap(hint2);
401
402 CPPUNIT_ASSERT( hint1.get_allocator().swaped() );
403 CPPUNIT_ASSERT( hint2.get_allocator().swaped() );
404
405 CPPUNIT_ASSERT( hint1.get_allocator() == stack2 );
406 CPPUNIT_ASSERT( hint2.get_allocator() == stack1 );
407 }
408 CPPUNIT_ASSERT( stack1.ok() );
409 CPPUNIT_ASSERT( stack2.ok() );
410#endif
411}
#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
Definition: _hash_fun.h:40

◆ CPPUNIT_TEST() [1/7]

HashTest::CPPUNIT_TEST ( allocator_with_state  )
private

◆ CPPUNIT_TEST() [2/7]

HashTest::CPPUNIT_TEST ( hmap1  )
private

◆ CPPUNIT_TEST() [3/7]

HashTest::CPPUNIT_TEST ( hmmap1  )
private

◆ CPPUNIT_TEST() [4/7]

HashTest::CPPUNIT_TEST ( hmmap2  )
private

◆ CPPUNIT_TEST() [5/7]

HashTest::CPPUNIT_TEST ( hmset1  )
private

◆ CPPUNIT_TEST() [6/7]

HashTest::CPPUNIT_TEST ( hset2  )
private

◆ CPPUNIT_TEST() [7/7]

HashTest::CPPUNIT_TEST ( insert_erase  )
private

◆ CPPUNIT_TEST_SUITE()

HashTest::CPPUNIT_TEST_SUITE ( HashTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

HashTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ hmap1()

void HashTest::hmap1 ( )
protected

Definition at line 76 of file hash_test.cpp.

77{
78#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
80 maptype m;
81 // Store mappings between roman numerals and decimals.
82 m['l'] = "50";
83 m['x'] = "20"; // Deliberate mistake.
84 m['v'] = "5";
85 m['i'] = "1";
86 CPPUNIT_ASSERT( !strcmp(m['x'].c_str(),"20") );
87 m['x'] = "10"; // Correct mistake.
88 CPPUNIT_ASSERT( !strcmp(m['x'].c_str(),"10") );
89
90 CPPUNIT_ASSERT( !strcmp(m['z'].c_str(),"") );
91
92 CPPUNIT_ASSERT( m.count('z')==1 );
94
95 CPPUNIT_ASSERT(p.second);
96
97 p = m.insert(pair<const char, crope>('c', crope("100")));
98 CPPUNIT_ASSERT(!p.second);
99
100 //Some iterators compare check, really compile time checks
101 maptype::iterator ite(m.begin());
102 maptype::const_iterator cite(m.begin());
103 cite = m.begin();
104 maptype const& cm = m;
105 cite = cm.begin();
106 CPPUNIT_ASSERT( ite == cite );
107 CPPUNIT_ASSERT( !(ite != cite) );
108 CPPUNIT_ASSERT( cite == ite );
109 CPPUNIT_ASSERT( !(cite != ite) );
110#endif
111}
rope< char, allocator< char > > crope
Definition: _rope.h:2297
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLfloat GLfloat p
Definition: glext.h:8902
const GLfloat * m
Definition: glext.h:10848
Definition: _pair.h:47

◆ hmmap1()

void HashTest::hmmap1 ( )
protected

Definition at line 113 of file hash_test.cpp.

114{
115#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
117 mmap m;
118 CPPUNIT_ASSERT(m.count('X')==0);
119 m.insert(pair<const char,int>('X', 10)); // Standard way.
120 CPPUNIT_ASSERT(m.count('X')==1);
121// m.insert('X', 20); // Non-standard, but very convenient!
122 m.insert(pair<const char,int>('X', 20)); // jbuck: standard way
123 CPPUNIT_ASSERT(m.count('X')==2);
124// m.insert('Y', 32);
125 m.insert(pair<const char,int>('Y', 32)); // jbuck: standard way
126 mmap::iterator i = m.find('X'); // Find first match.
127
128 CPPUNIT_ASSERT((*i).first=='X');
129 CPPUNIT_ASSERT((*i).second==10);
130 i++;
131 CPPUNIT_ASSERT((*i).first=='X');
132 CPPUNIT_ASSERT((*i).second==20);
133 i++;
134 CPPUNIT_ASSERT((*i).first=='Y');
135 CPPUNIT_ASSERT((*i).second==32);
136 i++;
137 CPPUNIT_ASSERT(i==m.end());
138
139 size_t count = m.erase('X');
141
142 //Some iterators compare check, really compile time checks
143 mmap::iterator ite(m.begin());
144 mmap::const_iterator cite(m.begin());
145 CPPUNIT_ASSERT( ite == cite );
146 CPPUNIT_ASSERT( !(ite != cite) );
147 CPPUNIT_ASSERT( cite == ite );
148 CPPUNIT_ASSERT( !(cite != ite) );
149
150 typedef hash_multimap<size_t, size_t> HMapType;
151 HMapType hmap;
152
153 //We fill the map to implicitely start a rehash.
154 for (size_t counter = 0; counter < 3077; ++counter)
155 hmap.insert(HMapType::value_type(1, counter));
156
157 hmap.insert(HMapType::value_type(12325, 1));
158 hmap.insert(HMapType::value_type(12325, 2));
159
160 CPPUNIT_ASSERT( hmap.count(12325) == 2 );
161
162 //At this point 23 goes to the same bucket as 12325, it used to reveal a bug.
163 hmap.insert(HMapType::value_type(23, 0));
164
165 CPPUNIT_ASSERT( hmap.count(12325) == 2 );
166#endif
167}
iterator insert(const value_type &__obj)
Definition: _hash_map.h:371
GLuint GLuint GLsizei count
Definition: gl.h:1545

◆ hmmap2()

void HashTest::hmmap2 ( )
protected

Definition at line 248 of file hash_test.cpp.

249{
250#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
251 hashType h;
252 mapType m;
253
254 // CAUTION the following configurations WORKS in our setting
255 // for (int id = 1; id != 400; id ++) and int key = (id %3 == 0 ? 3 : id)
256 // for (int id = 200; id != 1; id --) and int key = (id %3 == 0 ? 3 : id)
257 // for (int id = 300; id != 1; id --) and int key = (id %3 == 0 ? 3 : id)
258 // for (int id = 400; id != 1; id --) and int key = (id %3 == 0 ? 1 : id)
259 // for (int id = 4000; id != 1; id --) and int key = (id %3 == 0 ? 1 : id)
260 //
261 // whereas these will FAIL
262 // for (int id = 400; id != 1; id --) and int key = (id %3 == 0 ? 3 : id)
263 // for (int id = 4000; id != 1; id --) and int key = (id %3 == 0 ? 3 : id)
264 //
265
266 for ( int id = 400; id != 1; id-- ) {
267 // generate many entries with key 3, fill up with unique keys. Data is unique (needed in check_keys())
268 int key = (id % 3 == 0 ? 3 : id);
269
270 // keep hash_multi_map and multimap in sync
271 h.insert(make_pair(key, id));
272 m.insert(make_pair(key, id));
273
274 // check whether both contain the same elements
275 check_keys( h, m );
276 }
277#endif
278}
pair< _T1, _T2 > _STLP_CALL make_pair(_T1 __x, _T2 __y)
Definition: _pair.h:124
GLuint id
Definition: glext.h:5910
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
Definition: copy.c:22

◆ hmset1()

void HashTest::hmset1 ( )
protected

Definition at line 280 of file hash_test.cpp.

281{
282#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
283 hmset s;
284 CPPUNIT_ASSERT( s.count(star) == 0 );
285 s.insert(star);
286 CPPUNIT_ASSERT( s.count(star) == 1 );
287 s.insert(star);
288 CPPUNIT_ASSERT( s.count(star) == 2 );
289 hmset::iterator i = s.find(char(40));
290 CPPUNIT_ASSERT( i == s.end() );
291
292 i = s.find(star);
293 CPPUNIT_ASSERT( i != s.end() )
294 CPPUNIT_ASSERT( *i == '*' );
295 CPPUNIT_ASSERT( s.erase(star) == 2 );
296#endif
297}
GLdouble s
Definition: gl.h:2039

◆ hset2()

void HashTest::hset2 ( )
protected

Definition at line 298 of file hash_test.cpp.

299{
300#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
303 CPPUNIT_ASSERT( p.second );
304 CPPUNIT_ASSERT( *(p.first) == 42 );
305
306 p = s.insert(42);
307 CPPUNIT_ASSERT( !p.second );
308#endif
309}

◆ insert_erase()

void HashTest::insert_erase ( )
protected

Definition at line 311 of file hash_test.cpp.

312{
313#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
315 typedef hmap::value_type val_type;
316 {
317 hmap values;
318# if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x564)
319 CPPUNIT_ASSERT( values.insert(val_type("foo", 0)).second );
320 CPPUNIT_ASSERT( values.insert(val_type("bar", 0)).second );
321 CPPUNIT_ASSERT( values.insert(val_type("abc", 0)).second );
322# else
323 CPPUNIT_ASSERT( values.insert(hmap::value_type("foo", 0)).second );
324 CPPUNIT_ASSERT( values.insert(hmap::value_type("bar", 0)).second );
325 CPPUNIT_ASSERT( values.insert(hmap::value_type("abc", 0)).second );
326# endif
327
328 CPPUNIT_ASSERT( values.erase("foo") == 1 );
329 CPPUNIT_ASSERT( values.erase("bar") == 1 );
330 CPPUNIT_ASSERT( values.erase("abc") == 1 );
331 }
332
333 {
334 hmap values;
335# if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x564)
336 CPPUNIT_ASSERT( values.insert(val_type("foo", 0)).second );
337 CPPUNIT_ASSERT( values.insert(val_type("bar", 0)).second );
338 CPPUNIT_ASSERT( values.insert(val_type("abc", 0)).second );
339# else
340 CPPUNIT_ASSERT( values.insert(hmap::value_type("foo", 0)).second );
341 CPPUNIT_ASSERT( values.insert(hmap::value_type("bar", 0)).second );
342 CPPUNIT_ASSERT( values.insert(hmap::value_type("abc", 0)).second );
343# endif
344
345 CPPUNIT_ASSERT( values.erase("abc") == 1 );
346 CPPUNIT_ASSERT( values.erase("bar") == 1 );
347 CPPUNIT_ASSERT( values.erase("foo") == 1 );
348 }
349#endif
350}
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666

Member Data Documentation

◆ CPPUNIT_IGNORE

HashTest::CPPUNIT_IGNORE
private

Definition at line 37 of file hash_test.cpp.


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