Unordered: Test with more allocators.

Causes some C++11 failures....

[SVN r79357]
This commit is contained in:
Daniel James
2012-07-08 11:55:35 +00:00
parent 958b1d468f
commit f387994422
11 changed files with 208 additions and 85 deletions

View File

@ -22,7 +22,8 @@ namespace test
class hash; class hash;
class less; class less;
class equal_to; class equal_to;
template <class T> class allocator; template <class T> class allocator1;
template <class T> class allocator2;
object generate(object const*); object generate(object const*);
implicitly_convertible generate(implicitly_convertible const*); implicitly_convertible generate(implicitly_convertible const*);
@ -183,13 +184,97 @@ namespace test
} }
}; };
// allocator1 and allocator2 are pretty similar.
// allocator1 only has the old fashioned 'construct' method and has
// a few less typedefs
template <class T> template <class T>
class allocator class allocator1
{
public:
int tag_;
typedef T value_type;
template <class U> struct rebind { typedef allocator1<U> other; };
explicit allocator1(int t = 0) : tag_(t)
{
detail::tracker.allocator_ref();
}
template <class Y> allocator1(allocator1<Y> const& x)
: tag_(x.tag_)
{
detail::tracker.allocator_ref();
}
allocator1(allocator1 const& x)
: tag_(x.tag_)
{
detail::tracker.allocator_ref();
}
~allocator1()
{
detail::tracker.allocator_unref();
}
T* allocate(std::size_t n) {
T* ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*) ptr, n, sizeof(T), tag_);
return ptr;
}
T* allocate(std::size_t n, void const* u)
{
T* ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*) ptr, n, sizeof(T), tag_);
return ptr;
}
void deallocate(T* p, std::size_t n)
{
detail::tracker.track_deallocate((void*) p, n, sizeof(T), tag_);
::operator delete((void*) p);
}
void construct(T* p, T const& t) {
// Don't count constructions here as it isn't always called.
//detail::tracker.track_construct((void*) p, sizeof(T), tag_);
new(p) T(t);
}
void destroy(T* p) {
//detail::tracker.track_destroy((void*) p, sizeof(T), tag_);
p->~T();
}
bool operator==(allocator1 const& x) const
{
return tag_ == x.tag_;
}
bool operator!=(allocator1 const& x) const
{
return tag_ != x.tag_;
}
enum {
is_select_on_copy = false,
is_propagate_on_swap = false,
is_propagate_on_assign = false,
is_propagate_on_move = false
};
};
template <class T>
class allocator2
{ {
# ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS # ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public: public:
# else # else
template <class> friend class allocator; template <class> friend class allocator2;
# endif # endif
int tag_; int tag_;
public: public:
@ -201,26 +286,26 @@ namespace test
typedef T const& const_reference; typedef T const& const_reference;
typedef T value_type; typedef T value_type;
template <class U> struct rebind { typedef allocator<U> other; }; template <class U> struct rebind { typedef allocator2<U> other; };
explicit allocator(int t = 0) : tag_(t) explicit allocator2(int t = 0) : tag_(t)
{ {
detail::tracker.allocator_ref(); detail::tracker.allocator_ref();
} }
template <class Y> allocator(allocator<Y> const& x) template <class Y> allocator2(allocator2<Y> const& x)
: tag_(x.tag_) : tag_(x.tag_)
{ {
detail::tracker.allocator_ref(); detail::tracker.allocator_ref();
} }
allocator(allocator const& x) allocator2(allocator2 const& x)
: tag_(x.tag_) : tag_(x.tag_)
{ {
detail::tracker.allocator_ref(); detail::tracker.allocator_ref();
} }
~allocator() ~allocator2()
{ {
detail::tracker.allocator_unref(); detail::tracker.allocator_unref();
} }
@ -275,12 +360,12 @@ namespace test
return (std::numeric_limits<size_type>::max)(); return (std::numeric_limits<size_type>::max)();
} }
bool operator==(allocator const& x) const bool operator==(allocator2 const& x) const
{ {
return tag_ == x.tag_; return tag_ == x.tag_;
} }
bool operator!=(allocator const& x) const bool operator!=(allocator2 const& x) const
{ {
return tag_ != x.tag_; return tag_ != x.tag_;
} }
@ -294,7 +379,14 @@ namespace test
}; };
template <class T> template <class T>
bool equivalent_impl(allocator<T> const& x, allocator<T> const& y, bool equivalent_impl(allocator1<T> const& x, allocator1<T> const& y,
test::derived_type)
{
return x == y;
}
template <class T>
bool equivalent_impl(allocator2<T> const& x, allocator2<T> const& y,
test::derived_type) test::derived_type)
{ {
return x == y; return x == y;

View File

@ -114,18 +114,22 @@ void assign_tests2(T*,
} }
} }
boost::unordered_set<test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_set;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object, boost::unordered_map<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_map; std::allocator<test::object> >* test_map_std_alloc;
boost::unordered_set<test::object,
test::hash, test::equal_to,
test::allocator1<test::object> >* test_set;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator2<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object,
test::hash, test::equal_to,
test::allocator2<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object, boost::unordered_multimap<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multimap; test::allocator1<test::object> >* test_multimap;
boost::unordered_set<test::object, boost::unordered_set<test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
@ -178,6 +182,7 @@ UNORDERED_AUTO_TEST(check_traits)
} }
UNORDERED_TEST(assign_tests1, ( UNORDERED_TEST(assign_tests1, (
(test_map_std_alloc)
(test_set)(test_multiset)(test_map)(test_multimap) (test_set)(test_multiset)(test_map)(test_multimap)
(test_set_prop_assign)(test_multiset_prop_assign)(test_map_prop_assign)(test_multimap_prop_assign) (test_set_prop_assign)(test_multiset_prop_assign)(test_map_prop_assign)(test_multimap_prop_assign)
(test_set_no_prop_assign)(test_multiset_no_prop_assign)(test_map_no_prop_assign)(test_multimap_no_prop_assign) (test_set_no_prop_assign)(test_multiset_no_prop_assign)(test_map_no_prop_assign)(test_multimap_no_prop_assign)

View File

@ -68,20 +68,24 @@ void tests(X* = 0, test::random_generator generator = test::default_generator)
} }
} }
boost::unordered_set<test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_set;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object, boost::unordered_multimap<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multimap; std::allocator<test::object> >* test_multimap_std_alloc;
UNORDERED_TEST(tests, ((test_set)(test_multiset)(test_map)(test_multimap))) boost::unordered_set<test::object,
test::hash, test::equal_to,
test::allocator2<test::object> >* test_set;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator1<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object,
test::hash, test::equal_to,
test::allocator1<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object,
test::hash, test::equal_to,
test::allocator2<test::object> >* test_multimap;
UNORDERED_TEST(tests, ((test_multimap_std_alloc)(test_set)(test_multiset)(test_map)(test_multimap)))
} }

