mirror of
https://github.com/boostorg/intrusive.git
synced 2025-10-18 02:45:19 +02:00
Changes and fixes for Boost 1.37
[SVN r49277]
This commit is contained in:
@@ -24,9 +24,9 @@
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
||||
static const std::size_t BucketSize = 11;
|
||||
static const std::size_t BucketSize = 8;
|
||||
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash>
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash, bool Incremental>
|
||||
struct test_unordered_set
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
@@ -34,14 +34,16 @@ struct test_unordered_set
|
||||
static void test_sort(std::vector<value_type>& values);
|
||||
static void test_insert(std::vector<value_type>& values);
|
||||
static void test_swap(std::vector<value_type>& values);
|
||||
static void test_rehash(std::vector<value_type>& values);
|
||||
static void test_rehash(std::vector<value_type>& values, detail::true_);
|
||||
static void test_rehash(std::vector<value_type>& values, detail::false_);
|
||||
static void test_find(std::vector<value_type>& values);
|
||||
static void test_impl();
|
||||
static void test_clone(std::vector<value_type>& values);
|
||||
};
|
||||
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_all(std::vector<typename ValueTraits::value_type>& values)
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash, bool Incremental>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash, Incremental>::
|
||||
test_all(std::vector<typename ValueTraits::value_type>& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef unordered_set
|
||||
@@ -50,6 +52,7 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_all(std::vec
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, cache_begin<CacheBegin>
|
||||
, compare_hash<CompareHash>
|
||||
, incremental<Incremental>
|
||||
> unordered_set_type;
|
||||
typedef typename unordered_set_type::bucket_traits bucket_traits;
|
||||
{
|
||||
@@ -70,15 +73,15 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_all(std::vec
|
||||
test_sort(values);
|
||||
test_insert(values);
|
||||
test_swap(values);
|
||||
test_rehash(values);
|
||||
test_rehash(values, detail::bool_<Incremental>());
|
||||
test_find(values);
|
||||
test_impl();
|
||||
test_clone(values);
|
||||
}
|
||||
|
||||
//test case due to an error in tree implementation:
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_impl()
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash, bool Incremental>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash, Incremental>::test_impl()
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef unordered_set
|
||||
@@ -87,6 +90,7 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_impl()
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, cache_begin<CacheBegin>
|
||||
, compare_hash<CompareHash>
|
||||
, incremental<Incremental>
|
||||
> unordered_set_type;
|
||||
typedef typename unordered_set_type::bucket_traits bucket_traits;
|
||||
|
||||
@@ -107,8 +111,9 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_impl()
|
||||
}
|
||||
|
||||
//test: constructor, iterator, clear, reverse_iterator, front, back, size:
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_sort(std::vector<typename ValueTraits::value_type>& values)
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash, bool Incremental>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash, Incremental>::
|
||||
test_sort(std::vector<typename ValueTraits::value_type>& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef unordered_set
|
||||
@@ -117,23 +122,31 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_sort(std::ve
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, cache_begin<CacheBegin>
|
||||
, compare_hash<CompareHash>
|
||||
, incremental<Incremental>
|
||||
> unordered_set_type;
|
||||
typedef typename unordered_set_type::bucket_traits bucket_traits;
|
||||
|
||||
typename unordered_set_type::bucket_type buckets [BucketSize];
|
||||
unordered_set_type testset1(values.begin(), values.end(), bucket_traits(buckets, BucketSize));
|
||||
|
||||
BOOST_TEST (5 == std::distance(testset1.begin(), testset1.end()));
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
if(Incremental){
|
||||
{ int init_values [] = { 4, 5, 1, 2, 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
}
|
||||
else{
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
}
|
||||
|
||||
testset1.clear();
|
||||
BOOST_TEST (testset1.empty());
|
||||
}
|
||||
|
||||
//test: insert, const_iterator, const_reverse_iterator, erase, iterator_to:
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_insert(std::vector<typename ValueTraits::value_type>& values)
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash, bool Incremental>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash, Incremental>::
|
||||
test_insert(std::vector<typename ValueTraits::value_type>& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef unordered_set
|
||||
@@ -142,6 +155,7 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_insert(std::
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, cache_begin<CacheBegin>
|
||||
, compare_hash<CompareHash>
|
||||
, incremental<Incremental>
|
||||
> unordered_set_type;
|
||||
typedef typename unordered_set_type::bucket_traits bucket_traits;
|
||||
|
||||
@@ -150,27 +164,47 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_insert(std::
|
||||
testset.insert(&values[0] + 2, &values[0] + 5);
|
||||
|
||||
const unordered_set_type& const_testset = testset;
|
||||
{ int init_values [] = { 1, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); }
|
||||
if(Incremental)
|
||||
{
|
||||
{ int init_values [] = { 4, 5, 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); }
|
||||
typename unordered_set_type::iterator i = testset.begin();
|
||||
BOOST_TEST (i->value_ == 4);
|
||||
|
||||
typename unordered_set_type::iterator i = testset.begin();
|
||||
BOOST_TEST (i->value_ == 1);
|
||||
i = testset.insert(values[0]).first;
|
||||
BOOST_TEST (&*i == &values[0]);
|
||||
|
||||
i = testset.insert(values[0]).first;
|
||||
BOOST_TEST (&*i == &values[0]);
|
||||
i = testset.iterator_to (values[2]);
|
||||
BOOST_TEST (&*i == &values[2]);
|
||||
|
||||
i = testset.iterator_to (values[2]);
|
||||
BOOST_TEST (&*i == &values[2]);
|
||||
testset.erase (i);
|
||||
|
||||
testset.erase (i);
|
||||
{ int init_values [] = { 5, 1, 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); }
|
||||
}
|
||||
else{
|
||||
{ int init_values [] = { 1, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); }
|
||||
typename unordered_set_type::iterator i = testset.begin();
|
||||
BOOST_TEST (i->value_ == 1);
|
||||
|
||||
{ int init_values [] = { 1, 3, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); }
|
||||
i = testset.insert(values[0]).first;
|
||||
BOOST_TEST (&*i == &values[0]);
|
||||
|
||||
i = testset.iterator_to (values[2]);
|
||||
BOOST_TEST (&*i == &values[2]);
|
||||
|
||||
testset.erase (i);
|
||||
|
||||
{ int init_values [] = { 1, 3, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); }
|
||||
}
|
||||
}
|
||||
|
||||
//test: insert (seq-version), swap, erase (seq-version), size:
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_swap(std::vector<typename ValueTraits::value_type>& values)
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash, bool Incremental>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash, Incremental>::
|
||||
test_swap(std::vector<typename ValueTraits::value_type>& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef unordered_set
|
||||
@@ -179,6 +213,7 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_swap(std::ve
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, cache_begin<CacheBegin>
|
||||
, compare_hash<CompareHash>
|
||||
, incremental<Incremental>
|
||||
> unordered_set_type;
|
||||
typedef typename unordered_set_type::bucket_traits bucket_traits;
|
||||
|
||||
@@ -190,20 +225,30 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_swap(std::ve
|
||||
testset2.insert (&values[0] + 2, &values[0] + 6);
|
||||
testset1.swap (testset2);
|
||||
|
||||
{ int init_values [] = { 1, 2, 4, 5 };
|
||||
if(Incremental){
|
||||
{ int init_values [] = { 4, 5, 1, 2 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
{ int init_values [] = { 2, 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); }
|
||||
testset1.erase (testset1.iterator_to(values[4]), testset1.end());
|
||||
BOOST_TEST (testset1.size() == 1);
|
||||
BOOST_TEST (&*testset1.begin() == &values[2]);
|
||||
}
|
||||
else{
|
||||
{ int init_values [] = { 1, 2, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
{ int init_values [] = { 2, 3 };
|
||||
{ int init_values [] = { 2, 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); }
|
||||
|
||||
testset1.erase (testset1.iterator_to(values[5]), testset1.end());
|
||||
BOOST_TEST (testset1.size() == 1);
|
||||
// BOOST_TEST (&testset1.front() == &values[3]);
|
||||
BOOST_TEST (&*testset1.begin() == &values[3]);
|
||||
testset1.erase (testset1.iterator_to(values[5]), testset1.end());
|
||||
BOOST_TEST (testset1.size() == 1);
|
||||
BOOST_TEST (&*testset1.begin() == &values[3]);
|
||||
}
|
||||
}
|
||||
|
||||
//test: rehash:
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_rehash(std::vector<typename ValueTraits::value_type>& values)
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash, bool Incremental>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash, Incremental>::
|
||||
test_rehash(std::vector<typename ValueTraits::value_type>& values, detail::true_)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef unordered_set
|
||||
@@ -212,6 +257,137 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_rehash(std::
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, cache_begin<CacheBegin>
|
||||
, compare_hash<CompareHash>
|
||||
, incremental<Incremental>
|
||||
> unordered_set_type;
|
||||
typedef typename unordered_set_type::bucket_traits bucket_traits;
|
||||
//Build a uset
|
||||
typename unordered_set_type::bucket_type buckets1 [BucketSize];
|
||||
typename unordered_set_type::bucket_type buckets2 [BucketSize*2];
|
||||
unordered_set_type testset1(&values[0], &values[0] + 6, bucket_traits(buckets1, BucketSize));
|
||||
//Test current state
|
||||
BOOST_TEST(testset1.split_count() == BucketSize/2);
|
||||
{ int init_values [] = { 4, 5, 1, 2, 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
//Incremental rehash step
|
||||
BOOST_TEST (testset1.incremental_rehash() == true);
|
||||
BOOST_TEST(testset1.split_count() == (BucketSize/2+1));
|
||||
{ int init_values [] = { 5, 1, 2, 3, 4 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
//Rest of incremental rehashes should lead to the same sequence
|
||||
for(std::size_t split_bucket = testset1.split_count(); split_bucket != BucketSize; ++split_bucket){
|
||||
BOOST_TEST (testset1.incremental_rehash() == true);
|
||||
BOOST_TEST(testset1.split_count() == (split_bucket+1));
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
}
|
||||
//This incremental rehash should fail because we've reached the end of the bucket array
|
||||
BOOST_TEST(testset1.incremental_rehash() == false);
|
||||
BOOST_TEST(testset1.split_count() == BucketSize);
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
//
|
||||
//Try incremental hashing specifying a new bucket traits pointing to the same array
|
||||
//
|
||||
//This incremental rehash should fail because the new size is not twice the original
|
||||
BOOST_TEST(testset1.incremental_rehash(bucket_traits(buckets1, BucketSize)) == false);
|
||||
BOOST_TEST(testset1.split_count() == BucketSize);
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
//This incremental rehash should success because the new size is twice the original
|
||||
//and split_count is the same as the old bucket count
|
||||
BOOST_TEST(testset1.incremental_rehash(bucket_traits(buckets1, BucketSize*2)) == true);
|
||||
BOOST_TEST(testset1.split_count() == BucketSize);
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
//This incremental rehash should also success because the new size is half the original
|
||||
//and split_count is the same as the new bucket count
|
||||
BOOST_TEST(testset1.incremental_rehash(bucket_traits(buckets1, BucketSize)) == true);
|
||||
BOOST_TEST(testset1.split_count() == BucketSize);
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
//
|
||||
//Try incremental hashing specifying a new bucket traits pointing to the same array
|
||||
//
|
||||
//This incremental rehash should fail because the new size is not twice the original
|
||||
BOOST_TEST(testset1.incremental_rehash(bucket_traits(buckets2, BucketSize)) == false);
|
||||
BOOST_TEST(testset1.split_count() == BucketSize);
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
//This incremental rehash should success because the new size is twice the original
|
||||
//and split_count is the same as the old bucket count
|
||||
BOOST_TEST(testset1.incremental_rehash(bucket_traits(buckets2, BucketSize*2)) == true);
|
||||
BOOST_TEST(testset1.split_count() == BucketSize);
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
//This incremental rehash should also success because the new size is half the original
|
||||
//and split_count is the same as the new bucket count
|
||||
BOOST_TEST(testset1.incremental_rehash(bucket_traits(buckets1, BucketSize)) == true);
|
||||
BOOST_TEST(testset1.split_count() == BucketSize);
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
//Full shrink rehash
|
||||
testset1.rehash(bucket_traits(buckets1, 4));
|
||||
BOOST_TEST (testset1.size() == values.size()-1);
|
||||
BOOST_TEST (testset1.incremental_rehash() == false);
|
||||
{ int init_values [] = { 4, 5, 1, 2, 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
//Full shrink rehash again
|
||||
testset1.rehash(bucket_traits(buckets1, 2));
|
||||
BOOST_TEST (testset1.size() == values.size()-1);
|
||||
BOOST_TEST (testset1.incremental_rehash() == false);
|
||||
{ int init_values [] = { 2, 4, 3, 5, 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
//Full growing rehash
|
||||
testset1.rehash(bucket_traits(buckets1, BucketSize));
|
||||
BOOST_TEST (testset1.size() == values.size()-1);
|
||||
BOOST_TEST (testset1.incremental_rehash() == false);
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
//Incremental rehash shrinking
|
||||
//First incremental rehashes should lead to the same sequence
|
||||
for(std::size_t split_bucket = testset1.split_count(); split_bucket > 6; --split_bucket){
|
||||
BOOST_TEST (testset1.incremental_rehash(false) == true);
|
||||
BOOST_TEST(testset1.split_count() == (split_bucket-1));
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
}
|
||||
//Incremental rehash step
|
||||
BOOST_TEST (testset1.incremental_rehash(false) == true);
|
||||
BOOST_TEST(testset1.split_count() == (BucketSize/2+1));
|
||||
{ int init_values [] = { 5, 1, 2, 3, 4 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
//Incremental rehash step 2
|
||||
BOOST_TEST (testset1.incremental_rehash(false) == true);
|
||||
BOOST_TEST(testset1.split_count() == (BucketSize/2));
|
||||
{ int init_values [] = { 4, 5, 1, 2, 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
//This incremental rehash should fail because we've reached the half of the bucket array
|
||||
BOOST_TEST(testset1.incremental_rehash(false) == false);
|
||||
BOOST_TEST(testset1.split_count() == BucketSize/2);
|
||||
{ int init_values [] = { 4, 5, 1, 2, 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
}
|
||||
|
||||
//test: rehash:
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash, bool Incremental>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash, Incremental>::
|
||||
test_rehash(std::vector<typename ValueTraits::value_type>& values, detail::false_)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef unordered_set
|
||||
<value_type
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, cache_begin<CacheBegin>
|
||||
, compare_hash<CompareHash>
|
||||
, incremental<Incremental>
|
||||
> unordered_set_type;
|
||||
typedef typename unordered_set_type::bucket_traits bucket_traits;
|
||||
|
||||
@@ -220,37 +396,38 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_rehash(std::
|
||||
typename unordered_set_type::bucket_type buckets3 [BucketSize*2];
|
||||
|
||||
unordered_set_type testset1(&values[0], &values[0] + 6, bucket_traits(buckets1, BucketSize));
|
||||
BOOST_TEST (testset1.size() == 5);
|
||||
BOOST_TEST (testset1.size() == values.size()-1);
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
testset1.rehash(bucket_traits(buckets2, 2));
|
||||
BOOST_TEST (testset1.size() == 5);
|
||||
BOOST_TEST (testset1.size() == values.size()-1);
|
||||
{ int init_values [] = { 4, 2, 5, 3, 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
testset1.rehash(bucket_traits(buckets3, BucketSize*2));
|
||||
BOOST_TEST (testset1.size() == 5);
|
||||
BOOST_TEST (testset1.size() == values.size()-1);
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
//Now rehash reducing the buckets
|
||||
testset1.rehash(bucket_traits(buckets3, 2));
|
||||
BOOST_TEST (testset1.size() == 5);
|
||||
BOOST_TEST (testset1.size() == values.size()-1);
|
||||
{ int init_values [] = { 4, 2, 5, 3, 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
|
||||
//Now rehash increasing the buckets
|
||||
testset1.rehash(bucket_traits(buckets3, BucketSize*2));
|
||||
BOOST_TEST (testset1.size() == 5);
|
||||
BOOST_TEST (testset1.size() == values.size()-1);
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
|
||||
}
|
||||
|
||||
|
||||
//test: find, equal_range (lower_bound, upper_bound):
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_find(std::vector<typename ValueTraits::value_type>& values)
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash, bool Incremental>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash, Incremental>::
|
||||
test_find(std::vector<typename ValueTraits::value_type>& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef unordered_set
|
||||
@@ -259,6 +436,7 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_find(std::ve
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, cache_begin<CacheBegin>
|
||||
, compare_hash<CompareHash>
|
||||
, incremental<Incremental>
|
||||
> unordered_set_type;
|
||||
typedef typename unordered_set_type::bucket_traits bucket_traits;
|
||||
|
||||
@@ -281,8 +459,8 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>::test_find(std::ve
|
||||
BOOST_TEST (testset.find (cmp_val) == testset.end());
|
||||
}
|
||||
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash>
|
||||
template<class ValueTraits, bool CacheBegin, bool CompareHash, bool Incremental>
|
||||
void test_unordered_set<ValueTraits, CacheBegin, CompareHash, Incremental>
|
||||
::test_clone(std::vector<typename ValueTraits::value_type>& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
@@ -292,6 +470,7 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
, cache_begin<CacheBegin>
|
||||
, compare_hash<CompareHash>
|
||||
, incremental<Incremental>
|
||||
> unordered_set_type;
|
||||
typedef typename unordered_set_type::bucket_traits bucket_traits;
|
||||
{
|
||||
@@ -319,7 +498,7 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>
|
||||
unordered_set_type testset2 (bucket_traits(buckets2, BucketSize));
|
||||
|
||||
testset2.clone_from(testset1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
|
||||
//Ordering is not guarantee in the cloning so insert data in a set and test
|
||||
//Ordering is not guaranteed in the cloning so insert data in a set and test
|
||||
std::set<typename ValueTraits::value_type>
|
||||
src(testset1.begin(), testset1.end());
|
||||
std::set<typename ValueTraits::value_type>
|
||||
@@ -347,7 +526,7 @@ void test_unordered_set<ValueTraits, CacheBegin, CompareHash>
|
||||
}
|
||||
}
|
||||
|
||||
template<class VoidPointer, bool constant_time_size>
|
||||
template<class VoidPointer, bool constant_time_size, bool incremental>
|
||||
class test_main_template
|
||||
{
|
||||
public:
|
||||
@@ -365,6 +544,7 @@ class test_main_template
|
||||
>::type
|
||||
, true
|
||||
, false
|
||||
, incremental
|
||||
>::test_all(data);
|
||||
test_unordered_set < typename detail::get_member_value_traits
|
||||
< value_type
|
||||
@@ -375,14 +555,15 @@ class test_main_template
|
||||
>::type
|
||||
, false
|
||||
, false
|
||||
, incremental
|
||||
>::test_all(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
class test_main_template<VoidPointer, false>
|
||||
template<class VoidPointer, bool incremental>
|
||||
class test_main_template<VoidPointer, false, incremental>
|
||||
{
|
||||
public:
|
||||
int operator()()
|
||||
@@ -399,6 +580,7 @@ class test_main_template<VoidPointer, false>
|
||||
>::type
|
||||
, true
|
||||
, false
|
||||
, incremental
|
||||
>::test_all(data);
|
||||
|
||||
test_unordered_set < typename detail::get_member_value_traits
|
||||
@@ -410,6 +592,7 @@ class test_main_template<VoidPointer, false>
|
||||
>::type
|
||||
, false
|
||||
, false
|
||||
, incremental
|
||||
>::test_all(data);
|
||||
|
||||
test_unordered_set < typename detail::get_base_value_traits
|
||||
@@ -418,6 +601,7 @@ class test_main_template<VoidPointer, false>
|
||||
>::type
|
||||
, true
|
||||
, true
|
||||
, incremental
|
||||
>::test_all(data);
|
||||
|
||||
test_unordered_set < typename detail::get_member_value_traits
|
||||
@@ -429,6 +613,7 @@ class test_main_template<VoidPointer, false>
|
||||
>::type
|
||||
, false
|
||||
, true
|
||||
, incremental
|
||||
>::test_all(data);
|
||||
return 0;
|
||||
}
|
||||
@@ -436,10 +621,14 @@ class test_main_template<VoidPointer, false>
|
||||
|
||||
int main( int, char* [] )
|
||||
{
|
||||
test_main_template<void*, false>()();
|
||||
test_main_template<smart_ptr<void>, false>()();
|
||||
test_main_template<void*, true>()();
|
||||
test_main_template<smart_ptr<void>, true>()();
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<smart_ptr<void>, false, true>()();
|
||||
test_main_template<void*, true, true>()();
|
||||
test_main_template<smart_ptr<void>, true, true>()();
|
||||
test_main_template<void*, false, false>()();
|
||||
test_main_template<smart_ptr<void>, false, false>()();
|
||||
test_main_template<void*, true, true>()();
|
||||
test_main_template<smart_ptr<void>, true, false>()();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
Reference in New Issue
Block a user