Move libcds 1.6.0 from SVN
[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         //*******************************************
514         // If erase_with && find_with are supported
515 #ifndef CDS_CXX11_DEFAULT_FUNCTION_TEMPLATE_ARGS_SUPPORT
516         template <class Set>
517         void test_striped2()
518         {
519             test_striped<Set>();
520         }
521 #else
522         template <class Set>
523         void test_striped2()
524         {
525             Set s( 30 );
526             CPPUNIT_ASSERT( s.bucket_count() == 32 );
527             CPPUNIT_ASSERT( s.lock_count() == 32 );
528
529             test_striped_with2( s );
530         }
531
532         template <class Set>
533         void test_striped_with2( Set& s )
534         {
535             cds::OS::Timer    timer;
536
537             test_int_with2( s );
538
539             // Resizing test
540             for ( int i = 0; i < 10000; i++ ) {
541                 s.insert( i );
542             }
543
544             CPPUNIT_MSG( "   Duration=" << timer.duration() );
545         }
546
547         template <class Set>
548         void test_int_with2( Set& s)
549         {
550             typedef typename Set::value_type    value_type;
551
552             item itm;
553             int key;
554
555             // insert/find test
556             CPPUNIT_ASSERT( !s.find( 10 ) );
557             CPPUNIT_ASSERT( s.insert( 10 ));
558             CPPUNIT_ASSERT( !s.empty() );
559             CPPUNIT_ASSERT( check_size( s, 1 ));
560             CPPUNIT_ASSERT( s.find( 10 ) );
561
562             CPPUNIT_ASSERT( !s.insert( 10 ));
563             CPPUNIT_ASSERT( !s.empty() );
564             CPPUNIT_ASSERT( check_size( s, 1 ));
565
566             CPPUNIT_ASSERT( !s.find_with( 20, less<value_type>() ) );
567             CPPUNIT_ASSERT( s.insert( std::make_pair(20, 25) ));
568             CPPUNIT_ASSERT( !s.empty() );
569             CPPUNIT_ASSERT( check_size( s, 2 ));
570             CPPUNIT_ASSERT( s.find( 10 ) );
571             CPPUNIT_ASSERT( s.find_with( key = 20, less<value_type>() ) );
572             CPPUNIT_ASSERT( s.find_with( key, less<value_type>(), find_functor() ) );
573             {
574                 copy_found<item> f;
575                 key = 20;
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 == 1 );
580             }
581             {
582                 copy_found<item> f;
583                 key = 20;
584                 CPPUNIT_ASSERT( s.find_with( 20, less<value_type>(), find_functor() ) );
585                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
586                 CPPUNIT_ASSERT( f.m_found.nKey == 20 );
587                 CPPUNIT_ASSERT( f.m_found.nVal == 25 );
588                 CPPUNIT_ASSERT( f.m_found.nFindCount == 2 );
589             }
590             CPPUNIT_ASSERT( !s.empty() );
591             CPPUNIT_ASSERT( check_size( s, 2 ));
592
593             CPPUNIT_ASSERT( !s.find( 25 ) );
594             CPPUNIT_ASSERT( s.insert( std::make_pair(25, -1), insert_functor() ));
595             CPPUNIT_ASSERT( !s.empty() );
596             CPPUNIT_ASSERT( check_size( s, 3 ));
597             {
598                 copy_found<item> f;
599                 key = 25;
600                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
601                 CPPUNIT_ASSERT( f.m_found.nKey == 25 );
602                 CPPUNIT_ASSERT( f.m_found.nVal == 2500 );
603             }
604
605             // ensure test
606             key = 10;
607             {
608                 copy_found<item> f;
609                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
610                 CPPUNIT_ASSERT( f.m_found.nKey == 10 );
611                 CPPUNIT_ASSERT( f.m_found.nVal == 10 );
612                 CPPUNIT_ASSERT( f.m_found.nEnsureCount == 0 );
613                 CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 0 );
614             }
615             std::pair<bool, bool> ensureResult = s.ensure( key, ensure_functor() );
616             CPPUNIT_ASSERT( ensureResult.first && !ensureResult.second );
617             CPPUNIT_ASSERT( !s.empty() );
618             CPPUNIT_ASSERT( check_size( s, 3 ));
619             {
620                 copy_found<item> f;
621                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
622                 CPPUNIT_ASSERT( f.m_found.nKey == 10 );
623                 CPPUNIT_ASSERT( f.m_found.nVal == 10 );
624                 CPPUNIT_ASSERT( f.m_found.nEnsureCount == 1 );
625                 CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 0 );
626             }
627
628             ensureResult = s.ensure( std::make_pair(13, 1300), ensure_functor() );
629             CPPUNIT_ASSERT( ensureResult.first && ensureResult.second );
630             CPPUNIT_ASSERT( !s.empty() );
631             CPPUNIT_ASSERT( check_size( s, 4 ));
632             {
633                 copy_found<item> f;
634                 key = 13;
635                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
636                 CPPUNIT_ASSERT( f.m_found.nKey == 13 );
637                 CPPUNIT_ASSERT( f.m_found.nVal == 1300 );
638                 CPPUNIT_ASSERT( f.m_found.nEnsureCount == 0 );
639                 CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 1 );
640             }
641
642             // erase test
643             CPPUNIT_ASSERT( s.erase(13) );
644             CPPUNIT_ASSERT( !s.find( 13 ));
645             CPPUNIT_ASSERT( !s.empty() );
646             CPPUNIT_ASSERT( check_size( s, 3 ));
647             CPPUNIT_ASSERT( !s.erase(13) );
648             CPPUNIT_ASSERT( !s.empty() );
649             CPPUNIT_ASSERT( check_size( s, 3 ));
650
651             CPPUNIT_ASSERT( s.find( 10 ));
652             CPPUNIT_ASSERT( s.erase_with( 10, less<value_type>() ));
653             CPPUNIT_ASSERT( !s.find( 10 ));
654             CPPUNIT_ASSERT( !s.empty() );
655             CPPUNIT_ASSERT( check_size( s, 2 ));
656             CPPUNIT_ASSERT( !s.erase_with( 10, less<value_type>() ) );
657             CPPUNIT_ASSERT( !s.empty() );
658             CPPUNIT_ASSERT( check_size( s, 2 ));
659
660             CPPUNIT_ASSERT( s.find(20) );
661             {
662                 copy_found<item> f;
663                 CPPUNIT_ASSERT( s.erase( 20, boost::ref(f) ));
664                 CPPUNIT_ASSERT( f.m_found.nKey == 20 );
665                 CPPUNIT_ASSERT( f.m_found.nVal == 25 );
666
667                 CPPUNIT_ASSERT( s.insert(235))
668                 CPPUNIT_ASSERT( s.erase_with( 235, less<value_type>(), boost::ref(f) ));
669                 CPPUNIT_ASSERT( f.m_found.nKey == 235 );
670                 CPPUNIT_ASSERT( f.m_found.nVal == 235 );
671             }
672             CPPUNIT_ASSERT( !s.find( 20 ));
673             CPPUNIT_ASSERT( !s.empty() );
674             CPPUNIT_ASSERT( check_size( s, 1 ));
675
676             s.clear();
677             CPPUNIT_ASSERT( s.empty() );
678             CPPUNIT_ASSERT( check_size( s, 0 ));
679
680 #       ifdef CDS_EMPLACE_SUPPORT
681             // emplace test
682             CPPUNIT_ASSERT( s.emplace( 151 )) ;  // key = 151,  val = 151
683             CPPUNIT_ASSERT( s.emplace( 174, 471 )) ;    // key = 174, val = 471
684             CPPUNIT_ASSERT( s.emplace( std::make_pair( 190, 91 ) )) ; // key == 190, val = 91
685             CPPUNIT_ASSERT( !s.empty() );
686             CPPUNIT_ASSERT( check_size( s, 3 ));
687
688             CPPUNIT_ASSERT( s.find(151));
689             CPPUNIT_ASSERT( s.find(174));
690             CPPUNIT_ASSERT( s.find(190));
691
692             {
693                 copy_found<item> f;
694                 key = 151;
695                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
696                 CPPUNIT_ASSERT( f.m_found.nKey == 151 );
697                 CPPUNIT_ASSERT( f.m_found.nVal == 151 );
698
699                 key = 174;
700                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
701                 CPPUNIT_ASSERT( f.m_found.nKey == 174 );
702                 CPPUNIT_ASSERT( f.m_found.nVal == 471 );
703
704                 key = 190;
705                 CPPUNIT_ASSERT( s.find( key, boost::ref(f) ) );
706                 CPPUNIT_ASSERT( f.m_found.nKey == 190 );
707                 CPPUNIT_ASSERT( f.m_found.nVal == 91 );
708             }
709
710             s.clear();
711             CPPUNIT_ASSERT( s.empty() );
712             CPPUNIT_ASSERT( check_size( s, 0 ));
713 #       endif
714         }
715 #endif // CDS_CXX11_DEFAULT_FUNCTION_TEMPLATE_ARGS_SUPPORT
716
717         void Striped_list();
718         void Striped_vector();
719         void Striped_set();
720         void Striped_hashset();
721         void Striped_slist();
722         void Striped_boost_list();
723         void Striped_boost_vector();
724         void Striped_boost_stable_vector();
725         void Striped_boost_flat_set();
726         void Striped_boost_set();
727         void Striped_boost_unordered_set();
728
729         void Refinable_list();
730         void Refinable_vector();
731         void Refinable_set();
732         void Refinable_hashset();
733         void Refinable_slist();
734         void Refinable_boost_list();
735         void Refinable_boost_vector();
736         void Refinable_boost_stable_vector();
737         void Refinable_boost_flat_set();
738         void Refinable_boost_set();
739         void Refinable_boost_unordered_set();
740
741         CPPUNIT_TEST_SUITE(StripedSetHdrTest)
742             CPPUNIT_TEST(Striped_list)
743             CPPUNIT_TEST(Striped_vector)
744             CPPUNIT_TEST(Striped_set)
745             CPPUNIT_TEST(Striped_hashset)
746             CPPUNIT_TEST(Striped_slist)
747             CPPUNIT_TEST(Striped_boost_list)
748             CPPUNIT_TEST(Striped_boost_vector)
749             CPPUNIT_TEST(Striped_boost_stable_vector)
750             CPPUNIT_TEST(Striped_boost_flat_set)
751             CPPUNIT_TEST(Striped_boost_set)
752             CPPUNIT_TEST(Striped_boost_unordered_set)
753
754             CPPUNIT_TEST(Refinable_list)
755             CPPUNIT_TEST(Refinable_vector)
756             CPPUNIT_TEST(Refinable_set)
757             CPPUNIT_TEST(Refinable_hashset)
758             CPPUNIT_TEST(Refinable_slist)
759             CPPUNIT_TEST(Refinable_boost_list)
760             CPPUNIT_TEST(Refinable_boost_vector)
761             CPPUNIT_TEST(Refinable_boost_stable_vector)
762             CPPUNIT_TEST(Refinable_boost_flat_set)
763             CPPUNIT_TEST(Refinable_boost_set)
764             CPPUNIT_TEST(Refinable_boost_unordered_set)
765
766         CPPUNIT_TEST_SUITE_END()
767     };
768 } // namespace set
769
770 #endif // #ifndef __CDSTEST_HDR_STRIPED_SET_H