View File

@ -402,24 +402,28 @@ void map_constructor_test(T* = 0,
test::check_equivalent_keys(x); test::check_equivalent_keys(x);
} }
boost::unordered_set<test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_set;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object, boost::unordered_map<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_map; std::allocator<test::object> >* test_map_std_alloc;
boost::unordered_set<test::object,
test::hash, test::equal_to,
test::allocator1<test::object> >* test_set;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator2<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object,
test::hash, test::equal_to,
test::allocator2<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object, boost::unordered_multimap<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multimap; test::allocator1<test::object> >* test_multimap;
using test::default_generator; using test::default_generator;
using test::generate_collisions; using test::generate_collisions;
UNORDERED_TEST(constructor_tests1, UNORDERED_TEST(constructor_tests1,
((test_set)(test_multiset)(test_map)(test_multimap)) ((test_map_std_alloc)(test_set)(test_multiset)(test_map)(test_multimap))
((default_generator)(generate_collisions)) ((default_generator)(generate_collisions))
) )
@ -429,7 +433,7 @@ UNORDERED_TEST(constructor_tests2,
) )
UNORDERED_TEST(map_constructor_test, UNORDERED_TEST(map_constructor_test,
((test_map)(test_multimap)) ((test_map_std_alloc)(test_map)(test_multimap))
) )
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)

View File

