Fixed minor compiler warnings
[libcds.git] / test / unit / set / test_feldman_hashset_rcu.h
index 957d9ff8d3b44d871d4501725c13dc5e71e603cf..f5135ddeffd4dd42fb6f3b1523e4aaee689121af 100644 (file)
@@ -1,7 +1,7 @@
 /*
     This file is a part of libcds - Concurrent Data Structures library
 
-    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
@@ -53,7 +53,7 @@ namespace {
             // Precondition: set is empty
             // Postcondition: set is empty
 
-            ASSERT_TRUE( s.empty() );
+            ASSERT_TRUE( s.empty());
             ASSERT_CONTAINER_SIZE( s, 0 );
 
             base_class::test( s );
@@ -66,15 +66,15 @@ namespace {
             data.reserve( kSize );
             indices.reserve( kSize );
             for ( size_t key = 0; key < kSize; ++key ) {
-                data.push_back( value_type( static_cast<int>(key) ) );
+                data.push_back( value_type( static_cast<int>(key)));
                 indices.push_back( key );
             }
-            shuffle( indices.begin(), indices.end() );
+            shuffle( indices.begin(), indices.end());
 
             for ( auto& i : data ) {
-                ASSERT_TRUE( s.insert( i ) );
+                ASSERT_TRUE( s.insert( i ));
             }
-            ASSERT_FALSE( s.empty() );
+            ASSERT_FALSE( s.empty());
             ASSERT_CONTAINER_SIZE( s, nSetSize );
 
             typedef typename Set::rcu_lock rcu_lock;
@@ -110,8 +110,8 @@ namespace {
                     rcu_lock l;
                     value_type * p = s.get( i.key());
                     ASSERT_TRUE( p != nullptr );
-                    EXPECT_EQ( p->key(), i.key() );
-                    EXPECT_EQ( p->nFindCount, i.key() * 2 );
+                    EXPECT_EQ( p->key(), i.key());
+                    EXPECT_EQ( p->nFindCount, static_cast<size_t>( i.key() * 2 ));
                     p->nFindCount *= 2;
                 }
             }
@@ -122,22 +122,22 @@ namespace {
                 auto& i = data[idx];
 
                 ASSERT_TRUE( !xp );
-                xp = s.extract( i.key() );
+                xp = s.extract( i.key());
                 ASSERT_FALSE( !xp );
-                EXPECT_EQ( xp->key(), i.key() );
-                EXPECT_EQ( xp->nFindCount, i.key() * 4 );
+                EXPECT_EQ( xp->key(), i.key());
+                EXPECT_EQ( xp->nFindCount, static_cast<size_t>( i.key() * 4 ));
 
-                xp = s.extract( i.key() );
+                xp = s.extract( i.key());
                 ASSERT_TRUE( !xp );
 
                 {
                     rcu_lock l;
-                    value_type * p = s.get( i.key() );
+                    value_type * p = s.get( i.key());
                     EXPECT_TRUE( p == nullptr );
                 }
             }
 
-            ASSERT_TRUE( s.empty() );
+            ASSERT_TRUE( s.empty());
             ASSERT_CONTAINER_SIZE( s, 0 );
         }
 
@@ -280,10 +280,31 @@ namespace {
         this->test( s );
     }
 
+    TYPED_TEST_P( FeldmanHashSet, explicit_hash_size )
+    {
+        typedef typename TestFixture::rcu_type rcu_type;
+        typedef typename TestFixture::int_item2 int_item;
+        typedef typename TestFixture::get_hash2 get_hash2;
+
+        struct set_traits: public cc::feldman_hashset::traits
+        {
+            enum: size_t {
+                hash_size = sizeof( std::declval<int_item>().nKey )
+            };
+            typedef get_hash2 hash_accessor;
+            typedef typename TestFixture::cmp2 compare;
+            typedef cc::feldman_hashset::stat<> stat;
+        };
+        typedef cc::FeldmanHashSet< rcu_type, int_item, set_traits > set_type;
+
+        set_type s( 8, 4 );
+        this->test( s );
+    }
+
     // GCC 5: All test names should be written on single line, otherwise a runtime error will be encountered like as
     // "No test named <test_name> can be found in this test case"
     REGISTER_TYPED_TEST_CASE_P( FeldmanHashSet,
-        defaulted, compare, less, cmpmix, item_counting, backoff, stat
+        defaulted, compare, less, cmpmix, item_counting, backoff, stat, explicit_hash_size
         );
 } // namespace