Merged branch 'master' of https://github.com/Nemo1369/libcds
[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-2017
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& ) {
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&  ) {
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& ) {
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                     }
323                     break;
324                 case 15:
325                     {
326                         std::string str = val.strVal;
327                         ASSERT_TRUE( m.emplace( i, i.nKey, std::move( str )));
328                         ASSERT_TRUE( str.empty());
329                         str = val.strVal;
330                         ASSERT_FALSE( m.emplace( i, i.nKey, std::move( str )));
331                     }
332                     break;
333                 }
334
335                 ASSERT_TRUE( m.contains( i.nKey ));
336                 ASSERT_TRUE( m.contains( i ));
337                 ASSERT_TRUE(( call_contains_with<c_hasFindWith, Map>()( m, i.nKey )));
338                 ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
339                     EXPECT_EQ( v.first.nKey, v.second.nVal );
340                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
341                 } ));
342                 ASSERT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
343                     EXPECT_EQ( v.first.nKey, v.second.nVal );
344                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
345                 } ));
346                 ASSERT_TRUE(( call_find_with<c_hasFindWith, Map>()( m, i.nKey, []( map_pair const& v ) {
347                     EXPECT_EQ( v.first.nKey, v.second.nVal );
348                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
349                 } )));
350             }
351             ASSERT_FALSE( m.empty());
352             ASSERT_CONTAINER_SIZE( m, kkSize );
353
354             shuffle( arrKeys.begin(), arrKeys.end());
355
356             // erase/find
357             for ( auto const& i : arrKeys ) {
358                 value_type const& val( arrVals.at( i.nKey ));
359
360                 ASSERT_TRUE( m.contains( i.nKey ));
361                 ASSERT_TRUE( m.contains( val.strVal ));
362                 ASSERT_TRUE( m.contains( i ));
363                 ASSERT_TRUE(( call_contains_with<c_hasFindWith, Map>()( m, i.nKey )));
364                 ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
365                     EXPECT_EQ( v.first.nKey, v.second.nVal );
366                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
367                 } ));
368                 ASSERT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
369                     EXPECT_EQ( v.first.nKey, v.second.nVal );
370                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
371                 } ));
372                 ASSERT_TRUE(( call_find_with<c_hasFindWith, Map>()( m, i.nKey, []( map_pair const& v ) {
373                     EXPECT_EQ( v.first.nKey, v.second.nVal );
374                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
375                 } )));
376
377
378                 switch ( i.nKey % 8 ) {
379                 case 0:
380                     ASSERT_TRUE( m.erase( i ));
381                     ASSERT_FALSE( m.erase( i ));
382                     break;
383                 case 1:
384                     ASSERT_TRUE( m.erase( i.nKey ));
385                     ASSERT_FALSE( m.erase( i.nKey ));
386                     break;
387                 case 2:
388                     ASSERT_TRUE( m.erase( val.strVal ));
389                     ASSERT_FALSE( m.erase( val.strVal ));
390                     break;
391                 case 3:
392                     ASSERT_TRUE(( call_erase_with< c_hasEraseWith, Map>()( m, i.nKey )));
393                     ASSERT_FALSE(( call_erase_with< c_hasEraseWith, Map>()( m, i.nKey )));
394                     break;
395                 case 4:
396                     ASSERT_TRUE( m.erase( i, []( map_pair& v ) {
397                         EXPECT_EQ( v.first.nKey, v.second.nVal );
398                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
399                     }));
400                     ASSERT_FALSE( m.erase( i, []( map_pair& ) {
401                         EXPECT_TRUE( false );
402                     }));
403                     break;
404                 case 5:
405                     ASSERT_TRUE( m.erase( i.nKey, []( map_pair& v ) {
406                         EXPECT_EQ( v.first.nKey, v.second.nVal );
407                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
408                     }));
409                     ASSERT_FALSE( m.erase( i.nKey, []( map_pair& ) {
410                         EXPECT_TRUE( false );
411                     }));
412                     break;
413                 case 6:
414                     ASSERT_TRUE( m.erase( val.strVal, []( map_pair& v ) {
415                         EXPECT_EQ( v.first.nKey, v.second.nVal );
416                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
417                     }));
418                     ASSERT_FALSE( m.erase( val.strVal, []( map_pair& ) {
419                         EXPECT_TRUE( false );
420                     }));
421                     break;
422                 case 7:
423                     ASSERT_TRUE(( call_erase_with< c_hasEraseWith, Map >()( m, i.nKey, []( map_pair& v ) {
424                         EXPECT_EQ( v.first.nKey, v.second.nVal );
425                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
426                     })));
427                     ASSERT_FALSE(( call_erase_with< c_hasEraseWith, Map >()( m, i.nKey, []( map_pair& ) {
428                         EXPECT_TRUE( false );
429                     })));
430                     break;
431                 }
432
433                 ASSERT_FALSE( m.contains( i.nKey ));
434                 ASSERT_FALSE( m.contains( i ));
435                 ASSERT_FALSE( m.contains( val.strVal ));
436                 ASSERT_FALSE(( call_contains_with< c_hasFindWith, Map >()( m, i.nKey )));
437                 ASSERT_FALSE( m.find( i, []( map_pair const& ) {
438                     ASSERT_TRUE( false );
439                 } ));
440                 ASSERT_FALSE( m.find( i.nKey, []( map_pair const& ) {
441                     EXPECT_TRUE( false );
442                 } ));
443                 ASSERT_FALSE(( call_find_with< c_hasFindWith, Map >()( m, i.nKey, []( map_pair const& ) {
444                     EXPECT_TRUE( false );
445                 } )));
446             }
447             ASSERT_TRUE( m.empty());
448             ASSERT_CONTAINER_SIZE( m, 0 );
449
450             // clear
451             for ( auto const& i : arrKeys )
452                 ASSERT_TRUE( m.insert( i ));
453
454             ASSERT_FALSE( m.empty());
455             ASSERT_CONTAINER_SIZE( m, kkSize );
456
457             m.clear();
458
459             ASSERT_TRUE( m.empty());
460             ASSERT_CONTAINER_SIZE( m, 0 );
461         }
462     };
463
464     template <typename Traits>
465     class RefinableMap: public StripedMap< Traits >
466     {};
467
468     TYPED_TEST_CASE_P( StripedMap );
469     TYPED_TEST_CASE_P( RefinableMap );
470
471
472     // ****************************************************************
473     // striped map
474
475     TYPED_TEST_P( StripedMap, compare )
476     {
477         typedef cc::StripedMap<
478             typename TestFixture::container_type,
479             cds::opt::hash< typename TestFixture::hash1 >,
480             cds::opt::compare< typename TestFixture::cmp >,
481             cds::opt::mutex_policy< cc::striped_set::striping<>>
482         > map_type;
483
484         map_type m;
485         this->test( m );
486     }
487
488     TYPED_TEST_P( StripedMap, less )
489     {
490         typedef cc::StripedMap<
491             typename TestFixture::container_type,
492             cds::opt::hash< typename TestFixture::hash1 >,
493             cds::opt::less< typename TestFixture::less >
494         > map_type;
495
496         map_type m;
497         this->test( m );
498     }
499
500
501     TYPED_TEST_P( StripedMap, cmpmix )
502     {
503         typedef cc::StripedMap<
504             typename TestFixture::container_type,
505             cds::opt::hash< typename TestFixture::hash1 >,
506             cds::opt::less< typename TestFixture::less >,
507             cds::opt::compare< typename TestFixture::cmp >
508         > map_type;
509
510         map_type m( 32 );
511         this->test( m );
512     }
513
514     TYPED_TEST_P( StripedMap, spinlock )
515     {
516         typedef cc::StripedMap<
517             typename TestFixture::container_type,
518             cds::opt::mutex_policy< cc::striped_set::striping<cds::sync::spin>>,
519             cds::opt::hash< typename TestFixture::hash1 >,
520             cds::opt::less< typename TestFixture::less >,
521             cds::opt::compare< typename TestFixture::cmp >
522         > map_type;
523
524         map_type m;
525         this->test( m );
526     }
527
528     TYPED_TEST_P( StripedMap, load_factor_resizing )
529     {
530         typedef cc::StripedMap<
531             typename TestFixture::container_type,
532             cds::opt::hash< typename TestFixture::hash1 >,
533             cds::opt::less< typename TestFixture::less >,
534             cds::opt::compare< typename TestFixture::cmp >,
535             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>
536         > map_type;
537
538         map_type m;
539         this->test( m );
540     }
541
542     TYPED_TEST_P( StripedMap, load_factor_resizing_rt )
543     {
544         typedef cc::StripedMap<
545             typename TestFixture::container_type,
546             cds::opt::hash< typename TestFixture::hash1 >,
547             cds::opt::compare< typename TestFixture::cmp >,
548             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>
549         > map_type;
550
551         map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
552         this->test( m );
553     }
554
555     TYPED_TEST_P( StripedMap, single_bucket_resizing )
556     {
557         typedef cc::StripedMap<
558             typename TestFixture::container_type,
559             cds::opt::hash< typename TestFixture::hash1 >,
560             cds::opt::compare< typename TestFixture::cmp >,
561             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>
562         > map_type;
563
564         map_type m( 30 );
565         this->test( m );
566     }
567
568     TYPED_TEST_P( StripedMap, single_bucket_resizing_rt )
569     {
570         typedef cc::StripedMap<
571             typename TestFixture::container_type,
572             cds::opt::hash< typename TestFixture::hash1 >,
573             cds::opt::compare< typename TestFixture::cmp >,
574             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<0>>
575         > map_type;
576
577         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
578         map_type m( 24, resizing_policy );
579         this->test( m );
580     }
581
582     TYPED_TEST_P( StripedMap, copy_policy_copy )
583     {
584         typedef cc::StripedMap<
585             typename TestFixture::container_type,
586             cds::opt::hash< typename TestFixture::hash1 >,
587             cds::opt::less< typename TestFixture::less >,
588             cds::opt::compare< typename TestFixture::cmp >,
589             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>,
590             cds::opt::copy_policy< cc::striped_set::copy_item >
591         > map_type;
592
593         map_type m;
594         this->test( m );
595     }
596
597     TYPED_TEST_P( StripedMap, copy_policy_move )
598     {
599         typedef cc::StripedMap<
600             typename TestFixture::container_type,
601             cds::opt::hash< typename TestFixture::hash1 >,
602             cds::opt::compare< typename TestFixture::cmp >,
603             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>,
604             cds::opt::copy_policy< cc::striped_set::move_item >
605         > map_type;
606
607         map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
608         this->test( m );
609     }
610
611     TYPED_TEST_P( StripedMap, copy_policy_swap )
612     {
613         typedef cc::StripedMap<
614             typename TestFixture::container_type,
615             cds::opt::hash< typename TestFixture::hash1 >,
616             cds::opt::compare< typename TestFixture::cmp >,
617             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>,
618             cds::opt::copy_policy< cc::striped_set::swap_item >
619         > map_type;
620
621         map_type m( 30 );
622         this->test( m );
623     }
624
625     TYPED_TEST_P( StripedMap, copy_policy_special )
626     {
627         typedef cc::StripedMap<
628             typename TestFixture::container_type,
629             cds::opt::hash< typename TestFixture::hash1 >,
630             cds::opt::compare< typename TestFixture::cmp >,
631             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<0>>,
632             cds::opt::copy_policy< typename TestFixture::copy_policy >
633         > map_type;
634
635         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
636         map_type m( 24, resizing_policy );
637         this->test( m );
638     }
639
640
641     // ****************************************************************
642     // refinable map
643
644     TYPED_TEST_P( RefinableMap, compare )
645     {
646         typedef cc::StripedMap<
647             typename TestFixture::container_type,
648             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
649             cds::opt::hash< typename TestFixture::hash1 >,
650             cds::opt::compare< typename TestFixture::cmp >
651         > map_type;
652
653         map_type m;
654         this->test( m );
655     }
656
657     TYPED_TEST_P( RefinableMap, less )
658     {
659         typedef cc::StripedMap<
660             typename TestFixture::container_type,
661             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
662             cds::opt::hash< typename TestFixture::hash1 >,
663             cds::opt::less< typename TestFixture::less >
664         > map_type;
665
666         map_type m;
667         this->test( m );
668     }
669
670
671     TYPED_TEST_P( RefinableMap, cmpmix )
672     {
673         typedef cc::StripedMap<
674             typename TestFixture::container_type,
675             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
676             cds::opt::hash< typename TestFixture::hash1 >,
677             cds::opt::less< typename TestFixture::less >,
678             cds::opt::compare< typename TestFixture::cmp >
679         > map_type;
680
681         map_type m( 32 );
682         this->test( m );
683     }
684
685     TYPED_TEST_P( RefinableMap, spinlock )
686     {
687         typedef cc::StripedMap<
688             typename TestFixture::container_type,
689             cds::opt::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin>>,
690             cds::opt::hash< typename TestFixture::hash1 >,
691             cds::opt::less< typename TestFixture::less >,
692             cds::opt::compare< typename TestFixture::cmp >
693         > map_type;
694
695         map_type m;
696         this->test( m );
697     }
698
699     TYPED_TEST_P( RefinableMap, load_factor_resizing )
700     {
701         typedef cc::StripedMap<
702             typename TestFixture::container_type,
703             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
704             cds::opt::hash< typename TestFixture::hash1 >,
705             cds::opt::less< typename TestFixture::less >,
706             cds::opt::compare< typename TestFixture::cmp >,
707             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>
708         > map_type;
709
710         map_type m;
711         this->test( m );
712     }
713
714     TYPED_TEST_P( RefinableMap, load_factor_resizing_rt )
715     {
716         typedef cc::StripedMap<
717             typename TestFixture::container_type,
718             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
719             cds::opt::hash< typename TestFixture::hash1 >,
720             cds::opt::compare< typename TestFixture::cmp >,
721             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>
722         > map_type;
723
724         map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
725         this->test( m );
726     }
727
728     TYPED_TEST_P( RefinableMap, single_bucket_resizing )
729     {
730         typedef cc::StripedMap<
731             typename TestFixture::container_type,
732             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
733             cds::opt::hash< typename TestFixture::hash1 >,
734             cds::opt::compare< typename TestFixture::cmp >,
735             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>
736         > map_type;
737
738         map_type m( 30 );
739         this->test( m );
740     }
741
742     TYPED_TEST_P( RefinableMap, single_bucket_resizing_rt )
743     {
744         typedef cc::StripedMap<
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         > map_type;
751
752         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
753         map_type m( 24, resizing_policy );
754         this->test( m );
755     }
756
757     TYPED_TEST_P( RefinableMap, copy_policy_copy )
758     {
759         typedef cc::StripedMap<
760             typename TestFixture::container_type,
761             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
762             cds::opt::hash< typename TestFixture::hash1 >,
763             cds::opt::less< typename TestFixture::less >,
764             cds::opt::compare< typename TestFixture::cmp >,
765             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<4>>,
766             cds::opt::copy_policy< cc::striped_set::copy_item >
767         > map_type;
768
769         map_type m;
770         this->test( m );
771     }
772
773     TYPED_TEST_P( RefinableMap, copy_policy_move )
774     {
775         typedef cc::StripedMap<
776             typename TestFixture::container_type,
777             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
778             cds::opt::hash< typename TestFixture::hash1 >,
779             cds::opt::compare< typename TestFixture::cmp >,
780             cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>,
781             cds::opt::copy_policy< cc::striped_set::move_item >
782         > map_type;
783
784         map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
785         this->test( m );
786     }
787
788     TYPED_TEST_P( RefinableMap, copy_policy_swap )
789     {
790         typedef cc::StripedMap<
791             typename TestFixture::container_type,
792             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
793             cds::opt::hash< typename TestFixture::hash1 >,
794             cds::opt::compare< typename TestFixture::cmp >,
795             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<6>>,
796             cds::opt::copy_policy< cc::striped_set::swap_item >
797         > map_type;
798
799         map_type m( 30 );
800         this->test( m );
801     }
802
803     TYPED_TEST_P( RefinableMap, copy_policy_special )
804     {
805         typedef cc::StripedMap<
806             typename TestFixture::container_type,
807             cds::opt::mutex_policy< cc::striped_set::refinable<>>,
808             cds::opt::hash< typename TestFixture::hash1 >,
809             cds::opt::compare< typename TestFixture::cmp >,
810             cds::opt::resizing_policy< cc::striped_set::single_bucket_size_threshold<0>>,
811             cds::opt::copy_policy< typename TestFixture::copy_policy >
812         > map_type;
813
814         cc::striped_set::single_bucket_size_threshold<0> resizing_policy( 8 );
815         map_type m( 24, resizing_policy );
816         this->test( m );
817     }
818
819     REGISTER_TYPED_TEST_CASE_P( StripedMap,
820         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
821     );
822
823     REGISTER_TYPED_TEST_CASE_P( RefinableMap,
824         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
825     );
826 } // namespace
827
828 #endif // #ifndef CDSUNIT_STRIPED_MAP_TEST_STRIPED_MAP_H