@ -155,16 +155,16 @@ void copy_construct_tests2(T* ptr,
boost::unordered_set<test::object, boost::unordered_set<test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_set; test::allocator1<test::object> >* test_set;
boost::unordered_multiset<test::object, boost::unordered_multiset<test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multiset; test::allocator2<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object, boost::unordered_map<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_map; test::allocator1<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object, boost::unordered_multimap<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multimap; test::allocator2<test::object> >* test_multimap;
boost::unordered_set<test::object, boost::unordered_set<test::object,
test::hash, test::equal_to, test::hash, test::equal_to,

View File

@ -53,10 +53,10 @@ struct collision2_hash
typedef boost::unordered_multimap<int, int, typedef boost::unordered_multimap<int, int,
collision_hash, std::equal_to<int>, collision_hash, std::equal_to<int>,
test::allocator<std::pair<int const, int> > > collide_map; test::allocator1<std::pair<int const, int> > > collide_map;
typedef boost::unordered_multimap<int, int, typedef boost::unordered_multimap<int, int,
collision2_hash, std::equal_to<int>, collision2_hash, std::equal_to<int>,
test::allocator<std::pair<int const, int> > > collide_map2; test::allocator2<std::pair<int const, int> > > collide_map2;
typedef collide_map::value_type collide_value; typedef collide_map::value_type collide_value;
typedef test::list<collide_value> collide_list; typedef test::list<collide_value> collide_list;

View File

@ -196,16 +196,16 @@ void erase_tests1(Container*,
boost::unordered_set<test::object, boost::unordered_set<test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_set; test::allocator1<test::object> >* test_set;
boost::unordered_multiset<test::object, boost::unordered_multiset<test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multiset; test::allocator2<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object, boost::unordered_map<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_map; test::allocator1<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object, boost::unordered_multimap<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multimap; test::allocator2<test::object> >* test_multimap;
using test::default_generator; using test::default_generator;
using test::generate_collisions; using test::generate_collisions;

View File

@ -142,16 +142,16 @@ void find_compatible_keys_test(X*,
boost::unordered_set<test::object, boost::unordered_set<test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_set; test::allocator2<test::object> >* test_set;
boost::unordered_multiset<test::object, boost::unordered_multiset<test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multiset; test::allocator1<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object, boost::unordered_map<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_map; test::allocator2<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object, boost::unordered_multimap<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multimap; test::allocator1<test::object> >* test_multimap;
using test::default_generator; using test::default_generator;
using test::generate_collisions; using test::generate_collisions;

View File

@ -410,43 +410,50 @@ void map_insert_range_test2(X*,
boost::unordered_set<test::object, boost::unordered_set<test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_set; std::allocator<test::object> >* test_set_std_alloc;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object, boost::unordered_multimap<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multimap; std::allocator<test::object> >* test_multimap_std_alloc;
boost::unordered_set<test::object,
test::hash, test::equal_to,
test::allocator1<test::object> >* test_set;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator2<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object,
test::hash, test::equal_to,
test::allocator2<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object,
test::hash, test::equal_to,
test::allocator1<test::object> >* test_multimap;
using test::default_generator; using test::default_generator;
using test::generate_collisions; using test::generate_collisions;
UNORDERED_TEST(unique_insert_tests1, UNORDERED_TEST(unique_insert_tests1,
((test_set)(test_map)) ((test_set_std_alloc)(test_set)(test_map))
((default_generator)(generate_collisions)) ((default_generator)(generate_collisions))
) )
UNORDERED_TEST(equivalent_insert_tests1, UNORDERED_TEST(equivalent_insert_tests1,
((test_multiset)(test_multimap)) ((test_multimap_std_alloc)(test_multiset)(test_multimap))
((default_generator)(generate_collisions)) ((default_generator)(generate_collisions))
) )
UNORDERED_TEST(insert_tests2, UNORDERED_TEST(insert_tests2,
((test_set)(test_multiset)(test_map)(test_multimap)) ((test_multimap_std_alloc)(test_set)(test_multiset)(test_map)(test_multimap))
((default_generator)(generate_collisions)) ((default_generator)(generate_collisions))
) )
#if !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_VARIADIC_TEMPLATES) #if !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_VARIADIC_TEMPLATES)
UNORDERED_TEST(unique_emplace_tests1, UNORDERED_TEST(unique_emplace_tests1,
((test_set)(test_map)) ((test_set_std_alloc)(test_set)(test_map))
((default_generator)(generate_collisions)) ((default_generator)(generate_collisions))
) )
UNORDERED_TEST(equivalent_emplace_tests1, UNORDERED_TEST(equivalent_emplace_tests1,
((test_multiset)(test_multimap)) ((test_multimap_std_alloc)(test_multiset)(test_multimap))
((default_generator)(generate_collisions)) ((default_generator)(generate_collisions))
) )
#endif #endif
@ -457,12 +464,12 @@ UNORDERED_TEST(map_tests,
) )
UNORDERED_TEST(map_insert_range_test1, UNORDERED_TEST(map_insert_range_test1,
((test_map)(test_multimap)) ((test_multimap_std_alloc)(test_map)(test_multimap))
((default_generator)(generate_collisions)) ((default_generator)(generate_collisions))
) )
UNORDERED_TEST(map_insert_range_test2, UNORDERED_TEST(map_insert_range_test2,
((test_map)(test_multimap)) ((test_multimap_std_alloc)(test_map)(test_multimap))
((default_generator)(generate_collisions)) ((default_generator)(generate_collisions))
) )

View File

@ -316,18 +316,22 @@ namespace move_tests
} }
} }
boost::unordered_set<test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_set;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object, boost::unordered_map<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_map; std::allocator<test::object> >* test_map_std_alloc;
boost::unordered_set<test::object,
test::hash, test::equal_to,
test::allocator2<test::object> >* test_set;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator1<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object,
test::hash, test::equal_to,
test::allocator1<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object, boost::unordered_multimap<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multimap; test::allocator2<test::object> >* test_multimap;
boost::unordered_set<test::object, boost::unordered_set<test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
@ -367,12 +371,14 @@ boost::unordered_multimap<test::object, test::object,
using test::generate_collisions; using test::generate_collisions;
UNORDERED_TEST(move_construct_tests1, ( UNORDERED_TEST(move_construct_tests1, (
(test_map_std_alloc)
(test_set)(test_multiset)(test_map)(test_multimap) (test_set)(test_multiset)(test_map)(test_multimap)
(test_set_prop_move)(test_multiset_prop_move)(test_map_prop_move)(test_multimap_prop_move) (test_set_prop_move)(test_multiset_prop_move)(test_map_prop_move)(test_multimap_prop_move)
(test_set_no_prop_move)(test_multiset_no_prop_move)(test_map_no_prop_move)(test_multimap_no_prop_move) (test_set_no_prop_move)(test_multiset_no_prop_move)(test_map_no_prop_move)(test_multimap_no_prop_move)
) )
) )
UNORDERED_TEST(move_assign_tests1, ( UNORDERED_TEST(move_assign_tests1, (
(test_map_std_alloc)
(test_set)(test_multiset)(test_map)(test_multimap) (test_set)(test_multiset)(test_map)(test_multimap)
(test_set_prop_move)(test_multiset_prop_move)(test_map_prop_move)(test_multimap_prop_move) (test_set_prop_move)(test_multiset_prop_move)(test_map_prop_move)(test_multimap_prop_move)
(test_set_no_prop_move)(test_multiset_no_prop_move)(test_map_no_prop_move)(test_multimap_no_prop_move) (test_set_no_prop_move)(test_multiset_no_prop_move)(test_map_no_prop_move)(test_multimap_no_prop_move)

View File

@ -148,18 +148,22 @@ void swap_tests2(X* ptr = 0,
} }
} }
boost::unordered_set<test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_set;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object, boost::unordered_map<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_map; std::allocator<test::object> >* test_map_std_alloc;
boost::unordered_set<test::object,
test::hash, test::equal_to,
test::allocator1<test::object> >* test_set;
boost::unordered_multiset<test::object,
test::hash, test::equal_to,
test::allocator2<test::object> >* test_multiset;
boost::unordered_map<test::object, test::object,
test::hash, test::equal_to,
test::allocator1<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object, boost::unordered_multimap<test::object, test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
test::allocator<test::object> >* test_multimap; test::allocator2<test::object> >* test_multimap;
boost::unordered_set<test::object, boost::unordered_set<test::object,
test::hash, test::equal_to, test::hash, test::equal_to,
@ -209,6 +213,7 @@ UNORDERED_AUTO_TEST(check_traits)
} }
UNORDERED_TEST(swap_tests1, ( UNORDERED_TEST(swap_tests1, (
(test_map_std_alloc)
(test_set)(test_multiset)(test_map)(test_multimap) (test_set)(test_multiset)(test_map)(test_multimap)
(test_set_prop_swap)(test_multiset_prop_swap)(test_map_prop_swap)(test_multimap_prop_swap) (test_set_prop_swap)(test_multiset_prop_swap)(test_map_prop_swap)(test_multimap_prop_swap)
(test_set_no_prop_swap)(test_multiset_no_prop_swap)(test_map_no_prop_swap)(test_multimap_no_prop_swap) (test_set_no_prop_swap)(test_multiset_no_prop_swap)(test_map_no_prop_swap)(test_multimap_no_prop_swap)