forked from boostorg/unordered
Merge latest unordered developments:
Make simple_test test a little more. Use doubles for calculating max load factor. Some workarounds, mostly for Borland and running the tests. [SVN r42666]
This commit is contained in:
@@ -18,8 +18,8 @@ test::seed_t seed(96785);
|
||||
template <class T>
|
||||
void assign_tests1(T* = 0)
|
||||
{
|
||||
typename T::hasher hf;
|
||||
typename T::key_equal eq;
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq;
|
||||
|
||||
std::cerr<<"assign_tests1.1\n";
|
||||
{
|
||||
@@ -52,12 +52,12 @@ void assign_tests1(T* = 0)
|
||||
template <class T>
|
||||
void assign_tests2(T* = 0)
|
||||
{
|
||||
typename T::hasher hf1(1);
|
||||
typename T::hasher hf2(2);
|
||||
typename T::key_equal eq1(1);
|
||||
typename T::key_equal eq2(2);
|
||||
typename T::allocator_type al1(1);
|
||||
typename T::allocator_type al2(2);
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf2(2);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq2(2);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
|
||||
|
||||
std::cerr<<"assign_tests2.1\n";
|
||||
{
|
||||
|
||||
@@ -16,8 +16,8 @@ test::seed_t seed(54635);
|
||||
template <class X>
|
||||
void bucket_tests(X* = 0)
|
||||
{
|
||||
typedef typename X::size_type size_type;
|
||||
typedef typename X::const_local_iterator const_local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
|
||||
test::random_values<X> v(1000);
|
||||
|
||||
X x(v.begin(), v.end());
|
||||
@@ -25,7 +25,7 @@ void bucket_tests(X* = 0)
|
||||
BOOST_TEST(x.bucket_count() < x.max_bucket_count());
|
||||
std::cerr<<x.bucket_count()<<"<"<<x.max_bucket_count()<<"\n";
|
||||
|
||||
for(typename test::random_values<X>::const_iterator
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator
|
||||
it = v.begin(), end = v.end(); it != end; ++it)
|
||||
{
|
||||
size_type bucket = x.bucket(test::get_key<X>(*it));
|
||||
|
||||
@@ -29,19 +29,19 @@ template <class T> void sink(T const&) {}
|
||||
template <class X, class T>
|
||||
void container_test(X& r, T&)
|
||||
{
|
||||
typedef typename X::iterator iterator;
|
||||
typedef typename X::const_iterator const_iterator;
|
||||
typedef typename X::difference_type difference_type;
|
||||
typedef typename X::size_type size_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::difference_type difference_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
|
||||
|
||||
typedef typename boost::iterator_value<iterator>::type iterator_value_type;
|
||||
typedef typename boost::iterator_value<const_iterator>::type const_iterator_value_type;
|
||||
typedef typename boost::iterator_difference<iterator>::type iterator_difference_type;
|
||||
typedef typename boost::iterator_difference<const_iterator>::type const_iterator_difference_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<iterator>::type iterator_value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<const_iterator>::type const_iterator_value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<iterator>::type iterator_difference_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<const_iterator>::type const_iterator_difference_type;
|
||||
|
||||
typedef typename X::value_type value_type;
|
||||
typedef typename X::reference reference;
|
||||
typedef typename X::const_reference const_reference;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::reference reference;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_reference const_reference;
|
||||
|
||||
// value_type
|
||||
|
||||
@@ -132,8 +132,8 @@ void container_test(X& r, T&)
|
||||
template <class X, class Key>
|
||||
void unordered_set_test(X&, Key const&)
|
||||
{
|
||||
typedef typename X::value_type value_type;
|
||||
typedef typename X::key_type key_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<value_type, key_type>));
|
||||
}
|
||||
@@ -141,29 +141,29 @@ void unordered_set_test(X&, Key const&)
|
||||
template <class X, class Key, class T>
|
||||
void unordered_map_test(X&, Key const&, T const&)
|
||||
{
|
||||
typedef typename X::value_type value_type;
|
||||
typedef typename X::key_type key_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
||||
BOOST_MPL_ASSERT((boost::is_same<value_type, std::pair<key_type const, T> >));
|
||||
}
|
||||
|
||||
template <class X, class T>
|
||||
void unordered_unique_test(X& r, T const& t)
|
||||
{
|
||||
typedef typename X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
test::check_return_type<std::pair<iterator, bool> >::equals(r.insert(t));
|
||||
}
|
||||
|
||||
template <class X, class T>
|
||||
void unordered_equivalent_test(X& r, T const& t)
|
||||
{
|
||||
typedef typename X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
test::check_return_type<iterator>::equals(r.insert(t));
|
||||
}
|
||||
|
||||
template <class X, class Key, class T>
|
||||
void unordered_map_functions(X&, Key const& k, T const&)
|
||||
{
|
||||
typedef typename X::mapped_type mapped_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::mapped_type mapped_type;
|
||||
|
||||
X a;
|
||||
test::check_return_type<mapped_type>::equals_ref(a[k]);
|
||||
@@ -176,35 +176,35 @@ void unordered_map_functions(X&, Key const& k, T const&)
|
||||
template <class X, class Key, class T, class Hash, class Pred>
|
||||
void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq)
|
||||
{
|
||||
typedef typename X::key_type key_type;
|
||||
typedef typename X::hasher hasher;
|
||||
typedef typename X::key_equal key_equal;
|
||||
typedef typename X::size_type size_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::hasher hasher;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_equal key_equal;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
|
||||
|
||||
typedef typename X::iterator iterator;
|
||||
typedef typename X::const_iterator const_iterator;
|
||||
typedef typename X::local_iterator local_iterator;
|
||||
typedef typename X::const_local_iterator const_local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
|
||||
|
||||
typedef typename boost::BOOST_ITERATOR_CATEGORY<iterator>::type iterator_category;
|
||||
typedef typename boost::iterator_difference<iterator>::type iterator_difference;
|
||||
typedef typename boost::iterator_pointer<iterator>::type iterator_pointer;
|
||||
typedef typename boost::iterator_reference<iterator>::type iterator_reference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<iterator>::type iterator_category;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<iterator>::type iterator_difference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<iterator>::type iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<iterator>::type iterator_reference;
|
||||
|
||||
typedef typename boost::BOOST_ITERATOR_CATEGORY<local_iterator>::type local_iterator_category;
|
||||
typedef typename boost::iterator_difference<local_iterator>::type local_iterator_difference;
|
||||
typedef typename boost::iterator_pointer<local_iterator>::type local_iterator_pointer;
|
||||
typedef typename boost::iterator_reference<local_iterator>::type local_iterator_reference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<local_iterator>::type local_iterator_category;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<local_iterator>::type local_iterator_difference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<local_iterator>::type local_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<local_iterator>::type local_iterator_reference;
|
||||
|
||||
typedef typename boost::BOOST_ITERATOR_CATEGORY<const_iterator>::type const_iterator_category;
|
||||
typedef typename boost::iterator_difference<const_iterator>::type const_iterator_difference;
|
||||
typedef typename boost::iterator_pointer<const_iterator>::type const_iterator_pointer;
|
||||
typedef typename boost::iterator_reference<const_iterator>::type const_iterator_reference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<const_iterator>::type const_iterator_category;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<const_iterator>::type const_iterator_difference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_iterator>::type const_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<const_iterator>::type const_iterator_reference;
|
||||
|
||||
typedef typename boost::BOOST_ITERATOR_CATEGORY<const_local_iterator>::type const_local_iterator_category;
|
||||
typedef typename boost::iterator_difference<const_local_iterator>::type const_local_iterator_difference;
|
||||
typedef typename boost::iterator_pointer<const_local_iterator>::type const_local_iterator_pointer;
|
||||
typedef typename boost::iterator_reference<const_local_iterator>::type const_local_iterator_reference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<const_local_iterator>::type const_local_iterator_category;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<const_local_iterator>::type const_local_iterator_difference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_local_iterator>::type const_local_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<const_local_iterator>::type const_local_iterator_reference;
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<Key, key_type>));
|
||||
boost::function_requires<boost::CopyConstructibleConcept<key_type> >();
|
||||
@@ -237,8 +237,8 @@ void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq)
|
||||
X();
|
||||
X a4;
|
||||
|
||||
typename X::value_type* i = 0;
|
||||
typename X::value_type* j = 0;
|
||||
BOOST_DEDUCED_TYPENAME X::value_type* i = 0;
|
||||
BOOST_DEDUCED_TYPENAME X::value_type* j = 0;
|
||||
|
||||
X(i, j, 10, hf, eq);
|
||||
X a5(i, j, 10, hf, eq);
|
||||
|
||||
@@ -20,9 +20,9 @@ test::seed_t seed(356730);
|
||||
template <class T>
|
||||
void constructor_tests1(T* = 0)
|
||||
{
|
||||
typename T::hasher hf;
|
||||
typename T::key_equal eq;
|
||||
typename T::allocator_type al;
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq;
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al;
|
||||
|
||||
std::cerr<<"Construct 1\n";
|
||||
{
|
||||
@@ -139,15 +139,15 @@ void constructor_tests1(T* = 0)
|
||||
template <class T>
|
||||
void constructor_tests2(T* = 0)
|
||||
{
|
||||
typename T::hasher hf;
|
||||
typename T::hasher hf1(1);
|
||||
typename T::hasher hf2(2);
|
||||
typename T::key_equal eq;
|
||||
typename T::key_equal eq1(1);
|
||||
typename T::key_equal eq2(2);
|
||||
typename T::allocator_type al;
|
||||
typename T::allocator_type al1(1);
|
||||
typename T::allocator_type al2(2);
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf2(2);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq;
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq2(2);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al;
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
|
||||
|
||||
std::cerr<<"Construct 1\n";
|
||||
{
|
||||
|
||||
@@ -17,9 +17,9 @@ test::seed_t seed(9063);
|
||||
template <class T>
|
||||
void copy_construct_tests1(T* = 0)
|
||||
{
|
||||
typename T::hasher hf;
|
||||
typename T::key_equal eq;
|
||||
typename T::allocator_type al;
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq;
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al;
|
||||
|
||||
{
|
||||
T x;
|
||||
@@ -64,9 +64,9 @@ void copy_construct_tests2(T* ptr = 0)
|
||||
{
|
||||
copy_construct_tests1(ptr);
|
||||
|
||||
typename T::hasher hf(1);
|
||||
typename T::key_equal eq(1);
|
||||
typename T::allocator_type al(1);
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf(1);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq(1);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al(1);
|
||||
|
||||
{
|
||||
T x(10000, hf, eq, al);
|
||||
|
||||
@@ -24,7 +24,7 @@ void erase_tests1(Container* = 0)
|
||||
{
|
||||
test::random_values<Container> v(1000);
|
||||
Container x(v.begin(), v.end());
|
||||
for(typename test::random_values<Container>::iterator it = v.begin();
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<Container>::iterator it = v.begin();
|
||||
it != v.end(); ++it)
|
||||
{
|
||||
std::size_t count = x.count(test::get_key<Container>(*it));
|
||||
@@ -43,9 +43,9 @@ void erase_tests1(Container* = 0)
|
||||
std::size_t size = x.size();
|
||||
while(size > 0 && !x.empty())
|
||||
{
|
||||
typename Container::key_type key = test::get_key<Container>(*x.begin());
|
||||
BOOST_DEDUCED_TYPENAME Container::key_type key = test::get_key<Container>(*x.begin());
|
||||
std::size_t count = x.count(key);
|
||||
typename Container::iterator pos = x.erase(x.begin());
|
||||
BOOST_DEDUCED_TYPENAME Container::iterator pos = x.erase(x.begin());
|
||||
--size;
|
||||
BOOST_TEST(pos == x.begin());
|
||||
BOOST_TEST(x.count(key) == count - 1);
|
||||
@@ -63,7 +63,7 @@ void erase_tests1(Container* = 0)
|
||||
{
|
||||
using namespace std;
|
||||
int index = rand() % x.size();
|
||||
typename Container::const_iterator prev, pos, next;
|
||||
BOOST_DEDUCED_TYPENAME Container::const_iterator prev, pos, next;
|
||||
if(index == 0) {
|
||||
prev = pos = x.begin();
|
||||
}
|
||||
@@ -72,7 +72,7 @@ void erase_tests1(Container* = 0)
|
||||
pos = boost::next(prev);
|
||||
}
|
||||
next = boost::next(pos);
|
||||
typename Container::key_type key = test::get_key<Container>(*pos);
|
||||
BOOST_DEDUCED_TYPENAME Container::key_type key = test::get_key<Container>(*pos);
|
||||
std::size_t count = x.count(key);
|
||||
BOOST_TEST(next == x.erase(pos));
|
||||
--size;
|
||||
|
||||
@@ -16,7 +16,7 @@ test::seed_t seed(78937);
|
||||
template <class X>
|
||||
void find_tests1(X*)
|
||||
{
|
||||
typedef typename X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
|
||||
{
|
||||
test::random_values<X> v(500);
|
||||
@@ -25,12 +25,12 @@ void find_tests1(X*)
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
tracker.insert_range(v.begin(), v.end());
|
||||
|
||||
for(typename test::ordered<X>::const_iterator it1 =
|
||||
for(BOOST_DEDUCED_TYPENAME test::ordered<X>::const_iterator it1 =
|
||||
tracker.begin(); it1 != tracker.end(); ++it1)
|
||||
{
|
||||
typename X::key_type key = test::get_key<X>(*it1);
|
||||
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it1);
|
||||
iterator pos = x.find(key);
|
||||
typename X::const_iterator const_pos = x_const.find(key);
|
||||
BOOST_DEDUCED_TYPENAME X::const_iterator const_pos = x_const.find(key);
|
||||
BOOST_TEST(pos != x.end() &&
|
||||
x.key_eq()(key, test::get_key<X>(*pos)));
|
||||
BOOST_TEST(const_pos != x_const.end() &&
|
||||
@@ -40,17 +40,17 @@ void find_tests1(X*)
|
||||
|
||||
test::compare_pairs(x.equal_range(key),
|
||||
tracker.equal_range(key),
|
||||
(typename test::non_const_value_type<X>::type*) 0);
|
||||
(BOOST_DEDUCED_TYPENAME test::non_const_value_type<X>::type*) 0);
|
||||
test::compare_pairs(x_const.equal_range(key),
|
||||
tracker.equal_range(key),
|
||||
(typename test::non_const_value_type<X>::type*) 0);
|
||||
(BOOST_DEDUCED_TYPENAME test::non_const_value_type<X>::type*) 0);
|
||||
}
|
||||
|
||||
test::random_values<X> v2(500);
|
||||
for(typename test::random_values<X>::const_iterator it2 =
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator it2 =
|
||||
v2.begin(); it2 != v2.end(); ++it2)
|
||||
{
|
||||
typename X::key_type key = test::get_key<X>(*it2);
|
||||
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it2);
|
||||
if(tracker.find(test::get_key<X>(key)) == tracker.end())
|
||||
{
|
||||
BOOST_TEST(x.find(key) == x.end());
|
||||
@@ -66,10 +66,10 @@ void find_tests1(X*)
|
||||
X x;
|
||||
|
||||
test::random_values<X> v2(5);
|
||||
for(typename test::random_values<X>::const_iterator it3 =
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator it3 =
|
||||
v2.begin(); it3 != v2.end(); ++it3)
|
||||
{
|
||||
typename X::key_type key = test::get_key<X>(*it3);
|
||||
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it3);
|
||||
BOOST_TEST(x.find(key) == x.end());
|
||||
BOOST_TEST(x.count(key) == 0);
|
||||
std::pair<iterator, iterator> range = x.equal_range(key);
|
||||
|
||||
@@ -21,9 +21,8 @@ test::seed_t seed(243432);
|
||||
template <class X>
|
||||
void unique_insert_tests1(X* = 0)
|
||||
{
|
||||
typedef typename X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef test::ordered<X> ordered;
|
||||
typedef typename test::ordered<X>::iterator ordered_iterator;
|
||||
|
||||
std::cerr<<"insert(value) tests for containers with unique keys.\n";
|
||||
|
||||
@@ -31,14 +30,16 @@ void unique_insert_tests1(X* = 0)
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000);
|
||||
for(typename test::random_values<X>::iterator it = v.begin();
|
||||
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it)
|
||||
{
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
std::pair<iterator, bool> r1 = x.insert(*it);
|
||||
std::pair<ordered_iterator, bool> r2 = tracker.insert(*it);
|
||||
std::pair<BOOST_DEDUCED_TYPENAME ordered::iterator, bool> r2 = tracker.insert(*it);
|
||||
|
||||
BOOST_TEST(r1.second == r2.second);
|
||||
BOOST_TEST(*r1.first == *r2.first);
|
||||
@@ -61,14 +62,14 @@ void equivalent_insert_tests1(X* = 0)
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000);
|
||||
for(typename test::random_values<X>::iterator it = v.begin();
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it)
|
||||
{
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
typename X::iterator r1 = x.insert(*it);
|
||||
typename test::ordered<X>::iterator r2 = tracker.insert(*it);
|
||||
BOOST_DEDUCED_TYPENAME X::iterator r1 = x.insert(*it);
|
||||
BOOST_DEDUCED_TYPENAME test::ordered<X>::iterator r2 = tracker.insert(*it);
|
||||
|
||||
BOOST_TEST(*r1 == *r2);
|
||||
|
||||
@@ -84,10 +85,10 @@ void equivalent_insert_tests1(X* = 0)
|
||||
template <class X>
|
||||
void insert_tests2(X* = 0)
|
||||
{
|
||||
typedef typename test::ordered<X> tracker_type;
|
||||
typedef typename X::iterator iterator;
|
||||
typedef typename X::const_iterator const_iterator;
|
||||
typedef typename tracker_type::iterator tracker_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME test::ordered<X> tracker_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME tracker_type::iterator tracker_iterator;
|
||||
|
||||
std::cerr<<"insert(begin(), value) tests.\n";
|
||||
|
||||
@@ -96,10 +97,10 @@ void insert_tests2(X* = 0)
|
||||
tracker_type tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000);
|
||||
for(typename test::random_values<X>::iterator it = v.begin();
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it)
|
||||
{
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
iterator r1 = x.insert(x.begin(), *it);
|
||||
@@ -122,10 +123,10 @@ void insert_tests2(X* = 0)
|
||||
tracker_type tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(100);
|
||||
for(typename test::random_values<X>::iterator it = v.begin();
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it)
|
||||
{
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
const_iterator r1 = x.insert(x_const.end(), *it);
|
||||
@@ -148,10 +149,10 @@ void insert_tests2(X* = 0)
|
||||
tracker_type tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000);
|
||||
for(typename test::random_values<X>::iterator it = v.begin();
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it)
|
||||
{
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
pos = x.insert(pos, *it);
|
||||
@@ -173,10 +174,10 @@ void insert_tests2(X* = 0)
|
||||
tracker_type tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000);
|
||||
for(typename test::random_values<X>::iterator it = v.begin();
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it)
|
||||
{
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
x.insert(it, boost::next(it));
|
||||
@@ -224,10 +225,10 @@ void map_tests(X* = 0)
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000);
|
||||
for(typename test::random_values<X>::iterator it = v.begin();
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it)
|
||||
{
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
x[it->first] = it->second;
|
||||
@@ -296,6 +297,5 @@ int main()
|
||||
associative_insert_range_test((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
associative_insert_range_test((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
associative_insert_range_test((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -39,10 +39,10 @@ void insert_test(X*, float mlf)
|
||||
|
||||
test::random_values<X> values(1000);
|
||||
|
||||
for(typename test::random_values<X>::const_iterator
|
||||
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator
|
||||
it = values.begin(), end = values.end(); it != end; ++it)
|
||||
{
|
||||
typename X::size_type old_size = x.size(),
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_size = x.size(),
|
||||
old_bucket_count = x.bucket_count();
|
||||
x.insert(*it);
|
||||
if(old_size + 1 < b * old_bucket_count)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
test::seed_t seed(2974);
|
||||
|
||||
template <class X>
|
||||
bool postcondition(X const& x, typename X::size_type n)
|
||||
bool postcondition(X const& x, BOOST_DEDUCED_TYPENAME X::size_type n)
|
||||
{
|
||||
return x.bucket_count() > x.size() / x.max_load_factor() && x.bucket_count() >= n;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ void simple_test(X const& a)
|
||||
BOOST_TEST(b.empty());
|
||||
BOOST_TEST(equivalent(c));
|
||||
b.swap(c);
|
||||
BOOST_TEST(b.empty());
|
||||
BOOST_TEST(equivalent(c));
|
||||
BOOST_TEST(c.empty());
|
||||
BOOST_TEST(equivalent(b));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -68,7 +68,7 @@ void simple_test(X const& a)
|
||||
|
||||
{
|
||||
BOOST_TEST(a.size() ==
|
||||
(typename X::size_type) std::distance(a.begin(), a.end()));
|
||||
(BOOST_DEDUCED_TYPENAME X::size_type) std::distance(a.begin(), a.end()));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -84,20 +84,43 @@ void simple_test(X const& a)
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
srand(14878);
|
||||
|
||||
std::cout<<"Test unordered_set.\n";
|
||||
boost::unordered_set<int> set;
|
||||
simple_test(set);
|
||||
|
||||
set.insert(1); set.insert(2); set.insert(1456);
|
||||
simple_test(set);
|
||||
|
||||
std::cout<<"Test unordered_multiset.\n";
|
||||
boost::unordered_multiset<int> multiset;
|
||||
simple_test(multiset);
|
||||
|
||||
for(int i1 = 0; i1 < 1000; ++i1) {
|
||||
int count = rand() % 10, index = rand();
|
||||
for(int j = 0; j < count; ++j)
|
||||
multiset.insert(index);
|
||||
}
|
||||
simple_test(multiset);
|
||||
|
||||
std::cout<<"Test unordered_map.\n";
|
||||
boost::unordered_map<int, int> map;
|
||||
|
||||
for(int i2 = 0; i2 < 1000; ++i2) {
|
||||
map.insert(std::pair<const int, int>(rand(), rand()));
|
||||
}
|
||||
simple_test(map);
|
||||
|
||||
std::cout<<"Test unordered_multimap.\n";
|
||||
boost::unordered_multimap<int, int> multimap;
|
||||
|
||||
for(int i3 = 0; i3 < 1000; ++i3) {
|
||||
int count = rand() % 10, index = rand();
|
||||
for(int j = 0; j < count; ++j)
|
||||
multimap.insert(std::pair<const int, int>(index, rand()));
|
||||
}
|
||||
simple_test(multimap);
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -61,9 +61,9 @@ void swap_tests2(X* ptr = 0)
|
||||
{
|
||||
swap_tests1(ptr);
|
||||
|
||||
typedef typename X::hasher hasher;
|
||||
typedef typename X::key_equal key_equal;
|
||||
typedef typename X::allocator_type allocator_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::hasher hasher;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_equal key_equal;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
|
||||
|
||||
{
|
||||
X x(0, hasher(1), key_equal(1));
|
||||
|
||||
@@ -7,51 +7,52 @@
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
struct count_copies
|
||||
{
|
||||
static int count;
|
||||
count_copies() { ++count; }
|
||||
count_copies(count_copies const&) { ++count; }
|
||||
private:
|
||||
count_copies& operator=(count_copies const&);
|
||||
};
|
||||
namespace test {
|
||||
struct count_copies
|
||||
{
|
||||
static int count;
|
||||
count_copies() { ++count; }
|
||||
count_copies(count_copies const&) { ++count; }
|
||||
private:
|
||||
count_copies& operator=(count_copies const&);
|
||||
};
|
||||
|
||||
bool operator==(test::count_copies const&, test::count_copies const&) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
||||
namespace boost {
|
||||
#else
|
||||
namespace test {
|
||||
#endif
|
||||
|
||||
std::size_t hash_value(count_copies const&) {
|
||||
return 0;
|
||||
std::size_t hash_value(test::count_copies const&) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
||||
namespace test {
|
||||
int count_copies::count;
|
||||
|
||||
template <class T>
|
||||
void unnecessary_copy_test(T*)
|
||||
{
|
||||
count_copies::count = 0;
|
||||
T x;
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
BOOST_TEST(count_copies::count == 1);
|
||||
x.insert(a);
|
||||
BOOST_TEST(count_copies::count == 2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool operator==(count_copies const&, count_copies const&) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int count_copies::count;
|
||||
|
||||
template <class T>
|
||||
void unnecessary_copy_test(T*)
|
||||
{
|
||||
count_copies::count = 0;
|
||||
T x;
|
||||
typename T::value_type a;
|
||||
BOOST_TEST(count_copies::count == 1);
|
||||
x.insert(a);
|
||||
BOOST_TEST(count_copies::count == 2);
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
unnecessary_copy_test((boost::unordered_set<count_copies>*) 0);
|
||||
unnecessary_copy_test((boost::unordered_multiset<count_copies>*) 0);
|
||||
unnecessary_copy_test((boost::unordered_map<int, count_copies>*) 0);
|
||||
unnecessary_copy_test((boost::unordered_multimap<int, count_copies>*) 0);
|
||||
test::unnecessary_copy_test((boost::unordered_set<test::count_copies>*) 0);
|
||||
test::unnecessary_copy_test((boost::unordered_multiset<test::count_copies>*) 0);
|
||||
test::unnecessary_copy_test((boost::unordered_map<int, test::count_copies>*) 0);
|
||||
test::unnecessary_copy_test((boost::unordered_multimap<int, test::count_copies>*) 0);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user