Remove CDS_CXX11_DEFAULT_FUNCTION_TEMPLATE_ARGS_SUPPORT and emilating code
[libcds.git] / tests / test-hdr / set / hdr_striped_set.h
1 //$$CDS-header$$
2
3 #ifndef __CDSTEST_HDR_STRIPED_SET_H
4 #define __CDSTEST_HDR_STRIPED_SET_H
5
6 #include "cppunit/cppunit_proxy.h"
7 #include "size_check.h"
8
9 #include <cds/opt/hash.h>
10 #include <cds/os/timer.h>
11 #include <cds/ref.h>
12 #include <algorithm>    // random_shuffle
13
14 // forward namespace declaration
15 namespace cds {
16     namespace container {}
17     namespace opt {}
18 }
19
20 namespace set {
21     using misc::check_size;
22
23     namespace cc = cds::container;
24     namespace co = cds::opt;
25
26
27     class StripedSetHdrTest: public CppUnitMini::TestCase
28     {
29     public:
30         struct stat
31         {
32             unsigned int nFindCount     ;   // count of find-functor calling
33             unsigned int nEnsureNewCount;
34             unsigned int nEnsureCount;
35
36             stat()
37             {
38                 memset( this, 0, sizeof(*this));
39             }
40
41             void copy( stat const& s )
42             {
43                 nFindCount = s.nFindCount;
44                 nEnsureCount = s.nEnsureCount;
45                 nEnsureNewCount = s.nEnsureNewCount;
46             }
47         };
48
49         struct item: public stat
50         {
51             int nKey;
52             int nVal;
53
54             item()
55             {}
56
57             item( int key )
58                 : nKey( key )
59                 , nVal( key )
60             {}
61
62             item (int key, int val )
63                 : nKey(key)
64                 , nVal( val )
65             {}
66
67             item( std::pair<int,int> const& p )
68                 : nKey( p.first )
69                 , nVal( p.second )
70             {}
71
72             item( item const& i )
73                 : nKey( i.nKey )
74                 , nVal( i.nVal )
75             {}
76
77             item& operator=(item const& i)
78             {
79                 nKey = i.nKey;
80                 nVal = i.nVal;
81                 stat::copy(i);
82
83                 return *this;
84             }
85
86
87 #ifdef CDS_MOVE_SEMANTICS_SUPPORT
88             item( item&& i )
89                 : nKey( i.nKey )
90                 , nVal( i.nVal )
91             {}
92
93             //item& operator=(item&& i)
94             //{
95             //    nKey = i.nKey;
96             //    nVal = i.nVal;
97             //    return *this;
98             //}
99 #endif
100
101             int key() const
102             {
103                 return nKey;
104             }
105
106             int val() const
107             {
108                 return nVal;
109             }
110         };
111
112         struct hash_int {
113             size_t operator()( int i ) const
114             {
115                 return co::v::hash<int>()( i );
116             }
117
118             size_t operator()( std::pair<int,int> const& i ) const
119             {
120                 return co::v::hash<int>()( i.first );
121             }
122
123             template <typename Item>
124             size_t operator()( Item const& i ) const
125             {
126                 return (*this)( i.key() );
127             }
128         };
129
130         struct simple_item_counter {
131             size_t  m_nCount;
132
133             simple_item_counter()
134                 : m_nCount(0)
135             {}
136
137             size_t operator ++()
138             {
139                 return ++m_nCount;
140             }
141
142             size_t operator --()
143             {
144                 return --m_nCount;
145             }
146
147             void reset()
148             {
149                 m_nCount = 0;
150             }
151
152             operator size_t() const
153             {
154                 return m_nCount;
155             }
156         };
157
158         template <typename T>
159         struct less
160         {
161             bool operator ()(const T& v1, const T& v2 ) const
162             {
163                 return v1.key() < v2.key();
164             }
165
166             template <typename Q>
167             bool operator ()(const T& v1, const Q& v2 ) const
168             {
169                 return v1.key() < v2;
170             }
171
172             template <typename Q>
173             bool operator ()(const Q& v1, const T& v2 ) const
174             {
175                 return v1 < v2.key();
176             }
177
178             bool operator ()( std::pair<int, int> const& v1, const T& v2 ) const
179             {
180                 return v1.first < v2.key();
181             }
182
183             bool operator ()(const T& v1, std::pair<int, int> const& v2 ) const
184             {
185                 return v1.key() < v2.first;
186             }
187         };
188
189         template <typename T>
190         struct cmp {
191             int operator ()(const T& v1, const T& v2 ) const
192             {
193                 if ( v1.key() < v2.key() )
194                     return -1;
195                 return v1.key() > v2.key() ? 1 : 0;
196             }
197
198             template <typename Q>
199             int operator ()(const T& v1, const Q& v2 ) const
200             {
201                 if ( v1.key() < v2 )
202                     return -1;
203                 return v1.key() > v2 ? 1 : 0;
204             }
205
206             template <typename Q>
207             int operator ()(const Q& v1, const T& v2 ) const
208             {
209                 if ( v1 < v2.key() )
210                     return -1;
211                 return v1 > v2.key() ? 1 : 0;
212             }
213
214             int operator()( std::pair<int,int> const& v1, T const& v2 ) const
215             {
216                 if ( v1.first < v2.key() )
217                     return -1;
218                 return v1.first > v2.key() ? 1 : 0;
219             }
220
221             int operator()( T const& v1, std::pair<int,int> const& v2 ) const
222             {
223                 if ( v1.key() < v2.first )
224                     return -1;
225                 return v1.key() > v2.first ? 1 : 0;
226             }
227         };
228
229         template <typename T>
230         struct equal
231         {
232             bool operator ()(const T& v1, const T& v2 ) const
233             {
234                 return v1.key() == v2.key();
235             }
236
237             template <typename Q>
238             bool operator ()(const T& v1, const Q& v2 ) const
239             {
240                 return v1.key() == v2;
241             }
242
243             template <typename Q>
244             bool operator ()(const Q& v1, const T& v2 ) const
245             {
246                 return v1 == v2.key();
247             }
248
249             bool operator ()( std::pair<int, int> const& v1, const T& v2 ) const
250             {
251                 return v1.first == v2.key();
252             }
253
254             bool operator ()(const T& v1, std::pair<int, int> const& v2 ) const
255             {
256                 return v1.key() == v2.first;
257             }
258         };
259
260         struct find_functor
261         {
262             template <typename Item, typename T>
263             void operator()( Item& i, T& val )
264             {
265                 ++i.nFindCount;
266             }
267             template <typename Item, typename T>
268             void operator()( Item& i, T const& val )
269             {
270                 ++i.nFindCount;
271             }
272         };
273
274         template <typename Item>
275         struct copy_found
276         {
277             Item    m_found;
278
279             template <typename T>
280             void operator()( Item& i, T& /*val*/ )
281             {
282                 m_found = i;
283             }
284
285             void operator()( Item const& i )
286             {
287                 m_found = i;
288             }
289         };
290
291         struct insert_functor
292         {
293             template <typename Item>
294             void operator()(Item& i )
295             {
296                 i.nVal = i.nKey * 100;
297             }
298         };
299
300         template <typename Item, typename Q>
301         static void ensure_func( bool bNew, Item& i, Q& /*val*/ )
302         {
303             if ( bNew )
304                 ++i.nEnsureNewCount;
305             else
306                 ++i.nEnsureCount;
307         }
308
309         struct ensure_functor
310         {
311             template <typename Item, typename Q>
312             void operator()( bool bNew, Item& i, Q& val )
313             {
314                 ensure_func( bNew, i, val );
315             }
316         };
317
318     public:
319         template <class Set>
320         void test_striped()
321         {
322             Set s( 30 );
323             CPPUNIT_ASSERT( s.bucket_count() == 32 );
324             CPPUNIT_ASSERT( s.lock_count() == 32 );
325
326             test_striped_with( s );
327         }
328
329         template <class Set>
330         void test_striped_with( Set& s )
331         {
332             cds::OS::Timer    timer;
333
334             test_int_with( s );
335
336             // Resizing test
337             for ( int i = 0; i < 10000; i++ ) {
338                 s.insert( i );
339             }
340
341             CPPUNIT_MSG( "   Duration=" << timer.duration() );
342         }
343
344         template <class Set>
345         void test_int_with( Set& s)
346         {
347             typedef typename Set::value_type    value_type;
348
349             item itm;
350             int key;
351
352             // insert/find test
353             CPPUNIT_ASSERT( !s.find( 10 ) );
354             CPPUNIT_ASSERT( s.insert( 10 ));
355             CPPUNIT_ASSERT( !s.empty() );
356             CPPUNIT_ASSERT( check_size( s, 1 ));
357             CPPUNIT_ASSERT( s.find( 10 ) );
358
359             CPPUNIT_ASSERT( !s.insert( 10 ));
360             CPPUNIT_ASSERT( !s.empty() );
361             CPPUNIT_ASSERT( check_size( s, 1 ));
362
363             CPPUNIT_ASSERT( !s.find( 20 ) );
364             CPPUNIT_ASSERT( s.insert( std::make_pair(20, 25) ));
365             CPPUNIT_ASSERT( !s.empty() );
366             CPPUNIT_ASSERT( check_size( s, 2 ));
367             CPPUNIT_ASSERT( s.find( 10 ) );
368             CPPUNIT_ASSERT( s.find( key = 20 ) );
369             CPPUNIT_ASSERT( s.find( key, find_functor() ) );
370             {
371                 copy_found<item> f;
372                 key = 20;
373                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
374                 CPPUNIT_ASSERT( f.m_found.nKey == 20 );
375                 CPPUNIT_ASSERT( f.m_found.nVal == 25 );
376                 CPPUNIT_ASSERT( f.m_found.nFindCount == 1 );
377             }
378             {
379                 copy_found<item> f;
380                 key = 20;
381                 CPPUNIT_ASSERT( s.find( key, find_functor() ) );
382                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
383                 CPPUNIT_ASSERT( f.m_found.nKey == 20 );
384                 CPPUNIT_ASSERT( f.m_found.nVal == 25 );
385                 CPPUNIT_ASSERT( f.m_found.nFindCount == 2 );
386             }
387             CPPUNIT_ASSERT( !s.empty() );
388             CPPUNIT_ASSERT( check_size( s, 2 ));
389
390             CPPUNIT_ASSERT( !s.find( 25 ) );
391             CPPUNIT_ASSERT( s.insert( std::make_pair(25, -1), insert_functor() ));
392             CPPUNIT_ASSERT( !s.empty() );
393             CPPUNIT_ASSERT( check_size( s, 3 ));
394             {
395                 copy_found<item> f;
396                 key = 25;
397                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
398                 CPPUNIT_ASSERT( f.m_found.nKey == 25 );
399                 CPPUNIT_ASSERT( f.m_found.nVal == 2500 );
400             }
401
402             // ensure test
403             key = 10;
404             {
405                 copy_found<item> f;
406                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
407                 CPPUNIT_ASSERT( f.m_found.nKey == 10 );
408                 CPPUNIT_ASSERT( f.m_found.nVal == 10 );
409                 CPPUNIT_ASSERT( f.m_found.nEnsureCount == 0 );
410                 CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 0 );
411             }
412             std::pair<bool, bool> ensureResult = s.ensure( key, ensure_functor() );
413             CPPUNIT_ASSERT( ensureResult.first && !ensureResult.second );
414             CPPUNIT_ASSERT( !s.empty() );
415             CPPUNIT_ASSERT( check_size( s, 3 ));
416             {
417                 copy_found<item> f;
418                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
419                 CPPUNIT_ASSERT( f.m_found.nKey == 10 );
420                 CPPUNIT_ASSERT( f.m_found.nVal == 10 );
421                 CPPUNIT_ASSERT( f.m_found.nEnsureCount == 1 );
422                 CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 0 );
423             }
424
425             ensureResult = s.ensure( std::make_pair(13, 1300), ensure_functor() );
426             CPPUNIT_ASSERT( ensureResult.first && ensureResult.second );
427             CPPUNIT_ASSERT( !s.empty() );
428             CPPUNIT_ASSERT( check_size( s, 4 ));
429             {
430                 copy_found<item> f;
431                 key = 13;
432                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
433                 CPPUNIT_ASSERT( f.m_found.nKey == 13 );
434                 CPPUNIT_ASSERT( f.m_found.nVal == 1300 );
435                 CPPUNIT_ASSERT( f.m_found.nEnsureCount == 0 );
436                 CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 1 );
437             }
438
439             // erase test
440             CPPUNIT_ASSERT( s.erase(13) );
441             CPPUNIT_ASSERT( !s.find( 13 ));
442             CPPUNIT_ASSERT( !s.empty() );
443             CPPUNIT_ASSERT( check_size( s, 3 ));
444             CPPUNIT_ASSERT( !s.erase(13) );
445             CPPUNIT_ASSERT( !s.empty() );
446             CPPUNIT_ASSERT( check_size( s, 3 ));
447
448             CPPUNIT_ASSERT( s.find( 10 ));
449             CPPUNIT_ASSERT( s.erase( 10 ));
450             CPPUNIT_ASSERT( !s.find( 10 ));
451             CPPUNIT_ASSERT( !s.empty() );
452             CPPUNIT_ASSERT( check_size( s, 2 ));
453             CPPUNIT_ASSERT( !s.erase(10) );
454             CPPUNIT_ASSERT( !s.empty() );
455             CPPUNIT_ASSERT( check_size( s, 2 ));
456
457             CPPUNIT_ASSERT( s.find(20) );
458             {
459                 copy_found<item> f;
460                 CPPUNIT_ASSERT( s.erase( 20, boost::ref(f) ));
461                 CPPUNIT_ASSERT( f.m_found.nKey == 20 );
462                 CPPUNIT_ASSERT( f.m_found.nVal == 25 );
463
464                 CPPUNIT_ASSERT( s.insert(235))
465                     CPPUNIT_ASSERT( s.erase( 235, boost::ref(f) ));
466                 CPPUNIT_ASSERT( f.m_found.nKey == 235 );
467                 CPPUNIT_ASSERT( f.m_found.nVal == 235 );
468             }
469             CPPUNIT_ASSERT( !s.find( 20 ));
470             CPPUNIT_ASSERT( !s.empty() );
471             CPPUNIT_ASSERT( check_size( s, 1 ));
472
473             s.clear();
474             CPPUNIT_ASSERT( s.empty() );
475             CPPUNIT_ASSERT( check_size( s, 0 ));
476
477 #       ifdef CDS_EMPLACE_SUPPORT
478             // emplace test
479             CPPUNIT_ASSERT( s.emplace( 151 )) ;  // key = 151,  val = 151
480             CPPUNIT_ASSERT( s.emplace( 174, 471 )) ;    // key = 174, val = 471
481             CPPUNIT_ASSERT( s.emplace( std::make_pair( 190, 91 ) )) ; // key == 190, val = 91
482             CPPUNIT_ASSERT( !s.empty() );
483             CPPUNIT_ASSERT( check_size( s, 3 ));
484
485             CPPUNIT_ASSERT( s.find(151));
486             CPPUNIT_ASSERT( s.find(174));
487             CPPUNIT_ASSERT( s.find(190));
488
489             {
490                 copy_found<item> f;
491                 key = 151;
492                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
493                 CPPUNIT_ASSERT( f.m_found.nKey == 151 );
494                 CPPUNIT_ASSERT( f.m_found.nVal == 151 );
495
496                 key = 174;
497                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
498                 CPPUNIT_ASSERT( f.m_found.nKey == 174 );
499                 CPPUNIT_ASSERT( f.m_found.nVal == 471 );
500
501                 key = 190;
502                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
503                 CPPUNIT_ASSERT( f.m_found.nKey == 190 );
504                 CPPUNIT_ASSERT( f.m_found.nVal == 91 );
505             }
506
507             s.clear();
508             CPPUNIT_ASSERT( s.empty() );
509             CPPUNIT_ASSERT( check_size( s, 0 ));
510 #       endif
511         }
512
513         template <class Set>
514         void test_striped2()
515         {
516             Set s( 30 );
517             CPPUNIT_ASSERT( s.bucket_count() == 32 );
518             CPPUNIT_ASSERT( s.lock_count() == 32 );
519
520             test_striped_with2( s );
521         }
522
523         template <class Set>
524         void test_striped_with2( Set& s )
525         {
526             cds::OS::Timer    timer;
527
528             test_int_with2( s );
529
530             // Resizing test
531             for ( int i = 0; i < 10000; i++ ) {
532                 s.insert( i );
533             }
534
535             CPPUNIT_MSG( "   Duration=" << timer.duration() );
536         }
537
538         template <class Set>
539         void test_int_with2( Set& s)
540         {
541             typedef typename Set::value_type    value_type;
542
543             item itm;
544             int key;
545
546             // insert/find test
547             CPPUNIT_ASSERT( !s.find( 10 ) );
548             CPPUNIT_ASSERT( s.insert( 10 ));
549             CPPUNIT_ASSERT( !s.empty() );
550             CPPUNIT_ASSERT( check_size( s, 1 ));
551             CPPUNIT_ASSERT( s.find( 10 ) );
552
553             CPPUNIT_ASSERT( !s.insert( 10 ));
554             CPPUNIT_ASSERT( !s.empty() );
555             CPPUNIT_ASSERT( check_size( s, 1 ));
556
557             CPPUNIT_ASSERT( !s.find_with( 20, less<value_type>() ) );
558             CPPUNIT_ASSERT( s.insert( std::make_pair(20, 25) ));
559             CPPUNIT_ASSERT( !s.empty() );
560             CPPUNIT_ASSERT( check_size( s, 2 ));
561             CPPUNIT_ASSERT( s.find( 10 ) );
562             CPPUNIT_ASSERT( s.find_with( key = 20, less<value_type>() ) );
563             CPPUNIT_ASSERT( s.find_with( key, less<value_type>(), find_functor() ) );
564             {
565                 copy_found<item> f;
566                 key = 20;
567                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
568                 CPPUNIT_ASSERT( f.m_found.nKey == 20 );
569                 CPPUNIT_ASSERT( f.m_found.nVal == 25 );
570                 CPPUNIT_ASSERT( f.m_found.nFindCount == 1 );
571             }
572             {
573                 copy_found<item> f;
574                 key = 20;
575                 CPPUNIT_ASSERT( s.find_with( 20, less<value_type>(), find_functor() ) );
576                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
577                 CPPUNIT_ASSERT( f.m_found.nKey == 20 );
578                 CPPUNIT_ASSERT( f.m_found.nVal == 25 );
579                 CPPUNIT_ASSERT( f.m_found.nFindCount == 2 );
580             }
581             CPPUNIT_ASSERT( !s.empty() );
582             CPPUNIT_ASSERT( check_size( s, 2 ));
583
584             CPPUNIT_ASSERT( !s.find( 25 ) );
585             CPPUNIT_ASSERT( s.insert( std::make_pair(25, -1), insert_functor() ));
586             CPPUNIT_ASSERT( !s.empty() );
587             CPPUNIT_ASSERT( check_size( s, 3 ));
588             {
589                 copy_found<item> f;
590                 key = 25;
591                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
592                 CPPUNIT_ASSERT( f.m_found.nKey == 25 );
593                 CPPUNIT_ASSERT( f.m_found.nVal == 2500 );
594             }
595
596             // ensure test
597             key = 10;
598             {
599                 copy_found<item> f;
600                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
601                 CPPUNIT_ASSERT( f.m_found.nKey == 10 );
602                 CPPUNIT_ASSERT( f.m_found.nVal == 10 );
603                 CPPUNIT_ASSERT( f.m_found.nEnsureCount == 0 );
604                 CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 0 );
605             }
606             std::pair<bool, bool> ensureResult = s.ensure( key, ensure_functor() );
607             CPPUNIT_ASSERT( ensureResult.first && !ensureResult.second );
608             CPPUNIT_ASSERT( !s.empty() );
609             CPPUNIT_ASSERT( check_size( s, 3 ));
610             {
611                 copy_found<item> f;
612                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
613                 CPPUNIT_ASSERT( f.m_found.nKey == 10 );
614                 CPPUNIT_ASSERT( f.m_found.nVal == 10 );
615                 CPPUNIT_ASSERT( f.m_found.nEnsureCount == 1 );
616                 CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 0 );
617             }
618
619             ensureResult = s.ensure( std::make_pair(13, 1300), ensure_functor() );
620             CPPUNIT_ASSERT( ensureResult.first && ensureResult.second );
621             CPPUNIT_ASSERT( !s.empty() );
622             CPPUNIT_ASSERT( check_size( s, 4 ));
623             {
624                 copy_found<item> f;
625                 key = 13;
626                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
627                 CPPUNIT_ASSERT( f.m_found.nKey == 13 );
628                 CPPUNIT_ASSERT( f.m_found.nVal == 1300 );
629                 CPPUNIT_ASSERT( f.m_found.nEnsureCount == 0 );
630                 CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 1 );
631             }
632
633             // erase test
634             CPPUNIT_ASSERT( s.erase(13) );
635             CPPUNIT_ASSERT( !s.find( 13 ));
636             CPPUNIT_ASSERT( !s.empty() );
637             CPPUNIT_ASSERT( check_size( s, 3 ));
638             CPPUNIT_ASSERT( !s.erase(13) );
639             CPPUNIT_ASSERT( !s.empty() );
640             CPPUNIT_ASSERT( check_size( s, 3 ));
641
642             CPPUNIT_ASSERT( s.find( 10 ));
643             CPPUNIT_ASSERT( s.erase_with( 10, less<value_type>() ));
644             CPPUNIT_ASSERT( !s.find( 10 ));
645             CPPUNIT_ASSERT( !s.empty() );
646             CPPUNIT_ASSERT( check_size( s, 2 ));
647             CPPUNIT_ASSERT( !s.erase_with( 10, less<value_type>() ) );
648             CPPUNIT_ASSERT( !s.empty() );
649             CPPUNIT_ASSERT( check_size( s, 2 ));
650
651             CPPUNIT_ASSERT( s.find(20) );
652             {
653                 copy_found<item> f;
654                 CPPUNIT_ASSERT( s.erase( 20, boost::ref(f) ));
655                 CPPUNIT_ASSERT( f.m_found.nKey == 20 );
656                 CPPUNIT_ASSERT( f.m_found.nVal == 25 );
657
658                 CPPUNIT_ASSERT( s.insert(235))
659                 CPPUNIT_ASSERT( s.erase_with( 235, less<value_type>(), boost::ref(f) ));
660                 CPPUNIT_ASSERT( f.m_found.nKey == 235 );
661                 CPPUNIT_ASSERT( f.m_found.nVal == 235 );
662             }
663             CPPUNIT_ASSERT( !s.find( 20 ));
664             CPPUNIT_ASSERT( !s.empty() );
665             CPPUNIT_ASSERT( check_size( s, 1 ));
666
667             s.clear();
668             CPPUNIT_ASSERT( s.empty() );
669             CPPUNIT_ASSERT( check_size( s, 0 ));
670
671 #       ifdef CDS_EMPLACE_SUPPORT
672             // emplace test
673             CPPUNIT_ASSERT( s.emplace( 151 )) ;  // key = 151,  val = 151
674             CPPUNIT_ASSERT( s.emplace( 174, 471 )) ;    // key = 174, val = 471
675             CPPUNIT_ASSERT( s.emplace( std::make_pair( 190, 91 ) )) ; // key == 190, val = 91
676             CPPUNIT_ASSERT( !s.empty() );
677             CPPUNIT_ASSERT( check_size( s, 3 ));
678
679             CPPUNIT_ASSERT( s.find(151));
680             CPPUNIT_ASSERT( s.find(174));
681             CPPUNIT_ASSERT( s.find(190));
682
683             {
684                 copy_found<item> f;
685                 key = 151;
686                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
687                 CPPUNIT_ASSERT( f.m_found.nKey == 151 );
688                 CPPUNIT_ASSERT( f.m_found.nVal == 151 );
689
690                 key = 174;
691                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
692                 CPPUNIT_ASSERT( f.m_found.nKey == 174 );
693                 CPPUNIT_ASSERT( f.m_found.nVal == 471 );
694
695                 key = 190;
696                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
697                 CPPUNIT_ASSERT( f.m_found.nKey == 190 );
698                 CPPUNIT_ASSERT( f.m_found.nVal == 91 );
699             }
700
701             s.clear();
702             CPPUNIT_ASSERT( s.empty() );
703             CPPUNIT_ASSERT( check_size( s, 0 ));
704 #       endif
705         }
706
707         void Striped_list();
708         void Striped_vector();
709         void Striped_set();
710         void Striped_hashset();
711         void Striped_slist();
712         void Striped_boost_list();
713         void Striped_boost_vector();
714         void Striped_boost_stable_vector();
715         void Striped_boost_flat_set();
716         void Striped_boost_set();
717         void Striped_boost_unordered_set();
718
719         void Refinable_list();
720         void Refinable_vector();
721         void Refinable_set();
722         void Refinable_hashset();
723         void Refinable_slist();
724         void Refinable_boost_list();
725         void Refinable_boost_vector();
726         void Refinable_boost_stable_vector();
727         void Refinable_boost_flat_set();
728         void Refinable_boost_set();
729         void Refinable_boost_unordered_set();
730
731         CPPUNIT_TEST_SUITE(StripedSetHdrTest)
732             CPPUNIT_TEST(Striped_list)
733             CPPUNIT_TEST(Striped_vector)
734             CPPUNIT_TEST(Striped_set)
735             CPPUNIT_TEST(Striped_hashset)
736             CPPUNIT_TEST(Striped_slist)
737             CPPUNIT_TEST(Striped_boost_list)
738             CPPUNIT_TEST(Striped_boost_vector)
739             CPPUNIT_TEST(Striped_boost_stable_vector)
740             CPPUNIT_TEST(Striped_boost_flat_set)
741             CPPUNIT_TEST(Striped_boost_set)
742             CPPUNIT_TEST(Striped_boost_unordered_set)
743
744             CPPUNIT_TEST(Refinable_list)
745             CPPUNIT_TEST(Refinable_vector)
746             CPPUNIT_TEST(Refinable_set)
747             CPPUNIT_TEST(Refinable_hashset)
748             CPPUNIT_TEST(Refinable_slist)
749             CPPUNIT_TEST(Refinable_boost_list)
750             CPPUNIT_TEST(Refinable_boost_vector)
751             CPPUNIT_TEST(Refinable_boost_stable_vector)
752             CPPUNIT_TEST(Refinable_boost_flat_set)
753             CPPUNIT_TEST(Refinable_boost_set)
754             CPPUNIT_TEST(Refinable_boost_unordered_set)
755
756         CPPUNIT_TEST_SUITE_END()
757     };
758 } // namespace set
759
760 #endif // #ifndef __CDSTEST_HDR_STRIPED_SET_H