/*
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/
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CDSUNIT_SET_TEST_FELDMAN_HASHSET_RCU_H
// 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 );
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;
}
for ( auto it = s.cbegin(); it != s.cend(); ++it ) {
- EXPECT_EQ( it->nFindCount, it->key() * 3 );
+ EXPECT_EQ( it->nFindCount, static_cast<size_t>( it->key() * 3 ));
}
for ( auto it = s.rbegin(); it != s.rend(); ++it ) {
}
for ( auto it = s.crbegin(); it != s.crend(); ++it ) {
- EXPECT_EQ( it->nFindCount, it->key() * 2 );
+ EXPECT_EQ( it->nFindCount, static_cast<size_t>( it->key() * 2 ));
}
}
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;
}
}
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 );
}
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