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