Removed redundant spaces
[libcds.git] / test / unit / striped-set / test_striped_set.h
1 /*
2     This file is a part of libcds - Concurrent Data Structures library
3
4     (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
5
6     Source code repo: http://github.com/khizmax/libcds/
7     Download: http://sourceforge.net/projects/libcds/files/
8
9     Redistribution and use in source and binary forms, with or without
10     modification, are permitted provided that the following conditions are met:
11
12     * Redistributions of source code must retain the above copyright notice, this
13       list of conditions and the following disclaimer.
14
15     * Redistributions in binary form must reproduce the above copyright notice,
16       this list of conditions and the following disclaimer in the documentation
17       and/or other materials provided with the distribution.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef CDSUNIT_SET_TEST_STRIPED_SET_H
32 #define CDSUNIT_SET_TEST_STRIPED_SET_H
33
34 #include "test_set.h"
35
36 #include <cds/container/striped_set.h>
37
38 namespace {
39     namespace cc = cds::container;
40
41     template <bool Exist, typename Set>
42     struct call_contains_with
43     {
44         bool operator()( Set& s, int key ) const
45         {
46             return s.contains( cds_test::container_set::other_item( key ), cds_test::container_set::other_less());
47         }
48     };
49
50     template <typename Set>
51     struct call_contains_with<false, Set>
52     {
53         bool operator()( Set& s, int key ) const
54         {
55             return s.contains( key );
56         }
57     };
58
59     template <bool Exist, typename Set>
60     struct call_find_with
61     {
62         template <typename Func>
63         bool operator()( Set& s, int key, Func f ) const
64         {
65             return s.find_with( cds_test::container_set::other_item( key ), cds_test::container_set::other_less(), f );
66         }
67     };
68
69     template <typename Set>
70     struct call_find_with<false, Set>
71     {
72         template <typename Func>
73         bool operator()( Set& s, int key, Func f ) const
74         {
75             return s.find( key, [&f]( typename Set::value_type& v, int key ) {
76                 cds_test::container_set::other_item oi( key );
77                 f( v, oi );
78             });
79         }
80     };
81
82     template <bool Exist, typename Set>
83     struct call_erase_with
84     {
85         bool operator()( Set& s, int key ) const
86         {
87             return s.erase_with( cds_test::container_set::other_item( key ), cds_test::container_set::other_less());
88         }
89
90         template <typename Func>
91         bool operator()( Set& s, int key, Func f ) const
92         {
93             return s.erase_with( cds_test::container_set::other_item( key ), cds_test::container_set::other_less(), f );
94         }
95     };
96
97     template <typename Set>
98     struct call_erase_with<false, Set>
99     {
100         bool operator()( Set& s, int key ) const
101         {
102             return s.erase( key );
103         }
104
105         template <typename Func>
106         bool operator()( Set& s, int key, Func f ) const
107         {
108             return s.erase( key, f );
109         }
110     };
111
112     template <typename Traits >
113     class StripedSet : public cds_test::container_set
114     {
115     protected:
116         typedef cds_test::container_set base_class;
117
118         typedef typename Traits::container_type container_type;
119         typedef typename Traits::copy_policy    copy_policy;
120
121         static bool const c_hasFindWith = Traits::c_hasFindWith;
122         static bool const c_hasEraseWith = Traits::c_hasEraseWith;
123
124         //void SetUp()
125         //{}
126
127         //void TearDown()
128         //{}
129
130         template <typename Set>
131         void test( Set& s )
132         {
133             // Precondition: set is empty
134             // Postcondition: set is empty
135
136             ASSERT_TRUE( s.empty());
137             ASSERT_CONTAINER_SIZE( s, 0 );
138             size_t const nSetSize = kSize;
139
140             typedef typename Set::value_type value_type;
141
142             std::vector< value_type > data;
143             std::vector< size_t> indices;
144             data.reserve( kSize );
145             indices.reserve( kSize );
146             for ( size_t key = 0; key < kSize; ++key ) {
147                 data.push_back( value_type( static_cast<int>(key)));
148                 indices.push_back( key );
149             }
150             shuffle( indices.begin(), indices.end());
151
152             // insert/find
153             for ( auto idx : indices ) {
154                 auto& i = data[idx];
155
156                 ASSERT_FALSE( s.contains( i.nKey ));
157                 ASSERT_FALSE( s.contains( i ));
158                 ASSERT_FALSE( (call_contains_with< c_hasFindWith, Set >()( s, i.key())));
159                 ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
160                 ASSERT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
161                 ASSERT_FALSE( (call_find_with< c_hasFindWith, Set >()(s, i.key(), []( value_type&, other_item const& ) {} )));
162
163                 std::pair<bool, bool> updResult;
164
165                 std::string str;
166                 updResult = s.update( i.key(), []( bool, value_type&, int )
167                 {
168                     ASSERT_TRUE( false );
169                 }, false );
170                 EXPECT_FALSE( updResult.first );
171                 EXPECT_FALSE( updResult.second );
172
173                 switch ( idx % 8 ) {
174                 case 0:
175                     ASSERT_TRUE( s.insert( i ));
176                     ASSERT_FALSE( s.insert( i ));
177                     updResult = s.update( i, []( bool bNew, value_type& val, value_type const& arg )
178                     {
179                         EXPECT_FALSE( bNew );
180                         EXPECT_EQ( val.key(), arg.key());
181                     }, false );
182                     EXPECT_TRUE( updResult.first );
183                     EXPECT_FALSE( updResult.second );
184                     break;
185                 case 1:
186                     ASSERT_TRUE( s.insert( i.key()));
187                     ASSERT_FALSE( s.insert( i.key()));
188                     updResult = s.update( i.key(), []( bool bNew, value_type& val, int arg )
189                     {
190                         EXPECT_FALSE( bNew );
191                         EXPECT_EQ( val.key(), arg );
192                     }, false );
193                     EXPECT_TRUE( updResult.first );
194                     EXPECT_FALSE( updResult.second );
195                     break;
196                 case 2:
197                     ASSERT_TRUE( s.insert( i, []( value_type& v ) { ++v.nFindCount; } ));
198                     ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nFindCount; } ));
199                     ASSERT_TRUE( s.find( i.nKey, []( value_type const& v, int key )
200                     {
201                         EXPECT_EQ( v.key(), key );
202                         EXPECT_EQ( v.nFindCount, 1u );
203                     } ));
204                     break;
205                 case 3:
206                     ASSERT_TRUE( s.insert( i.key(), []( value_type& v ) { ++v.nFindCount; } ));
207                     ASSERT_FALSE( s.insert( i.key(), []( value_type& v ) { ++v.nFindCount; } ));
208                     ASSERT_TRUE( s.find( i.nKey, []( value_type const& v, int key )
209                     {
210                         EXPECT_EQ( v.key(), key );
211                         EXPECT_EQ( v.nFindCount, 1u );
212                     } ));
213                     break;
214                 case 4:
215                     updResult = s.update( i, []( bool bNew, value_type& v, value_type const& arg )
216                     {
217                         EXPECT_TRUE( bNew );
218                         EXPECT_EQ( v.key(), arg.key());
219                         ++v.nUpdateNewCount;
220                     } );
221                     EXPECT_TRUE( updResult.first );
222                     EXPECT_TRUE( updResult.second );
223
224                     updResult = s.update( i, []( bool bNew, value_type& v, value_type const& arg )
225                     {
226                         EXPECT_FALSE( bNew );
227                         EXPECT_EQ( v.key(), arg.key());
228                         ++v.nUpdateNewCount;
229                     }, false );
230                     EXPECT_TRUE( updResult.first );
231                     EXPECT_FALSE( updResult.second );
232
233                     ASSERT_TRUE( s.find( i.nKey, []( value_type const& v, int key )
234                     {
235                         EXPECT_EQ( v.key(), key );
236                         EXPECT_EQ( v.nUpdateNewCount, 2u );
237                     } ));
238                     break;
239                 case 5:
240                     updResult = s.update( i.key(), []( bool bNew, value_type& v, int arg )
241                     {
242                         EXPECT_TRUE( bNew );
243                         EXPECT_EQ( v.key(), arg );
244                         ++v.nUpdateNewCount;
245                     } );
246                     EXPECT_TRUE( updResult.first );
247                     EXPECT_TRUE( updResult.second );
248
249                     updResult = s.update( i.key(), []( bool bNew, value_type& v, int arg )
250                     {
251                         EXPECT_FALSE( bNew );
252                         EXPECT_EQ( v.key(), arg );
253                         ++v.nUpdateNewCount;
254                     }, false );
255                     EXPECT_TRUE( updResult.first );
256                     EXPECT_FALSE( updResult.second );
257
258                     ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
259                     {
260                         EXPECT_EQ( v.key(), arg.key());
261                         EXPECT_EQ( v.nUpdateNewCount, 2u );
262                     } ));
263                     break;
264                 case 6:
265                     ASSERT_TRUE( s.emplace( i.key()));
266                     ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
267                     {
268                         EXPECT_EQ( v.key(), arg.key());
269                         EXPECT_EQ( v.nVal, arg.nVal );
270                     } ));
271                     break;
272                 case 7:
273                     str = "Hello!";
274                     ASSERT_TRUE( s.emplace( i.key(), std::move( str )));
275                     EXPECT_TRUE( str.empty());
276                     ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
277                     {
278                         EXPECT_EQ( v.key(), arg.key());
279                         EXPECT_EQ( v.nVal, arg.nVal );
280                         EXPECT_EQ( v.strVal, std::string( "Hello!" ));
281                     } ));
282                     break;
283                 default:
284                     // forgot anything?..
285                     ASSERT_TRUE( false );
286                 }
287
288                 ASSERT_TRUE( s.contains( i.nKey ));
289                 ASSERT_TRUE( s.contains( i ));
290                 ASSERT_TRUE( (call_contains_with< c_hasFindWith, Set>()( s, i.key())));
291                 ASSERT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ));
292                 ASSERT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ));
293                 ASSERT_TRUE( (call_find_with< c_hasFindWith, Set >()(s, i.key(), []( value_type&, other_item const& ) {})));
294             }
295
296             ASSERT_FALSE( s.empty());
297             ASSERT_CONTAINER_SIZE( s, nSetSize );
298
299             // erase
300             shuffle( indices.begin(), indices.end());
301             for ( auto idx : indices ) {
302                 auto& i = data[idx];
303
304                 ASSERT_TRUE( s.contains( i.nKey ));
305                 ASSERT_TRUE( s.contains( i ));
306                 ASSERT_TRUE( (call_contains_with<c_hasFindWith, Set>()(s, i.key())));
307                 ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int )
308                 {
309                     v.nFindCount = 1;
310                 } ));
311                 ASSERT_TRUE( s.find( i, []( value_type& v, value_type const& )
312                 {
313                     EXPECT_EQ( ++v.nFindCount, 2u );
314                 } ));
315                 ASSERT_TRUE( (call_find_with< c_hasFindWith, Set >()(s, i.key(), []( value_type& v, other_item const& ) {
316                     EXPECT_EQ( ++v.nFindCount, 3u );
317                 })));
318
319                 int nKey = i.key() - 1;
320                 switch ( idx % 6 ) {
321                 case 0:
322                     ASSERT_TRUE( s.erase( i.key()));
323                     ASSERT_FALSE( s.erase( i.key()));
324                     break;
325                 case 1:
326                     ASSERT_TRUE( s.erase( i ));
327                     ASSERT_FALSE( s.erase( i ));
328                     break;
329                 case 2:
330                     ASSERT_TRUE( (call_erase_with<c_hasEraseWith, Set>()( s, i.key())));
331                     ASSERT_FALSE( (call_erase_with<c_hasEraseWith, Set>()(s, i.key())));
332                     break;
333                 case 3:
334                     ASSERT_TRUE( s.erase( i.key(), [&nKey]( value_type const& v )
335                     {
336                         nKey = v.key();
337                     } ));
338                     EXPECT_EQ( i.key(), nKey );
339
340                     nKey = i.key() - 1;
341                     ASSERT_FALSE( s.erase( i.key(), [&nKey]( value_type const& v )
342                     {
343                         nKey = v.key();
344                     } ));
345                     EXPECT_EQ( i.key(), nKey + 1 );
346                     break;
347                 case 4:
348                     ASSERT_TRUE( s.erase( i, [&nKey]( value_type const& v )
349                     {
350                         nKey = v.key();
351                     } ));
352                     EXPECT_EQ( i.key(), nKey );
353
354                     nKey = i.key() - 1;
355                     ASSERT_FALSE( s.erase( i, [&nKey]( value_type const& v )
356                     {
357                         nKey = v.key();
358                     } ));
359                     EXPECT_EQ( i.key(), nKey + 1 );
360                     break;
361                 case 5:
362                     ASSERT_TRUE( (call_erase_with<c_hasEraseWith, Set>()(s, i.key(), [&nKey]( value_type const& v )
363                     {
364                         nKey = v.key();
365                     })));
366                     EXPECT_EQ( i.key(), nKey );
367
368                     nKey = i.key() - 1;
369                     ASSERT_FALSE( (call_erase_with<c_hasEraseWith, Set>()(s, i.key(), [&nKey]( value_type const& v )
370                     {
371                         nKey = v.key();
372                     })));
373                     EXPECT_EQ( i.key(), nKey + 1 );
374                     break;
375                 }
376
377                 ASSERT_FALSE( s.contains( i.nKey ));
378                 ASSERT_FALSE( s.contains( i ));
379                 ASSERT_FALSE( (call_contains_with<c_hasFindWith, Set>()( s, i.key())));
380                 ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
381                 ASSERT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
382                 ASSERT_FALSE( (call_find_with<c_hasFindWith, Set>()( s, i.key(), []( value_type&, other_item const& ) {})));
383             }
384             ASSERT_TRUE( s.empty());
385             ASSERT_CONTAINER_SIZE( s, 0u );
386
387
388             // clear
389             for ( auto& i : data ) {
390                 ASSERT_TRUE( s.insert( i ));
391             }
392
393             ASSERT_FALSE( s.empty());
394             ASSERT_CONTAINER_SIZE( s, nSetSize );
395
396             s.clear();
397
398             ASSERT_TRUE( s.empty());
399             ASSERT_CONTAINER_SIZE( s, 0u );
400         }
401
402     };
403
404     template <typename Traits>
405     class RefinableSet: public StripedSet< Traits >
406     {};
407
408     TYPED_TEST_CASE_P( StripedSet );
409     TYPED_TEST_CASE_P( RefinableSet );
410
411 // ****************************************************************
412 // striped set
413
414     TYPED_TEST_P( StripedSet, compare )
415     {
416         typedef cc::StripedSet<
417             typename TestFixture::container_type,
418             cds::opt::hash< typename TestFixture::hash1 >,
419             cds::opt::compare< typename TestFixture::cmp >,
420             cds::opt::mutex_policy< cc::striped_set::striping<>>
421         > set_type;
422
423         set_type s;
424         this->test( s );
425     }
426
427     TYPED_TEST_P( StripedSet, less )
428     {
429         typedef cc::StripedSet<
430             typename TestFixture::container_type,
431             cds::opt::hash< typename TestFixture::hash1 >,
432             cds::opt::less< typename TestFixture::less >
433         > set_type;
434
435         set_type s;
436         this->test( s );
437     }
438
439
440     TYPED_TEST_P( StripedSet, cmpmix )
441     {
442         typedef cc::StripedSet<
443             typename TestFixture::container_type,
444             cds::opt::hash< typename TestFixture::hash1 >,
445             cds::opt::less< typename TestFixture::less >,
446             cds::opt::compare< typename TestFixture::cmp >
447         > set_type;
448
449         set_type s( 32 );
450         this->test( s );
451     }
452
453     TYPED_TEST_P( StripedSet, spinlock )
454     {
455         typedef cc::StripedSet<
456             typename TestFixture::container_type,
457             cds::opt::mutex_policy< cc::striped_set::striping<cds::sync::spin>>,
458             cds::opt::hash< typename TestFixture::hash1 >,
459             cds::opt::less< typename TestFixture::less >,
460             cds::opt::compare< typename TestFixture::cmp >
461         > set_type;
462
463         set_type s;
464         this->test( s );
465     }
466
467     TYPED_TEST_P( StripedSet, load_factor_resizing )
468     {
469         typedef cc::StripedSet<
470             typename TestFixture::container_type,
471             cds::opt::hash< typename TestFixture::hash1 >,
472             cds::opt::less< typename TestFixture::less >,
473             cds::opt::compare< typename TestFixture::cmp >,
474             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>
475         > set_type;
476
477         set_type s;
478         this->test( s );
479     }
480
481     TYPED_TEST_P( StripedSet, load_factor_resizing_rt )
482     {
483         typedef cc::StripedSet<
484             typename TestFixture::container_type,
485             cds::opt::hash< typename TestFixture::hash1 >,
486             cds::opt::compare< typename TestFixture::cmp >,
487             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>
488         > set_type;
489
490         set_type s( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
491         this->test( s );
492     }
493
494     TYPED_TEST_P( StripedSet, single_bucket_resizing )
495     {
496         typedef cc::StripedSet<
497             typename TestFixture::container_type,
498             cds::opt::hash< typename TestFixture::hash1 >,
499             cds::opt::compare< typename TestFixture::cmp >,
500             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>
501         > set_type;
502
503         set_type s( 30 );
504         this->test( s );
505     }
506
507     TYPED_TEST_P( StripedSet, single_bucket_resizing_rt )
508     {
509         typedef cc::StripedSet<
510             typename TestFixture::container_type,
511             cds::opt::hash< typename TestFixture::hash1 >,
512             cds::opt::compare< typename TestFixture::cmp >,
513             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<0>>
514         > set_type;
515
516         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
517         set_type s( 24, resizing_policy );
518         this->test( s );
519     }
520
521     TYPED_TEST_P( StripedSet, copy_policy_copy )
522     {
523         typedef cc::StripedSet<
524             typename TestFixture::container_type,
525             cds::opt::hash< typename TestFixture::hash1 >,
526             cds::opt::less< typename TestFixture::less >,
527             cds::opt::compare< typename TestFixture::cmp >,
528             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>,
529             cds::opt::copy_policy< cc::striped_set::copy_item >
530         > set_type;
531
532         set_type s;
533         this->test( s );
534     }
535
536     TYPED_TEST_P( StripedSet, copy_policy_move )
537     {
538         typedef cc::StripedSet<
539             typename TestFixture::container_type,
540             cds::opt::hash< typename TestFixture::hash1 >,
541             cds::opt::compare< typename TestFixture::cmp >,
542             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>,
543             cds::opt::copy_policy< cc::striped_set::move_item >
544         > set_type;
545
546         set_type s( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
547         this->test( s );
548     }
549
550     TYPED_TEST_P( StripedSet, copy_policy_swap )
551     {
552         typedef cc::StripedSet<
553             typename TestFixture::container_type,
554             cds::opt::hash< typename TestFixture::hash1 >,
555             cds::opt::compare< typename TestFixture::cmp >,
556             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>,
557             cds::opt::copy_policy< cc::striped_set::swap_item >
558         > set_type;
559
560         set_type s( 30 );
561         this->test( s );
562     }
563
564     TYPED_TEST_P( StripedSet, copy_policy_special )
565     {
566         typedef cc::StripedSet<
567             typename TestFixture::container_type,
568             cds::opt::hash< typename TestFixture::hash1 >,
569             cds::opt::compare< typename TestFixture::cmp >,
570             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<0>>,
571             cds::opt::copy_policy< typename TestFixture::copy_policy >
572         > set_type;
573
574         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
575         set_type s( 24, resizing_policy );
576         this->test( s );
577     }
578
579
580 // ****************************************************************
581 // refinable set
582
583     TYPED_TEST_P( RefinableSet, compare )
584     {
585         typedef cc::StripedSet<
586             typename TestFixture::container_type,
587             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
588             cds::opt::hash< typename TestFixture::hash1 >,
589             cds::opt::compare< typename TestFixture::cmp >
590         > set_type;
591
592         set_type s;
593         this->test( s );
594     }
595
596     TYPED_TEST_P( RefinableSet, less )
597     {
598         typedef cc::StripedSet<
599             typename TestFixture::container_type,
600             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
601             cds::opt::hash< typename TestFixture::hash1 >,
602             cds::opt::less< typename TestFixture::less >
603         > set_type;
604
605         set_type s;
606         this->test( s );
607     }
608
609
610     TYPED_TEST_P( RefinableSet, cmpmix )
611     {
612         typedef cc::StripedSet<
613             typename TestFixture::container_type,
614             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
615             cds::opt::hash< typename TestFixture::hash1 >,
616             cds::opt::less< typename TestFixture::less >,
617             cds::opt::compare< typename TestFixture::cmp >
618         > set_type;
619
620         set_type s( 32 );
621         this->test( s );
622     }
623
624     TYPED_TEST_P( RefinableSet, spinlock )
625     {
626         typedef cc::StripedSet<
627             typename TestFixture::container_type,
628             cds::opt::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin>>,
629             cds::opt::hash< typename TestFixture::hash1 >,
630             cds::opt::less< typename TestFixture::less >,
631             cds::opt::compare< typename TestFixture::cmp >
632         > set_type;
633
634         set_type s;
635         this->test( s );
636     }
637
638     TYPED_TEST_P( RefinableSet, load_factor_resizing )
639     {
640         typedef cc::StripedSet<
641             typename TestFixture::container_type,
642             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
643             cds::opt::hash< typename TestFixture::hash1 >,
644             cds::opt::less< typename TestFixture::less >,
645             cds::opt::compare< typename TestFixture::cmp >,
646             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>
647         > set_type;
648
649         set_type s;
650         this->test( s );
651     }
652
653     TYPED_TEST_P( RefinableSet, load_factor_resizing_rt )
654     {
655         typedef cc::StripedSet<
656             typename TestFixture::container_type,
657             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
658             cds::opt::hash< typename TestFixture::hash1 >,
659             cds::opt::compare< typename TestFixture::cmp >,
660             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>
661         > set_type;
662
663         set_type s( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
664         this->test( s );
665     }
666
667     TYPED_TEST_P( RefinableSet, single_bucket_resizing )
668     {
669         typedef cc::StripedSet<
670             typename TestFixture::container_type,
671             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
672             cds::opt::hash< typename TestFixture::hash1 >,
673             cds::opt::compare< typename TestFixture::cmp >,
674             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>
675         > set_type;
676
677         set_type s( 30 );
678         this->test( s );
679     }
680
681     TYPED_TEST_P( RefinableSet, single_bucket_resizing_rt )
682     {
683         typedef cc::StripedSet<
684             typename TestFixture::container_type,
685             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
686             cds::opt::hash< typename TestFixture::hash1 >,
687             cds::opt::compare< typename TestFixture::cmp >,
688             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<0>>
689         > set_type;
690
691         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
692         set_type s( 24, resizing_policy );
693         this->test( s );
694     }
695
696     TYPED_TEST_P( RefinableSet, copy_policy_copy )
697     {
698         typedef cc::StripedSet<
699             typename TestFixture::container_type,
700             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
701             cds::opt::hash< typename TestFixture::hash1 >,
702             cds::opt::less< typename TestFixture::less >,
703             cds::opt::compare< typename TestFixture::cmp >,
704             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>,
705             cds::opt::copy_policy< cc::striped_set::copy_item >
706         > set_type;
707
708         set_type s;
709         this->test( s );
710     }
711
712     TYPED_TEST_P( RefinableSet, copy_policy_move )
713     {
714         typedef cc::StripedSet<
715             typename TestFixture::container_type,
716             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
717             cds::opt::hash< typename TestFixture::hash1 >,
718             cds::opt::compare< typename TestFixture::cmp >,
719             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>,
720             cds::opt::copy_policy< cc::striped_set::move_item >
721         > set_type;
722
723         set_type s( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
724         this->test( s );
725     }
726
727     TYPED_TEST_P( RefinableSet, copy_policy_swap )
728     {
729         typedef cc::StripedSet<
730             typename TestFixture::container_type,
731             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
732             cds::opt::hash< typename TestFixture::hash1 >,
733             cds::opt::compare< typename TestFixture::cmp >,
734             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>,
735             cds::opt::copy_policy< cc::striped_set::swap_item >
736         > set_type;
737
738         set_type s( 30 );
739         this->test( s );
740     }
741
742     TYPED_TEST_P( RefinableSet, copy_policy_special )
743     {
744         typedef cc::StripedSet<
745             typename TestFixture::container_type,
746             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
747             cds::opt::hash< typename TestFixture::hash1 >,
748             cds::opt::compare< typename TestFixture::cmp >,
749             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<0>>,
750             cds::opt::copy_policy< typename TestFixture::copy_policy >
751         > set_type;
752
753         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
754         set_type s( 24, resizing_policy );
755         this->test( s );
756     }
757
758     REGISTER_TYPED_TEST_CASE_P( StripedSet,
759         compare, less, cmpmix, spinlock, load_factor_resizing, load_factor_resizing_rt, single_bucket_resizing, single_bucket_resizing_rt, copy_policy_copy, copy_policy_move, copy_policy_swap, copy_policy_special
760         );
761
762     REGISTER_TYPED_TEST_CASE_P( RefinableSet,
763         compare, less, cmpmix, spinlock, load_factor_resizing, load_factor_resizing_rt, single_bucket_resizing, single_bucket_resizing_rt, copy_policy_copy, copy_policy_move, copy_policy_swap, copy_policy_special
764         );
765
766 } // namespace
767
768 #endif // CDSUNIT_SET_TEST_INTRUSIVE_STRIPED_SET_H