Migrated a part of StripedMap unit test to gtest
[libcds.git] / test / unit / striped-map / test_striped_map.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_STRIPED_MAP_TEST_STRIPED_MAP_H
32 #define CDSUNIT_STRIPED_MAP_TEST_STRIPED_MAP_H
33
34 #include "test_map_data.h"
35
36 #include <cds/container/striped_map.h>
37
38 namespace {
39     namespace cc = cds::container;
40
41     template <bool Exist, typename Map>
42     struct call_contains_with
43     {
44         bool operator()( Map& m, int key ) const
45         {
46             return m.contains( cds_test::striped_map_fixture::other_item( key ), cds_test::striped_map_fixture::other_less() );
47         }
48     };
49
50     template <typename Map>
51     struct call_contains_with<false, Map>
52     {
53         bool operator()( Map& m, int key ) const
54         {
55             return m.contains( key );
56         }
57     };
58
59     template <bool Exist, typename Map>
60     struct call_find_with
61     {
62         template <typename Func>
63         bool operator()( Map& m, int key, Func f ) const
64         {
65             return m.find_with( cds_test::striped_map_fixture::other_item( key ), cds_test::striped_map_fixture::other_less(), f );
66         }
67     };
68
69     template <typename Map>
70     struct call_find_with<false, Map>
71     {
72         template <typename Func>
73         bool operator()( Map& m, int key, Func f ) const
74         {
75             return m.find( key, f );
76         }
77     };
78
79     template <bool Exist, typename Map>
80     struct call_erase_with
81     {
82         bool operator()( Map& m, int key ) const
83         {
84             return m.erase_with( cds_test::striped_map_fixture::other_item( key ), cds_test::striped_map_fixture::other_less() );
85         }
86
87         template <typename Func>
88         bool operator()( Map& m, int key, Func f ) const
89         {
90             return m.erase_with( cds_test::striped_map_fixture::other_item( key ), cds_test::striped_map_fixture::other_less(), f );
91         }
92     };
93
94     template <typename Map>
95     struct call_erase_with<false, Map>
96     {
97         bool operator()( Map& m, int key ) const
98         {
99             return m.erase( key );
100         }
101
102         template <typename Func>
103         bool operator()( Map& m, int key, Func f ) const
104         {
105             return m.erase( key, f );
106         }
107     };
108
109     template <typename Traits>
110     class StripedMap: public cds_test::striped_map_fixture
111     {
112     public:
113         static size_t const kSize = 1000;
114
115     protected:
116         typedef typename Traits::container_type container_type;
117         typedef typename Traits::copy_policy    copy_policy;
118
119         static bool const c_hasFindWith = Traits::c_hasFindWith;
120         static bool const c_hasEraseWith = Traits::c_hasEraseWith;
121
122         //void SetUp()
123         //{}
124
125         //void TearDown()
126         //{}
127
128         template <class Map>
129         void test( Map& m )
130         {
131             // Precondition: map is empty
132             // Postcondition: map is empty
133
134             ASSERT_TRUE( m.empty());
135             ASSERT_CONTAINER_SIZE( m, 0 );
136
137             typedef typename Map::value_type map_pair;
138
139             size_t const kkSize = kSize;
140
141             std::vector<key_type> arrKeys;
142             for ( int i = 0; i < static_cast<int>(kkSize); ++i )
143                 arrKeys.push_back( key_type( i ));
144             shuffle( arrKeys.begin(), arrKeys.end());
145
146             std::vector< value_type > arrVals;
147             for ( size_t i = 0; i < kkSize; ++i ) {
148                 value_type val;
149                 val.nVal = static_cast<int>( i );
150                 val.strVal = std::to_string( i );
151                 arrVals.push_back( val );
152             }
153
154             // insert/find
155             for ( auto const& i : arrKeys ) {
156                 value_type const& val( arrVals.at( i.nKey ));
157
158                 ASSERT_FALSE( m.contains( i.nKey ));
159                 ASSERT_FALSE( m.contains( i ));
160                 ASSERT_FALSE(( call_contains_with<c_hasFindWith, Map>()( m, i.nKey ) ));
161                 ASSERT_FALSE( m.find( i, []( map_pair const& ) {
162                     ASSERT_TRUE( false );
163                 } ));
164                 ASSERT_FALSE( m.find( i.nKey, []( map_pair const& ) {
165                     EXPECT_TRUE( false );
166                 } ));
167                 ASSERT_FALSE(( call_find_with< c_hasFindWith, Map>()( m, i.nKey, []( map_pair const& ) {
168                     EXPECT_TRUE( false );
169                 } )));
170
171                 std::pair< bool, bool > updResult;
172
173                 switch ( i.nKey % 16 ) {
174                 case 0:
175                     ASSERT_TRUE( m.insert( i ));
176                     ASSERT_FALSE( m.insert( i ));
177                     ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
178                         v.second.nVal = v.first.nKey;
179                         v.second.strVal = std::to_string( v.first.nKey );
180                     } ));
181                     break;
182                 case 1:
183                     ASSERT_TRUE( m.insert( i.nKey ));
184                     ASSERT_FALSE( m.insert( i.nKey ));
185                     ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
186                         v.second.nVal = v.first.nKey;
187                         v.second.strVal = std::to_string( v.first.nKey );
188                     } ));
189                     break;
190                 case 2:
191                     ASSERT_TRUE( m.insert( std::to_string( i.nKey )));
192                     ASSERT_FALSE( m.insert( std::to_string( i.nKey )));
193                     ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
194                         v.second.nVal = v.first.nKey;
195                         v.second.strVal = std::to_string( v.first.nKey );
196                     } ));
197                     break;
198                 case 3:
199                     ASSERT_TRUE( m.insert( i, val ));
200                     ASSERT_FALSE( m.insert( i, val ));
201                     break;
202                 case 4:
203                     ASSERT_TRUE( m.insert( i.nKey, val.strVal ));
204                     ASSERT_FALSE( m.insert( i.nKey, val.strVal ));
205                     break;
206                 case 5:
207                     ASSERT_TRUE( m.insert( val.strVal, i.nKey ));
208                     ASSERT_FALSE( m.insert( val.strVal, i.nKey ));
209                     break;
210                 case 6:
211                     ASSERT_TRUE( m.insert_with( i, []( map_pair& v ) {
212                         v.second.nVal = v.first.nKey;
213                         v.second.strVal = std::to_string( v.first.nKey );
214                     } ));
215                     ASSERT_FALSE( m.insert_with( i, []( map_pair& v ) {
216                         EXPECT_TRUE( false );
217                     } ));
218                     break;
219                 case 7:
220                     ASSERT_TRUE( m.insert_with( i.nKey, []( map_pair& v ) {
221                         v.second.nVal = v.first.nKey;
222                         v.second.strVal = std::to_string( v.first.nKey );
223                     } ));
224                     ASSERT_FALSE( m.insert_with( i.nKey, []( map_pair& v ) {
225                         EXPECT_TRUE( false );
226                     } ));
227                     break;
228                 case 8:
229                     ASSERT_TRUE( m.insert_with( val.strVal, []( map_pair& v ) {
230                         v.second.nVal = v.first.nKey;
231                         v.second.strVal = std::to_string( v.first.nKey );
232                     } ));
233                     ASSERT_FALSE( m.insert_with( val.strVal, []( map_pair& v ) {
234                         EXPECT_TRUE( false );
235                     } ));
236                     break;
237                 case 9:
238                     updResult = m.update( i.nKey, []( bool, map_pair& ) {
239                         EXPECT_TRUE( false );
240                     }, false );
241                     ASSERT_FALSE( updResult.first );
242                     ASSERT_FALSE( updResult.second );
243
244                     updResult = m.update( i.nKey, []( bool bNew, map_pair& v ) {
245                         EXPECT_TRUE( bNew );
246                         v.second.nVal = v.first.nKey;
247                     });
248                     ASSERT_TRUE( updResult.first );
249                     ASSERT_TRUE( updResult.second );
250
251                     updResult = m.update( i.nKey, []( bool bNew, map_pair& v ) {
252                         EXPECT_FALSE( bNew );
253                         EXPECT_EQ( v.first.nKey, v.second.nVal );
254                         v.second.strVal = std::to_string( v.second.nVal );
255                     } );
256                     ASSERT_TRUE( updResult.first );
257                     ASSERT_FALSE( updResult.second );
258                     break;
259                 case 10:
260                     updResult = m.update( i, []( bool, map_pair& ) {
261                         EXPECT_TRUE( false );
262                     }, false );
263                     ASSERT_FALSE( updResult.first );
264                     ASSERT_FALSE( updResult.second );
265
266                     updResult = m.update( i, []( bool bNew, map_pair& v ) {
267                         EXPECT_TRUE( bNew );
268                         v.second.nVal = v.first.nKey;
269                     });
270                     ASSERT_TRUE( updResult.first );
271                     ASSERT_TRUE( updResult.second );
272
273                     updResult = m.update( i, []( bool bNew, map_pair& v ) {
274                         EXPECT_FALSE( bNew );
275                         EXPECT_EQ( v.first.nKey, v.second.nVal );
276                         v.second.strVal = std::to_string( v.second.nVal );
277                     } );
278                     ASSERT_TRUE( updResult.first );
279                     ASSERT_FALSE( updResult.second );
280                     break;
281                 case 11:
282                     updResult = m.update( val.strVal, []( bool, map_pair& ) {
283                         EXPECT_TRUE( false );
284                     }, false );
285                     ASSERT_FALSE( updResult.first );
286                     ASSERT_FALSE( updResult.second );
287
288                     updResult = m.update( val.strVal, []( bool bNew, map_pair& v ) {
289                         EXPECT_TRUE( bNew );
290                         v.second.nVal = v.first.nKey;
291                     });
292                     ASSERT_TRUE( updResult.first );
293                     ASSERT_TRUE( updResult.second );
294
295                     updResult = m.update( val.strVal, []( bool bNew, map_pair& v ) {
296                         EXPECT_FALSE( bNew );
297                         EXPECT_EQ( v.first.nKey, v.second.nVal );
298                         v.second.strVal = std::to_string( v.second.nVal );
299                     } );
300                     ASSERT_TRUE( updResult.first );
301                     ASSERT_FALSE( updResult.second );
302                     break;
303                 case 12:
304                     ASSERT_TRUE( m.emplace( i.nKey ));
305                     ASSERT_FALSE( m.emplace( i.nKey ));
306                     ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
307                         v.second.nVal = v.first.nKey;
308                         v.second.strVal = std::to_string( v.first.nKey );
309                     } ));
310                     break;
311                 case 13:
312                     ASSERT_TRUE( m.emplace( i, i.nKey ));
313                     ASSERT_FALSE( m.emplace( i, i.nKey ));
314                     break;
315                 case 14:
316                     {
317                         std::string str = val.strVal;
318                         ASSERT_TRUE( m.emplace( i, std::move( str )));
319                         ASSERT_TRUE( str.empty());
320                         str = val.strVal;
321                         ASSERT_FALSE( m.emplace( i, std::move( str )));
322                         ASSERT_TRUE( str.empty());
323                     }
324                     break;
325                 case 15:
326                     {
327                         std::string str = val.strVal;
328                         ASSERT_TRUE( m.emplace( i, i.nKey, std::move( str )));
329                         ASSERT_TRUE( str.empty());
330                         str = val.strVal;
331                         ASSERT_FALSE( m.emplace( i, i.nKey, std::move( str )));
332                         ASSERT_TRUE( str.empty());
333                     }
334                     break;
335                 }
336
337                 ASSERT_TRUE( m.contains( i.nKey ));
338                 ASSERT_TRUE( m.contains( i ));
339                 ASSERT_TRUE(( call_contains_with<c_hasFindWith, Map>()( m, i.nKey ) ));
340                 ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
341                     EXPECT_EQ( v.first.nKey, v.second.nVal );
342                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
343                 } ));
344                 ASSERT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
345                     EXPECT_EQ( v.first.nKey, v.second.nVal );
346                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
347                 } ));
348                 ASSERT_TRUE(( call_find_with<c_hasFindWith, Map>()( m, i.nKey, []( map_pair const& v ) {
349                     EXPECT_EQ( v.first.nKey, v.second.nVal );
350                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
351                 } )));
352             }
353             ASSERT_FALSE( m.empty() );
354             ASSERT_CONTAINER_SIZE( m, kkSize );
355
356             shuffle( arrKeys.begin(), arrKeys.end() );
357
358             // erase/find
359             for ( auto const& i : arrKeys ) {
360                 value_type const& val( arrVals.at( i.nKey ) );
361
362                 ASSERT_TRUE( m.contains( i.nKey ));
363                 ASSERT_TRUE( m.contains( val.strVal ) );
364                 ASSERT_TRUE( m.contains( i ));
365                 ASSERT_TRUE(( call_contains_with<c_hasFindWith, Map>()( m, i.nKey )));
366                 ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
367                     EXPECT_EQ( v.first.nKey, v.second.nVal );
368                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
369                 } ));
370                 ASSERT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
371                     EXPECT_EQ( v.first.nKey, v.second.nVal );
372                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
373                 } ));
374                 ASSERT_TRUE(( call_find_with<c_hasFindWith, Map>()( m, i.nKey, []( map_pair const& v ) {
375                     EXPECT_EQ( v.first.nKey, v.second.nVal );
376                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
377                 } )));
378
379
380                 switch ( i.nKey % 8 ) {
381                 case 0:
382                     ASSERT_TRUE( m.erase( i ));
383                     ASSERT_FALSE( m.erase( i ));
384                     break;
385                 case 1:
386                     ASSERT_TRUE( m.erase( i.nKey ));
387                     ASSERT_FALSE( m.erase( i.nKey ));
388                     break;
389                 case 2:
390                     ASSERT_TRUE( m.erase( val.strVal ));
391                     ASSERT_FALSE( m.erase( val.strVal ));
392                     break;
393                 case 3:
394                     ASSERT_TRUE(( call_erase_with< c_hasEraseWith, Map>()( m, i.nKey )));
395                     ASSERT_FALSE(( call_erase_with< c_hasEraseWith, Map>()( m, i.nKey )));
396                     break;
397                 case 4:
398                     ASSERT_TRUE( m.erase( i, []( map_pair& v ) {
399                         EXPECT_EQ( v.first.nKey, v.second.nVal );
400                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
401                     }));
402                     ASSERT_FALSE( m.erase( i, []( map_pair& ) {
403                         EXPECT_TRUE( false );
404                     }));
405                     break;
406                 case 5:
407                     ASSERT_TRUE( m.erase( i.nKey, []( map_pair& v ) {
408                         EXPECT_EQ( v.first.nKey, v.second.nVal );
409                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
410                     }));
411                     ASSERT_FALSE( m.erase( i.nKey, []( map_pair& ) {
412                         EXPECT_TRUE( false );
413                     }));
414                     break;
415                 case 6:
416                     ASSERT_TRUE( m.erase( val.strVal, []( map_pair& v ) {
417                         EXPECT_EQ( v.first.nKey, v.second.nVal );
418                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
419                     }));
420                     ASSERT_FALSE( m.erase( val.strVal, []( map_pair& ) {
421                         EXPECT_TRUE( false );
422                     }));
423                     break;
424                 case 7:
425                     ASSERT_TRUE(( call_erase_with< c_hasEraseWith, Map >()( m, i.nKey, []( map_pair& v ) {
426                         EXPECT_EQ( v.first.nKey, v.second.nVal );
427                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
428                     })));
429                     ASSERT_FALSE(( call_erase_with< c_hasEraseWith, Map >()( m, i.nKey, []( map_pair& ) {
430                         EXPECT_TRUE( false );
431                     })));
432                     break;
433                 }
434
435                 ASSERT_FALSE( m.contains( i.nKey ));
436                 ASSERT_FALSE( m.contains( i ));
437                 ASSERT_FALSE( m.contains( val.strVal ));
438                 ASSERT_FALSE(( call_contains_with< c_hasFindWith, Map >()( m, i.nKey )));
439                 ASSERT_FALSE( m.find( i, []( map_pair const& ) {
440                     ASSERT_TRUE( false );
441                 } ));
442                 ASSERT_FALSE( m.find( i.nKey, []( map_pair const& ) {
443                     EXPECT_TRUE( false );
444                 } ));
445                 ASSERT_FALSE(( call_find_with< c_hasFindWith, Map >()( m, i.nKey, []( map_pair const& ) {
446                     EXPECT_TRUE( false );
447                 } )));
448             }
449             ASSERT_TRUE( m.empty() );
450             ASSERT_CONTAINER_SIZE( m, 0 );
451
452             // clear
453             for ( auto const& i : arrKeys )
454                 ASSERT_TRUE( m.insert( i ));
455
456             ASSERT_FALSE( m.empty() );
457             ASSERT_CONTAINER_SIZE( m, kkSize );
458
459             m.clear();
460
461             ASSERT_TRUE( m.empty() );
462             ASSERT_CONTAINER_SIZE( m, 0 );
463         }
464     };
465
466     template <typename Traits>
467     class RefinableMap: public StripedMap< Traits >
468     {};
469
470     TYPED_TEST_CASE_P( StripedMap );
471     TYPED_TEST_CASE_P( RefinableMap );
472
473
474     // ****************************************************************
475     // striped map
476
477     TYPED_TEST_P( StripedMap, compare )
478     {
479         typedef cc::StripedMap<
480             typename TestFixture::container_type,
481             cds::opt::hash< typename TestFixture::hash1 >,
482             cds::opt::compare< typename TestFixture::cmp >,
483             cds::opt::mutex_policy< cc::striped_set::striping<>>
484         > map_type;
485
486         map_type m;
487         this->test( m );
488     }
489
490     TYPED_TEST_P( StripedMap, less )
491     {
492         typedef cc::StripedMap<
493             typename TestFixture::container_type,
494             cds::opt::hash< typename TestFixture::hash1 >,
495             cds::opt::less< typename TestFixture::less >
496         > map_type;
497
498         map_type m;
499         this->test( m );
500     }
501
502
503     TYPED_TEST_P( StripedMap, cmpmix )
504     {
505         typedef cc::StripedMap<
506             typename TestFixture::container_type,
507             cds::opt::hash< typename TestFixture::hash1 >,
508             cds::opt::less< typename TestFixture::less >,
509             cds::opt::compare< typename TestFixture::cmp >
510         > map_type;
511
512         map_type m( 32 );
513         this->test( m );
514     }
515
516     TYPED_TEST_P( StripedMap, spinlock )
517     {
518         typedef cc::StripedMap<
519             typename TestFixture::container_type,
520             cds::opt::mutex_policy< cc::striped_set::striping<cds::sync::spin>>,
521             cds::opt::hash< typename TestFixture::hash1 >,
522             cds::opt::less< typename TestFixture::less >,
523             cds::opt::compare< typename TestFixture::cmp >
524         > map_type;
525
526         map_type m;
527         this->test( m );
528     }
529
530     TYPED_TEST_P( StripedMap, load_factor_resizing )
531     {
532         typedef cc::StripedMap<
533             typename TestFixture::container_type,
534             cds::opt::hash< typename TestFixture::hash1 >,
535             cds::opt::less< typename TestFixture::less >,
536             cds::opt::compare< typename TestFixture::cmp >,
537             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>
538         > map_type;
539
540         map_type m;
541         this->test( m );
542     }
543
544     TYPED_TEST_P( StripedMap, load_factor_resizing_rt )
545     {
546         typedef cc::StripedMap<
547             typename TestFixture::container_type,
548             cds::opt::hash< typename TestFixture::hash1 >,
549             cds::opt::compare< typename TestFixture::cmp >,
550             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>
551         > map_type;
552
553         map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ) );
554         this->test( m );
555     }
556
557     TYPED_TEST_P( StripedMap, single_bucket_resizing )
558     {
559         typedef cc::StripedMap<
560             typename TestFixture::container_type,
561             cds::opt::hash< typename TestFixture::hash1 >,
562             cds::opt::compare< typename TestFixture::cmp >,
563             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>
564         > map_type;
565
566         map_type m( 30 );
567         this->test( m );
568     }
569
570     TYPED_TEST_P( StripedMap, single_bucket_resizing_rt )
571     {
572         typedef cc::StripedMap<
573             typename TestFixture::container_type,
574             cds::opt::hash< typename TestFixture::hash1 >,
575             cds::opt::compare< typename TestFixture::cmp >,
576             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<0>>
577         > map_type;
578
579         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
580         map_type m( 24, resizing_policy );
581         this->test( m );
582     }
583
584     TYPED_TEST_P( StripedMap, copy_policy_copy )
585     {
586         typedef cc::StripedMap<
587             typename TestFixture::container_type,
588             cds::opt::hash< typename TestFixture::hash1 >,
589             cds::opt::less< typename TestFixture::less >,
590             cds::opt::compare< typename TestFixture::cmp >,
591             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>,
592             cds::opt::copy_policy< cc::striped_set::copy_item >
593         > map_type;
594
595         map_type m;
596         this->test( m );
597     }
598
599     TYPED_TEST_P( StripedMap, copy_policy_move )
600     {
601         typedef cc::StripedMap<
602             typename TestFixture::container_type,
603             cds::opt::hash< typename TestFixture::hash1 >,
604             cds::opt::compare< typename TestFixture::cmp >,
605             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>,
606             cds::opt::copy_policy< cc::striped_set::move_item >
607         > map_type;
608
609         map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ) );
610         this->test( m );
611     }
612
613     TYPED_TEST_P( StripedMap, copy_policy_swap )
614     {
615         typedef cc::StripedMap<
616             typename TestFixture::container_type,
617             cds::opt::hash< typename TestFixture::hash1 >,
618             cds::opt::compare< typename TestFixture::cmp >,
619             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>,
620             cds::opt::copy_policy< cc::striped_set::swap_item >
621         > map_type;
622
623         map_type m( 30 );
624         this->test( m );
625     }
626
627     TYPED_TEST_P( StripedMap, copy_policy_special )
628     {
629         typedef cc::StripedMap<
630             typename TestFixture::container_type,
631             cds::opt::hash< typename TestFixture::hash1 >,
632             cds::opt::compare< typename TestFixture::cmp >,
633             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<0>>,
634             cds::opt::copy_policy< typename TestFixture::copy_policy >
635         > map_type;
636
637         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
638         map_type m( 24, resizing_policy );
639         this->test( m );
640     }
641
642
643     // ****************************************************************
644     // refinable map
645
646     TYPED_TEST_P( RefinableMap, compare )
647     {
648         typedef cc::StripedMap<
649             typename TestFixture::container_type,
650             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
651             cds::opt::hash< typename TestFixture::hash1 >,
652             cds::opt::compare< typename TestFixture::cmp >
653         > map_type;
654
655         map_type m;
656         this->test( m );
657     }
658
659     TYPED_TEST_P( RefinableMap, less )
660     {
661         typedef cc::StripedMap<
662             typename TestFixture::container_type,
663             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
664             cds::opt::hash< typename TestFixture::hash1 >,
665             cds::opt::less< typename TestFixture::less >
666         > map_type;
667
668         map_type m;
669         this->test( m );
670     }
671
672
673     TYPED_TEST_P( RefinableMap, cmpmix )
674     {
675         typedef cc::StripedMap<
676             typename TestFixture::container_type,
677             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
678             cds::opt::hash< typename TestFixture::hash1 >,
679             cds::opt::less< typename TestFixture::less >,
680             cds::opt::compare< typename TestFixture::cmp >
681         > map_type;
682
683         map_type m( 32 );
684         this->test( m );
685     }
686
687     TYPED_TEST_P( RefinableMap, spinlock )
688     {
689         typedef cc::StripedMap<
690             typename TestFixture::container_type,
691             cds::opt::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin>>,
692             cds::opt::hash< typename TestFixture::hash1 >,
693             cds::opt::less< typename TestFixture::less >,
694             cds::opt::compare< typename TestFixture::cmp >
695         > map_type;
696
697         map_type m;
698         this->test( m );
699     }
700
701     TYPED_TEST_P( RefinableMap, load_factor_resizing )
702     {
703         typedef cc::StripedMap<
704             typename TestFixture::container_type,
705             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
706             cds::opt::hash< typename TestFixture::hash1 >,
707             cds::opt::less< typename TestFixture::less >,
708             cds::opt::compare< typename TestFixture::cmp >,
709             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>
710         > map_type;
711
712         map_type m;
713         this->test( m );
714     }
715
716     TYPED_TEST_P( RefinableMap, load_factor_resizing_rt )
717     {
718         typedef cc::StripedMap<
719             typename TestFixture::container_type,
720             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
721             cds::opt::hash< typename TestFixture::hash1 >,
722             cds::opt::compare< typename TestFixture::cmp >,
723             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>
724         > map_type;
725
726         map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ) );
727         this->test( m );
728     }
729
730     TYPED_TEST_P( RefinableMap, single_bucket_resizing )
731     {
732         typedef cc::StripedMap<
733             typename TestFixture::container_type,
734             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
735             cds::opt::hash< typename TestFixture::hash1 >,
736             cds::opt::compare< typename TestFixture::cmp >,
737             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>
738         > map_type;
739
740         map_type m( 30 );
741         this->test( m );
742     }
743
744     TYPED_TEST_P( RefinableMap, single_bucket_resizing_rt )
745     {
746         typedef cc::StripedMap<
747             typename TestFixture::container_type,
748             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
749             cds::opt::hash< typename TestFixture::hash1 >,
750             cds::opt::compare< typename TestFixture::cmp >,
751             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<0>>
752         > map_type;
753
754         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
755         map_type m( 24, resizing_policy );
756         this->test( m );
757     }
758
759     TYPED_TEST_P( RefinableMap, copy_policy_copy )
760     {
761         typedef cc::StripedMap<
762             typename TestFixture::container_type,
763             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
764             cds::opt::hash< typename TestFixture::hash1 >,
765             cds::opt::less< typename TestFixture::less >,
766             cds::opt::compare< typename TestFixture::cmp >,
767             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>,
768             cds::opt::copy_policy< cc::striped_set::copy_item >
769         > map_type;
770
771         map_type m;
772         this->test( m );
773     }
774
775     TYPED_TEST_P( RefinableMap, copy_policy_move )
776     {
777         typedef cc::StripedMap<
778             typename TestFixture::container_type,
779             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
780             cds::opt::hash< typename TestFixture::hash1 >,
781             cds::opt::compare< typename TestFixture::cmp >,
782             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>,
783             cds::opt::copy_policy< cc::striped_set::move_item >
784         > map_type;
785
786         map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ) );
787         this->test( m );
788     }
789
790     TYPED_TEST_P( RefinableMap, copy_policy_swap )
791     {
792         typedef cc::StripedMap<
793             typename TestFixture::container_type,
794             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
795             cds::opt::hash< typename TestFixture::hash1 >,
796             cds::opt::compare< typename TestFixture::cmp >,
797             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>,
798             cds::opt::copy_policy< cc::striped_set::swap_item >
799         > map_type;
800
801         map_type m( 30 );
802         this->test( m );
803     }
804
805     TYPED_TEST_P( RefinableMap, copy_policy_special )
806     {
807         typedef cc::StripedMap<
808             typename TestFixture::container_type,
809             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
810             cds::opt::hash< typename TestFixture::hash1 >,
811             cds::opt::compare< typename TestFixture::cmp >,
812             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<0>>,
813             cds::opt::copy_policy< typename TestFixture::copy_policy >
814         > map_type;
815
816         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
817         map_type m( 24, resizing_policy );
818         this->test( m );
819     }
820
821     REGISTER_TYPED_TEST_CASE_P( StripedMap,
822         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
823     );
824
825     REGISTER_TYPED_TEST_CASE_P( RefinableMap,
826         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
827     );
828 } // namespace
829
830 #endif // #ifndef CDSUNIT_STRIPED_MAP_TEST_STRIPED_MAP_H