mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-31 20:04:29 +02:00
Improved support for Visual C++.
[SVN r2985]
This commit is contained in:
@@ -51,7 +51,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||||
#define BOOST_HASH_MSVC_RESET_PTR(x) unordered_detail::reset(node_pointer_)
|
#define BOOST_HASH_MSVC_RESET_PTR(x) unordered_detail::reset(x)
|
||||||
#else
|
#else
|
||||||
#define BOOST_HASH_MSVC_RESET_PTR(x)
|
#define BOOST_HASH_MSVC_RESET_PTR(x)
|
||||||
#endif
|
#endif
|
||||||
@@ -61,7 +61,7 @@ namespace boost {
|
|||||||
template <class T> struct type_wrapper {};
|
template <class T> struct type_wrapper {};
|
||||||
|
|
||||||
const static std::size_t default_initial_bucket_count = 50;
|
const static std::size_t default_initial_bucket_count = 50;
|
||||||
const static float minimum_max_load_factor = 1e-3;
|
const static float minimum_max_load_factor = 1e-3f;
|
||||||
inline std::size_t next_prime(std::size_t n);
|
inline std::size_t next_prime(std::size_t n);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@@ -1811,7 +1811,7 @@ namespace boost {
|
|||||||
// Create the node before rehashing in case it throws an
|
// Create the node before rehashing in case it throws an
|
||||||
// exception (need strong safety in such a case).
|
// exception (need strong safety in such a case).
|
||||||
node_constructor a(this->node_alloc_, this->bucket_alloc_);
|
node_constructor a(this->node_alloc_, this->bucket_alloc_);
|
||||||
value_type const& v(*i);
|
value_type const& v = *i;
|
||||||
a.construct(v);
|
a.construct(v);
|
||||||
|
|
||||||
// reserve has basic exception safety if the hash function
|
// reserve has basic exception safety if the hash function
|
||||||
|
@@ -19,4 +19,6 @@ int main()
|
|||||||
boost::unordered_multimap<int, int> x4;
|
boost::unordered_multimap<int, int> x4;
|
||||||
|
|
||||||
foo(x1, x2, x3, x4);
|
foo(x1, x2, x3, x4);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ void simple_test(X const& a)
|
|||||||
|
|
||||||
{
|
{
|
||||||
X u;
|
X u;
|
||||||
X& r(u);
|
X& r = u;
|
||||||
// TODO: I can't actually see a requirement for that assignment
|
// TODO: I can't actually see a requirement for that assignment
|
||||||
// returns a reference to itself (just that it returns a reference).
|
// returns a reference to itself (just that it returns a reference).
|
||||||
BOOST_TEST(&(r = r) == &r);
|
BOOST_TEST(&(r = r) == &r);
|
||||||
|
@@ -14,32 +14,35 @@
|
|||||||
|
|
||||||
namespace test
|
namespace test
|
||||||
{
|
{
|
||||||
|
struct base_type {} base;
|
||||||
|
struct derived_type : base_type {} derived;
|
||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
bool equivalent_impl(T1 const& x, T2 const& y) {
|
bool equivalent_impl(T1 const& x, T2 const& y, base_type) {
|
||||||
return x == y;
|
return x == y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
bool equivalent_impl(boost::hash<T> const&, boost::hash<T> const&) {
|
bool equivalent_impl(boost::hash<T> const&, boost::hash<T> const&, derived_type) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
bool equivalent_impl(std::equal_to<T> const&, std::equal_to<T> const&) {
|
bool equivalent_impl(std::equal_to<T> const&, std::equal_to<T> const&, derived_type) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T1, class T2, class T3, class T4>
|
template <class T1, class T2, class T3, class T4>
|
||||||
bool equivalent_impl(std::pair<T1, T2> const& x1,
|
bool equivalent_impl(std::pair<T1, T2> const& x1,
|
||||||
std::pair<T3, T4> const& x2) {
|
std::pair<T3, T4> const& x2, derived_type) {
|
||||||
return equivalent_impl(x1.first, x2.first) &&
|
return equivalent_impl(x1.first, x2.first, derived) &&
|
||||||
equivalent_impl(x1.second, x2.second);
|
equivalent_impl(x1.second, x2.second, derived);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct equivalent_type {
|
struct equivalent_type {
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
bool operator()(T1 const& x, T2 const& y) {
|
bool operator()(T1 const& x, T2 const& y) {
|
||||||
return equivalent_impl(x, y);
|
return equivalent_impl(x, y, derived);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,8 +77,8 @@ namespace test
|
|||||||
bool operator()(Container const& x) const
|
bool operator()(Container const& x) const
|
||||||
{
|
{
|
||||||
if(!((size_ == x.size()) &&
|
if(!((size_ == x.size()) &&
|
||||||
(test::equivalent_impl(hasher_, x.hash_function())) &&
|
(test::equivalent(hasher_, x.hash_function())) &&
|
||||||
(test::equivalent_impl(key_equal_, x.key_eq())) &&
|
(test::equivalent(key_equal_, x.key_eq())) &&
|
||||||
(max_load_factor_ == x.max_load_factor()) &&
|
(max_load_factor_ == x.max_load_factor()) &&
|
||||||
(values_.size() == x.size()))) return false;
|
(values_.size() == x.size()))) return false;
|
||||||
|
|
||||||
|
@@ -11,18 +11,24 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#if 0
|
||||||
#include <boost/random/inversive_congruential.hpp>
|
#include <boost/random/inversive_congruential.hpp>
|
||||||
#include <boost/random/uniform_int.hpp>
|
#include <boost/random/uniform_int.hpp>
|
||||||
#include <boost/random/lagged_fibonacci.hpp>
|
#include <boost/random/lagged_fibonacci.hpp>
|
||||||
#include <boost/random/uniform_real.hpp>
|
#include <boost/random/uniform_real.hpp>
|
||||||
#include <boost/random/variate_generator.hpp>
|
#include <boost/random/variate_generator.hpp>
|
||||||
|
#else
|
||||||
|
#include <cstdlib>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "./fwd.hpp"
|
#include "./fwd.hpp"
|
||||||
|
|
||||||
namespace test
|
namespace test
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
typedef boost::hellekalek1995 integer_generator_type;
|
typedef boost::hellekalek1995 integer_generator_type;
|
||||||
typedef boost::lagged_fibonacci607 real_generator_type;
|
typedef boost::lagged_fibonacci607 real_generator_type;
|
||||||
|
#endif
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct generator
|
struct generator
|
||||||
@@ -36,20 +42,30 @@ namespace test
|
|||||||
|
|
||||||
inline int generate(int const*)
|
inline int generate(int const*)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
integer_generator_type gen;
|
integer_generator_type gen;
|
||||||
boost::uniform_int<> dist(0, 1000);
|
boost::uniform_int<> dist(0, 1000);
|
||||||
static boost::variate_generator<integer_generator_type, boost::uniform_int<> >
|
static boost::variate_generator<integer_generator_type, boost::uniform_int<> >
|
||||||
vg(gen, dist);
|
vg(gen, dist);
|
||||||
return vg();
|
return vg();
|
||||||
|
#else
|
||||||
|
using namespace std;
|
||||||
|
return rand();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline char generate(char const*)
|
inline char generate(char const*)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
integer_generator_type gen;
|
integer_generator_type gen;
|
||||||
boost::uniform_int<char> dist(32, 128);
|
boost::uniform_int<char> dist(32, 127);
|
||||||
static boost::variate_generator<integer_generator_type, boost::uniform_int<char> >
|
static boost::variate_generator<integer_generator_type, boost::uniform_int<char> >
|
||||||
vg(gen, dist);
|
vg(gen, dist);
|
||||||
return vg();
|
return vg();
|
||||||
|
#else
|
||||||
|
using namespace std;
|
||||||
|
return rand() % (128 - 32) + 32;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string generate(std::string const*)
|
inline std::string generate(std::string const*)
|
||||||
@@ -74,11 +90,16 @@ namespace test
|
|||||||
|
|
||||||
float generate(float const*)
|
float generate(float const*)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
real_generator_type gen;
|
real_generator_type gen;
|
||||||
boost::uniform_real<float> dist;
|
boost::uniform_real<float> dist;
|
||||||
static boost::variate_generator<real_generator_type, boost::uniform_real<float> >
|
static boost::variate_generator<real_generator_type, boost::uniform_real<float> >
|
||||||
vg(gen, dist);
|
vg(gen, dist);
|
||||||
return vg();
|
return vg();
|
||||||
|
#else
|
||||||
|
using namespace std;
|
||||||
|
return (double) rand() / (double) RAND_MAX;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T1, class T2> std::pair<T1, T2> generate(
|
template <class T1, class T2> std::pair<T1, T2> generate(
|
||||||
|
@@ -9,21 +9,32 @@
|
|||||||
namespace test
|
namespace test
|
||||||
{
|
{
|
||||||
template <class Container>
|
template <class Container>
|
||||||
inline typename Container::key_type get_key(typename Container::key_type const& x)
|
struct get_key_impl
|
||||||
{
|
{
|
||||||
return x;
|
typedef typename Container::key_type key_type;
|
||||||
}
|
|
||||||
|
|
||||||
template <class Container, class T>
|
static key_type get_key(key_type const& x)
|
||||||
inline typename Container::key_type get_key(std::pair<typename Container::key_type const, T> const& x)
|
{
|
||||||
{
|
return x;
|
||||||
return x.first;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
static key_type get_key(std::pair<key_type, T> const& x, char = 0)
|
||||||
|
{
|
||||||
|
return x.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
static key_type get_key(std::pair<key_type const, T> const& x, unsigned char = 0)
|
||||||
|
{
|
||||||
|
return x.first;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <class Container, class T>
|
template <class Container, class T>
|
||||||
inline typename Container::key_type get_key(std::pair<typename Container::key_type, T> const& x)
|
inline typename Container::key_type get_key(T const& x)
|
||||||
{
|
{
|
||||||
return x.first;
|
return get_key_impl<Container>::get_key(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#define BOOST_UNORDERED_TEST_HELPERS_INVARIANT_HEADER
|
#define BOOST_UNORDERED_TEST_HELPERS_INVARIANT_HEADER
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <cmath>
|
||||||
#include "./metafunctions.hpp"
|
#include "./metafunctions.hpp"
|
||||||
#include "./helpers.hpp"
|
#include "./helpers.hpp"
|
||||||
|
|
||||||
@@ -80,7 +81,9 @@ namespace test
|
|||||||
// Finally, check that size matches up.
|
// Finally, check that size matches up.
|
||||||
if(x1.size() != size)
|
if(x1.size() != size)
|
||||||
BOOST_ERROR("x1.size() doesn't match actual size.");
|
BOOST_ERROR("x1.size() doesn't match actual size.");
|
||||||
if(static_cast<float>(size) / static_cast<float>(x1.bucket_count()) != x1.load_factor())
|
float load_factor = static_cast<float>(size) / static_cast<float>(x1.bucket_count());
|
||||||
|
using namespace std;
|
||||||
|
if(fabs(x1.load_factor() - load_factor) > x1.load_factor() / 64)
|
||||||
BOOST_ERROR("x1.load_factor() doesn't match actual load_factor.");
|
BOOST_ERROR("x1.load_factor() doesn't match actual load_factor.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/mpl/if.hpp>
|
||||||
#include <boost/mpl/eval_if.hpp>
|
#include <boost/mpl/eval_if.hpp>
|
||||||
|
#include <boost/mpl/identity.hpp>
|
||||||
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include "../objects/fwd.hpp"
|
#include "../objects/fwd.hpp"
|
||||||
#include "./metafunctions.hpp"
|
#include "./metafunctions.hpp"
|
||||||
#include "./helpers.hpp"
|
#include "./helpers.hpp"
|
||||||
@@ -24,15 +26,19 @@
|
|||||||
namespace test
|
namespace test
|
||||||
{
|
{
|
||||||
template <class X>
|
template <class X>
|
||||||
struct equals_to_compare
|
struct equals_to_compare2
|
||||||
|
: public boost::mpl::identity<std::less<typename X::first_argument_type> >
|
||||||
{
|
{
|
||||||
typedef std::less<typename X::first_argument_type> type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <class X>
|
||||||
struct equals_to_compare<test::equal_to>
|
struct equals_to_compare
|
||||||
|
: public boost::mpl::eval_if<
|
||||||
|
boost::is_same<X, test::equal_to>,
|
||||||
|
boost::mpl::identity<test::less>,
|
||||||
|
equals_to_compare2<X>
|
||||||
|
>
|
||||||
{
|
{
|
||||||
typedef test::less type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class X1, class X2>
|
template <class X1, class X2>
|
||||||
@@ -121,13 +127,22 @@ namespace test
|
|||||||
(typename non_const_value_type<X>::type*) 0
|
(typename non_const_value_type<X>::type*) 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class It>
|
||||||
|
void insert_range(It begin, It end) {
|
||||||
|
while(begin != end) {
|
||||||
|
this->insert(*begin);
|
||||||
|
++begin;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Equals>
|
template <class Equals>
|
||||||
typename equals_to_compare<Equals>::type create_compare(
|
typename equals_to_compare<Equals>::type create_compare(
|
||||||
Equals equals)
|
Equals const& equals)
|
||||||
{
|
{
|
||||||
return typename equals_to_compare<Equals>::type();
|
typename equals_to_compare<Equals>::type x;
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
@@ -140,7 +155,7 @@ namespace test
|
|||||||
void check_container(X1 const& container, X2 const& values)
|
void check_container(X1 const& container, X2 const& values)
|
||||||
{
|
{
|
||||||
ordered<X1> tracker = create_ordered(container);
|
ordered<X1> tracker = create_ordered(container);
|
||||||
tracker.insert(values.begin(), values.end());
|
tracker.insert_range(values.begin(), values.end());
|
||||||
tracker.compare(container);
|
tracker.compare(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ namespace test
|
|||||||
|
|
||||||
|
|
||||||
friend object generate(object const*) {
|
friend object generate(object const*) {
|
||||||
int* x;
|
int* x = 0;
|
||||||
return object(generate(x), generate(x));
|
return object(generate(x), generate(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,10 +339,7 @@ namespace test
|
|||||||
return (std::numeric_limits<size_type>::max)();
|
return (std::numeric_limits<size_type>::max)();
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(allocator const& x, allocator const& y)
|
friend bool operator==(allocator const& x, allocator const& y);
|
||||||
{
|
|
||||||
return x.tag_ == y.tag_;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend bool operator!=(allocator const& x, allocator const& y)
|
friend bool operator!=(allocator const& x, allocator const& y)
|
||||||
{
|
{
|
||||||
@@ -351,4 +348,17 @@ namespace test
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
||||||
|
namespace test
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
template <class T>
|
||||||
|
bool operator==(test::allocator<T> const& x, test::allocator<T> const& y)
|
||||||
|
{
|
||||||
|
return x.tag_ == y.tag_;
|
||||||
|
}
|
||||||
|
#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -34,7 +34,7 @@ void assign_tests1(T* = 0)
|
|||||||
T x(v.begin(), v.end());
|
T x(v.begin(), v.end());
|
||||||
|
|
||||||
test::ordered<T> tracker = test::create_ordered(x);
|
test::ordered<T> tracker = test::create_ordered(x);
|
||||||
tracker.insert(v.begin(), v.end());
|
tracker.insert_range(v.begin(), v.end());
|
||||||
|
|
||||||
x = x;
|
x = x;
|
||||||
tracker.compare(x);
|
tracker.compare(x);
|
||||||
@@ -68,7 +68,7 @@ void assign_tests2(T* = 0)
|
|||||||
x2 = x1;
|
x2 = x1;
|
||||||
BOOST_TEST(test::equivalent(x2.hash_function(), hf1));
|
BOOST_TEST(test::equivalent(x2.hash_function(), hf1));
|
||||||
BOOST_TEST(test::equivalent(x2.key_eq(), eq1));
|
BOOST_TEST(test::equivalent(x2.key_eq(), eq1));
|
||||||
check_container(x2, v);
|
test::check_container(x2, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr<<"assign_tests2.2\n";
|
std::cerr<<"assign_tests2.2\n";
|
||||||
@@ -81,7 +81,7 @@ void assign_tests2(T* = 0)
|
|||||||
BOOST_TEST(test::equivalent(x2.hash_function(), hf1));
|
BOOST_TEST(test::equivalent(x2.hash_function(), hf1));
|
||||||
BOOST_TEST(test::equivalent(x2.key_eq(), eq1));
|
BOOST_TEST(test::equivalent(x2.key_eq(), eq1));
|
||||||
BOOST_TEST(test::equivalent(x2.get_allocator(), al2));
|
BOOST_TEST(test::equivalent(x2.get_allocator(), al2));
|
||||||
check_container(x2, v1);
|
test::check_container(x2, v1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@ void bucket_tests(X* = 0)
|
|||||||
|
|
||||||
for(size_type i = 0; i < x.bucket_count(); ++i) {
|
for(size_type i = 0; i < x.bucket_count(); ++i) {
|
||||||
BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x.begin(i), x.end(i)));
|
BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x.begin(i), x.end(i)));
|
||||||
X const& x_ref(x);
|
X const& x_ref = x;
|
||||||
BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x_ref.begin(i), x_ref.end(i)));
|
BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x_ref.begin(i), x_ref.end(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -106,7 +106,7 @@ void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq)
|
|||||||
X(10);
|
X(10);
|
||||||
X a3(10);
|
X a3(10);
|
||||||
X();
|
X();
|
||||||
X a4();
|
X a4;
|
||||||
|
|
||||||
typename X::value_type* i = 0;
|
typename X::value_type* i = 0;
|
||||||
typename X::value_type* j = 0;
|
typename X::value_type* j = 0;
|
||||||
|
@@ -67,7 +67,7 @@ void constructor_tests1(T* = 0)
|
|||||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||||
check_container(x, v);
|
test::check_container(x, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr<<"Construct 6\n";
|
std::cerr<<"Construct 6\n";
|
||||||
@@ -78,7 +78,7 @@ void constructor_tests1(T* = 0)
|
|||||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||||
check_container(x, v);
|
test::check_container(x, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr<<"Construct 7\n";
|
std::cerr<<"Construct 7\n";
|
||||||
@@ -89,7 +89,7 @@ void constructor_tests1(T* = 0)
|
|||||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||||
check_container(x, v);
|
test::check_container(x, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr<<"Construct 8\n";
|
std::cerr<<"Construct 8\n";
|
||||||
@@ -99,7 +99,7 @@ void constructor_tests1(T* = 0)
|
|||||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||||
check_container(x, v);
|
test::check_container(x, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr<<"Construct 9\n";
|
std::cerr<<"Construct 9\n";
|
||||||
@@ -120,7 +120,7 @@ void constructor_tests1(T* = 0)
|
|||||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||||
check_container(x, v);
|
test::check_container(x, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ void constructor_tests2(T* = 0)
|
|||||||
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
|
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
|
||||||
BOOST_TEST(test::equivalent(x.key_eq(), eq1));
|
BOOST_TEST(test::equivalent(x.key_eq(), eq1));
|
||||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||||
check_container(x, v);
|
test::check_container(x, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr<<"Construct 4\n";
|
std::cerr<<"Construct 4\n";
|
||||||
@@ -174,7 +174,7 @@ void constructor_tests2(T* = 0)
|
|||||||
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
|
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
|
||||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||||
check_container(x, v);
|
test::check_container(x, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,8 +183,8 @@ void constructor_tests2(T* = 0)
|
|||||||
test::random_values<T> v(100);
|
test::random_values<T> v(100);
|
||||||
T x(v.begin(), v.end(), 0, hf, eq, al1);
|
T x(v.begin(), v.end(), 0, hf, eq, al1);
|
||||||
T y(x.begin(), x.end(), 0, hf1, eq1, al2);
|
T y(x.begin(), x.end(), 0, hf1, eq1, al2);
|
||||||
check_container(x, v);
|
test::check_container(x, v);
|
||||||
check_container(y, x);
|
test::check_container(y, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr<<"Construct 6\n";
|
std::cerr<<"Construct 6\n";
|
||||||
@@ -192,8 +192,8 @@ void constructor_tests2(T* = 0)
|
|||||||
test::random_values<T> v(100);
|
test::random_values<T> v(100);
|
||||||
T x(v.begin(), v.end(), 0, hf1, eq1);
|
T x(v.begin(), v.end(), 0, hf1, eq1);
|
||||||
T y(x.begin(), x.end(), 0, hf, eq);
|
T y(x.begin(), x.end(), 0, hf, eq);
|
||||||
check_container(x, v);
|
test::check_container(x, v);
|
||||||
check_container(y, x);
|
test::check_container(y, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr<<"Construct 7\n";
|
std::cerr<<"Construct 7\n";
|
||||||
@@ -201,8 +201,8 @@ void constructor_tests2(T* = 0)
|
|||||||
test::random_values<T> v(100);
|
test::random_values<T> v(100);
|
||||||
T x(v.begin(), v.end(), 0, hf1, eq1);
|
T x(v.begin(), v.end(), 0, hf1, eq1);
|
||||||
T y(x.begin(), x.end(), 0, hf2, eq2);
|
T y(x.begin(), x.end(), 0, hf2, eq2);
|
||||||
check_container(x, v);
|
test::check_container(x, v);
|
||||||
check_container(y, x);
|
test::check_container(y, x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,18 +14,20 @@
|
|||||||
template <class X>
|
template <class X>
|
||||||
void find_tests1(X*)
|
void find_tests1(X*)
|
||||||
{
|
{
|
||||||
|
typedef typename X::iterator iterator;
|
||||||
|
|
||||||
{
|
{
|
||||||
test::random_values<X> v(500);
|
test::random_values<X> v(500);
|
||||||
X x(v.begin(), v.end());
|
X x(v.begin(), v.end());
|
||||||
X const& x_const = x;
|
X const& x_const = x;
|
||||||
test::ordered<X> tracker = test::create_ordered(x);
|
test::ordered<X> tracker = test::create_ordered(x);
|
||||||
tracker.insert(v.begin(), v.end());
|
tracker.insert_range(v.begin(), v.end());
|
||||||
|
|
||||||
for(typename test::ordered<X>::const_iterator it =
|
for(typename test::ordered<X>::const_iterator it1 =
|
||||||
tracker.begin(); it != tracker.end(); ++it)
|
tracker.begin(); it1 != tracker.end(); ++it1)
|
||||||
{
|
{
|
||||||
typename X::key_type key = test::get_key<X>(*it);
|
typename X::key_type key = test::get_key<X>(*it1);
|
||||||
typename X::iterator pos = x.find(key);
|
iterator pos = x.find(key);
|
||||||
typename X::const_iterator const_pos = x_const.find(key);
|
typename X::const_iterator const_pos = x_const.find(key);
|
||||||
BOOST_TEST(pos != x.end() &&
|
BOOST_TEST(pos != x.end() &&
|
||||||
x.key_eq()(key, test::get_key<X>(*pos)));
|
x.key_eq()(key, test::get_key<X>(*pos)));
|
||||||
@@ -43,17 +45,16 @@ void find_tests1(X*)
|
|||||||
}
|
}
|
||||||
|
|
||||||
test::random_values<X> v2(500);
|
test::random_values<X> v2(500);
|
||||||
for(typename test::random_values<X>::const_iterator it =
|
for(typename test::random_values<X>::const_iterator it2 =
|
||||||
v2.begin(); it != v2.end(); ++it)
|
v2.begin(); it2 != v2.end(); ++it2)
|
||||||
{
|
{
|
||||||
typename X::key_type key = test::get_key<X>(*it);
|
typename X::key_type key = test::get_key<X>(*it2);
|
||||||
if(tracker.find(test::get_key<X>(key)) == tracker.end())
|
if(tracker.find(test::get_key<X>(key)) == tracker.end())
|
||||||
{
|
{
|
||||||
BOOST_TEST(x.find(key) == x.end());
|
BOOST_TEST(x.find(key) == x.end());
|
||||||
BOOST_TEST(x_const.find(key) == x_const.end());
|
BOOST_TEST(x_const.find(key) == x_const.end());
|
||||||
BOOST_TEST(x.count(key) == 0);
|
BOOST_TEST(x.count(key) == 0);
|
||||||
std::pair<typename X::iterator,
|
std::pair<iterator, iterator> range = x.equal_range(key);
|
||||||
typename X::iterator> range = x.equal_range(key);
|
|
||||||
BOOST_TEST(range.first == range.second);
|
BOOST_TEST(range.first == range.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,14 +64,13 @@ void find_tests1(X*)
|
|||||||
X x;
|
X x;
|
||||||
|
|
||||||
test::random_values<X> v2(5);
|
test::random_values<X> v2(5);
|
||||||
for(typename test::random_values<X>::const_iterator it =
|
for(typename test::random_values<X>::const_iterator it3 =
|
||||||
v2.begin(); it != v2.end(); ++it)
|
v2.begin(); it3 != v2.end(); ++it3)
|
||||||
{
|
{
|
||||||
typename X::key_type key = test::get_key<X>(*it);
|
typename X::key_type key = test::get_key<X>(*it3);
|
||||||
BOOST_TEST(x.find(key) == x.end());
|
BOOST_TEST(x.find(key) == x.end());
|
||||||
BOOST_TEST(x.count(key) == 0);
|
BOOST_TEST(x.count(key) == 0);
|
||||||
std::pair<typename X::iterator,
|
std::pair<iterator, iterator> range = x.equal_range(key);
|
||||||
typename X::iterator> range = x.equal_range(key);
|
|
||||||
BOOST_TEST(range.first == range.second);
|
BOOST_TEST(range.first == range.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,4 +87,6 @@ int main()
|
|||||||
find_tests1((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
find_tests1((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||||
find_tests1((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
find_tests1((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||||
find_tests1((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
find_tests1((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,10 @@
|
|||||||
template <class X>
|
template <class X>
|
||||||
void unique_insert_tests1(X* = 0)
|
void unique_insert_tests1(X* = 0)
|
||||||
{
|
{
|
||||||
|
typedef 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";
|
std::cerr<<"insert(value) tests for containers with unique keys.\n";
|
||||||
|
|
||||||
X x;
|
X x;
|
||||||
@@ -30,9 +34,8 @@ void unique_insert_tests1(X* = 0)
|
|||||||
typename X::size_type old_bucket_count = x.bucket_count();
|
typename X::size_type old_bucket_count = x.bucket_count();
|
||||||
float b = x.max_load_factor();
|
float b = x.max_load_factor();
|
||||||
|
|
||||||
std::pair<typename X::iterator, bool> r1 = x.insert(*it);
|
std::pair<iterator, bool> r1 = x.insert(*it);
|
||||||
std::pair<typename test::ordered<X>::iterator, bool> r2
|
std::pair<ordered_iterator, bool> r2 = tracker.insert(*it);
|
||||||
= tracker.insert(*it);
|
|
||||||
|
|
||||||
BOOST_TEST(r1.second == r2.second);
|
BOOST_TEST(r1.second == r2.second);
|
||||||
BOOST_TEST(*r1.first == *r2.first);
|
BOOST_TEST(*r1.first == *r2.first);
|
||||||
@@ -192,7 +195,7 @@ void insert_tests2(X* = 0)
|
|||||||
|
|
||||||
test::random_values<X> v(1000);
|
test::random_values<X> v(1000);
|
||||||
x.insert(v.begin(), v.end());
|
x.insert(v.begin(), v.end());
|
||||||
check_container(x, v);
|
test::check_container(x, v);
|
||||||
|
|
||||||
test::check_equivalent_keys(x);
|
test::check_equivalent_keys(x);
|
||||||
}
|
}
|
||||||
|
@@ -46,9 +46,9 @@ void insert_test(X*, float mlf)
|
|||||||
template <class X>
|
template <class X>
|
||||||
void load_factor_insert_tests(X* ptr = 0)
|
void load_factor_insert_tests(X* ptr = 0)
|
||||||
{
|
{
|
||||||
insert_test(ptr, 1.0);
|
insert_test(ptr, 1.0f);
|
||||||
insert_test(ptr, 0.1);
|
insert_test(ptr, 0.1f);
|
||||||
insert_test(ptr, 100);
|
insert_test(ptr, 100.0f);
|
||||||
|
|
||||||
insert_test(ptr, (std::numeric_limits<float>::min)());
|
insert_test(ptr, (std::numeric_limits<float>::min)());
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ void rehash_test1(X* = 0)
|
|||||||
{
|
{
|
||||||
test::random_values<X> v(1000);
|
test::random_values<X> v(1000);
|
||||||
test::ordered<X> tracker;
|
test::ordered<X> tracker;
|
||||||
tracker.insert(v.begin(), v.end());
|
tracker.insert_range(v.begin(), v.end());
|
||||||
X x(v.begin(), v.end());
|
X x(v.begin(), v.end());
|
||||||
|
|
||||||
x.rehash(0); BOOST_TEST(postcondition(x, 0));
|
x.rehash(0); BOOST_TEST(postcondition(x, 0));
|
||||||
|
@@ -3,6 +3,9 @@
|
|||||||
// subject to the Boost Software License, Version 1.0. (See accompanying
|
// subject to the Boost Software License, Version 1.0. (See accompanying
|
||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
@@ -16,8 +19,8 @@ void swap_test_impl(X& x1, X& x2)
|
|||||||
{
|
{
|
||||||
test::ordered<X> tracker1 = test::create_ordered(x1);
|
test::ordered<X> tracker1 = test::create_ordered(x1);
|
||||||
test::ordered<X> tracker2 = test::create_ordered(x2);
|
test::ordered<X> tracker2 = test::create_ordered(x2);
|
||||||
tracker1.insert(x1.begin(), x1.end());
|
tracker1.insert_range(x1.begin(), x1.end());
|
||||||
tracker2.insert(x2.begin(), x2.end());
|
tracker2.insert_range(x2.begin(), x2.end());
|
||||||
x1.swap(x2);
|
x1.swap(x2);
|
||||||
tracker1.compare(x2);
|
tracker1.compare(x2);
|
||||||
tracker2.compare(x1);
|
tracker2.compare(x1);
|
||||||
|
Reference in New Issue
Block a user