From: khizmax Date: Tue, 22 Mar 2016 19:57:59 +0000 (+0300) Subject: Migrated intrusive StripedSet to gtest framework X-Git-Tag: v2.2.0~323 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=26ce60ca752b62326f85db07617175c936bcdaad;p=libcds.git Migrated intrusive StripedSet to gtest framework --- diff --git a/projects/Win/vc14/gtest-striped-set.vcxproj b/projects/Win/vc14/gtest-striped-set.vcxproj index 8b5384dc..482b02e8 100644 --- a/projects/Win/vc14/gtest-striped-set.vcxproj +++ b/projects/Win/vc14/gtest-striped-set.vcxproj @@ -43,6 +43,7 @@ _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + diff --git a/projects/Win/vc14/gtest-striped-set.vcxproj.filters b/projects/Win/vc14/gtest-striped-set.vcxproj.filters index 9683579a..dd452fec 100644 --- a/projects/Win/vc14/gtest-striped-set.vcxproj.filters +++ b/projects/Win/vc14/gtest-striped-set.vcxproj.filters @@ -42,6 +42,9 @@ Source Files + + Source Files + diff --git a/test/unit/striped-set/CMakeLists.txt b/test/unit/striped-set/CMakeLists.txt index 3f2a1cab..968c32d7 100644 --- a/test/unit/striped-set/CMakeLists.txt +++ b/test/unit/striped-set/CMakeLists.txt @@ -11,6 +11,7 @@ set(CDSGTEST_SET_SOURCES intrusive_boost_slist.cpp intrusive_boost_splay_set.cpp intrusive_boost_treap_set.cpp + intrusive_boost_unordered_set.cpp intrusive_cuckoo_set.cpp ) diff --git a/test/unit/striped-set/intrusive_boost_unordered_set.cpp b/test/unit/striped-set/intrusive_boost_unordered_set.cpp new file mode 100644 index 00000000..84d4ca4e --- /dev/null +++ b/test/unit/striped-set/intrusive_boost_unordered_set.cpp @@ -0,0 +1,326 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#ifndef CDSUNIT_SET_TEST_INTRUSIVE_BOOST_UNORDERED_SET_H +#define CDSUNIT_SET_TEST_INTRUSIVE_BOOST_UNORDERED_SET_H + +#ifdef CDSUNIT_ENABLE_BOOST_CONTAINER + +#include "test_intrusive_set.h" + +#include +#include + +namespace { + namespace ci = cds::intrusive; + namespace bi = boost::intrusive; + + class IntrusiveStripedBoostUnorderedSet: public cds_test::intrusive_set + { + public: + typedef base_int_item< bi::unordered_set_base_hook<>> base_item; + typedef member_int_item< bi::unordered_set_member_hook<>> member_item; + }; + + template + struct dyn_buffer: public ci::opt::v::dynamic_buffer< T, Alloc > + { + typedef ci::opt::v::dynamic_buffer< T, Alloc > base_class; + public: + template + struct rebind { + typedef dyn_buffer other; ///< Rebinding result type + }; + + dyn_buffer() + : base_class( Capacity ) + {} + }; + + TEST_F( IntrusiveStripedBoostUnorderedSet, basehook ) + { + typedef ci::StripedSet< + bi::unordered_set< base_item + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,cds::intrusive::opt::hash< hash2 > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s; + this->test( s, data ); + } + } + + TEST_F( IntrusiveStripedBoostUnorderedSet, basehook_resize_bucket_threshold ) + { + typedef ci::StripedSet< + bi::unordered_set< base_item + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,cds::intrusive::opt::hash< hash2 > + ,cds::intrusive::opt::buffer< cds::intrusive::opt::v::static_buffer< cds::any_type, 64 > > + ,cds::intrusive::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s; + this->test( s, data ); + } + } + + TEST_F( IntrusiveStripedBoostUnorderedSet, basehook_resize_bucket_threshold_rt ) + { + typedef ci::StripedSet< + bi::unordered_set< base_item + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,ci::opt::hash< hash2 > + ,ci::opt::buffer< dyn_buffer<64, cds::any_type>> + ,ci::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) ); + this->test( s, data ); + } + } + + TEST_F( IntrusiveStripedBoostUnorderedSet, memberhook ) + { + typedef ci::StripedSet< + bi::unordered_set< member_item + , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember> + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,cds::intrusive::opt::hash< hash2 > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s; + this->test( s, data ); + } + } + + TEST_F( IntrusiveStripedBoostUnorderedSet, memberhook_resize_bucket_threshold ) + { + typedef ci::StripedSet< + bi::unordered_set< member_item + , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember> + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,cds::intrusive::opt::hash< hash2 > + ,cds::intrusive::opt::buffer< cds::intrusive::opt::v::static_buffer< cds::any_type, 64 > > + ,cds::intrusive::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s; + this->test( s, data ); + } + } + + TEST_F( IntrusiveStripedBoostUnorderedSet, memberhook_resize_bucket_threshold_rt ) + { + typedef ci::StripedSet< + bi::unordered_set< member_item + , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember> + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,ci::opt::hash< hash2 > + ,ci::opt::buffer< dyn_buffer<64, cds::any_type>> + ,ci::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) ); + this->test( s, data ); + } + } + + TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_basehook ) + { + typedef ci::StripedSet< + bi::unordered_set< base_item + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,cds::intrusive::opt::hash< hash2 > + ,ci::opt::mutex_policy< ci::striped_set::refinable<> > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s; + this->test( s, data ); + } + } + + TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_basehook_resize_bucket_threshold ) + { + typedef ci::StripedSet< + bi::unordered_set< base_item + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,ci::opt::mutex_policy< ci::striped_set::refinable<> > + ,cds::intrusive::opt::hash< hash2 > + ,cds::intrusive::opt::buffer< cds::intrusive::opt::v::static_buffer< cds::any_type, 64 > > + ,cds::intrusive::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s; + this->test( s, data ); + } + } + + TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_basehook_resize_bucket_threshold_rt ) + { + typedef ci::StripedSet< + bi::unordered_set< base_item + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,ci::opt::hash< hash2 > + ,ci::opt::mutex_policy< ci::striped_set::refinable<> > + ,ci::opt::buffer< dyn_buffer<64, cds::any_type>> + ,ci::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) ); + this->test( s, data ); + } + } + + TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_memberhook ) + { + typedef ci::StripedSet< + bi::unordered_set< member_item + , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember> + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,cds::intrusive::opt::hash< hash2 > + ,ci::opt::mutex_policy< ci::striped_set::refinable<> > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s; + this->test( s, data ); + } + } + + TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_memberhook_resize_bucket_threshold ) + { + typedef ci::StripedSet< + bi::unordered_set< member_item + , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember> + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,cds::intrusive::opt::hash< hash2 > + ,ci::opt::mutex_policy< ci::striped_set::refinable<> > + ,cds::intrusive::opt::buffer< cds::intrusive::opt::v::static_buffer< cds::any_type, 64 > > + ,cds::intrusive::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s; + this->test( s, data ); + } + } + + TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_memberhook_resize_bucket_threshold_rt ) + { + typedef ci::StripedSet< + bi::unordered_set< member_item + , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember> + , bi::hash< hash1 > + , bi::equal< equal_to > + , bi::power_2_buckets + , bi::incremental + > + ,ci::opt::hash< hash2 > + ,ci::opt::mutex_policy< ci::striped_set::refinable<> > + ,ci::opt::buffer< dyn_buffer<64, cds::any_type>> + ,ci::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > + > set_type; + + std::vector< typename set_type::value_type > data; + { + set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) ); + this->test( s, data ); + } + } + +} // namespace + +#endif // #ifdef CDSUNIT_ENABLE_BOOST_CONTAINER +#endif // CDSUNIT_SET_TEST_INTRUSIVE_BOOST_UNORDERED_SET_H diff --git a/test/unit/striped-set/test_intrusive_set.h b/test/unit/striped-set/test_intrusive_set.h index 14f672e1..6776f456 100644 --- a/test/unit/striped-set/test_intrusive_set.h +++ b/test/unit/striped-set/test_intrusive_set.h @@ -256,14 +256,12 @@ namespace cds_test { return v1.key() == v2.key(); } - template - int operator ()( const T& v1, const Q& v2 ) const + int operator ()( const T& v1, int v2 ) const { return v1.key() == v2; } - template - int operator ()( const Q& v1, const T& v2 ) const + int operator ()( int v1, const T& v2 ) const { return v1 == v2.key(); }