mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-31 20:04:29 +02:00
Unordered: Reduce the amount of meta-stuff in the tests.
Some of this was there for older compilers, some is just premature generalization. There's still too much metaprogramming, but these are things that are relatively easy to remove. [SVN r79356]
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
#if !defined(BOOST_UNORDERED_TEST_HELPERS_CHECK_RETURN_TYPE_HEADER)
|
#if !defined(BOOST_UNORDERED_TEST_HELPERS_CHECK_RETURN_TYPE_HEADER)
|
||||||
#define BOOST_UNORDERED_TEST_HELPERS_CHECK_RETURN_TYPE_HEADER
|
#define BOOST_UNORDERED_TEST_HELPERS_CHECK_RETURN_TYPE_HEADER
|
||||||
|
|
||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
#include <boost/type_traits/is_convertible.hpp>
|
||||||
|
|
||||||
@@ -18,19 +18,19 @@ namespace test
|
|||||||
template <class T2>
|
template <class T2>
|
||||||
static void equals(T2)
|
static void equals(T2)
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT((boost::is_same<T1, T2>));
|
BOOST_STATIC_ASSERT((boost::is_same<T1, T2>::value));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T2>
|
template <class T2>
|
||||||
static void equals_ref(T2&)
|
static void equals_ref(T2&)
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT((boost::is_same<T1, T2>));
|
BOOST_STATIC_ASSERT((boost::is_same<T1, T2>::value));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T2>
|
template <class T2>
|
||||||
static void convertible(T2)
|
static void convertible(T2)
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT((boost::is_convertible<T2, T1>));
|
BOOST_STATIC_ASSERT((boost::is_convertible<T2, T1>::value));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -8,10 +8,8 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <boost/mpl/apply.hpp>
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/unordered/detail/allocate.hpp>
|
#include <boost/unordered/detail/allocate.hpp>
|
||||||
#include <boost/mpl/aux_/config/eti.hpp>
|
|
||||||
#include "../helpers/test.hpp"
|
#include "../helpers/test.hpp"
|
||||||
|
|
||||||
namespace test
|
namespace test
|
||||||
|
@@ -8,72 +8,33 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/mpl/not.hpp>
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
|
|
||||||
namespace test
|
namespace test
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
struct unordered_set_type { char x[100]; };
|
|
||||||
struct unordered_multiset_type { char x[200]; };
|
|
||||||
struct unordered_map_type { char x[300]; };
|
|
||||||
struct unordered_multimap_type { char x[400]; };
|
|
||||||
|
|
||||||
template <class V, class H, class P, class A>
|
|
||||||
unordered_set_type container_type(
|
|
||||||
boost::unordered_set<V, H, P, A> const*);
|
|
||||||
template <class V, class H, class P, class A>
|
|
||||||
unordered_multiset_type container_type(
|
|
||||||
boost::unordered_multiset<V, H, P, A> const*);
|
|
||||||
template <class K, class M, class H, class P, class A>
|
|
||||||
unordered_map_type container_type(
|
|
||||||
boost::unordered_map<K, M, H, P, A> const*);
|
|
||||||
template <class K, class M, class H, class P, class A>
|
|
||||||
unordered_multimap_type container_type(
|
|
||||||
boost::unordered_multimap<K, M, H, P, A> const*);
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class Container>
|
template <class Container>
|
||||||
struct is_set
|
struct is_set
|
||||||
: public boost::is_same<
|
: public boost::is_same<
|
||||||
BOOST_DEDUCED_TYPENAME Container::key_type,
|
BOOST_DEDUCED_TYPENAME Container::key_type,
|
||||||
BOOST_DEDUCED_TYPENAME Container::value_type> {};
|
BOOST_DEDUCED_TYPENAME Container::value_type> {};
|
||||||
|
|
||||||
template <class Container>
|
|
||||||
struct is_map
|
|
||||||
: public boost::mpl::not_<is_set<Container> > {};
|
|
||||||
|
|
||||||
struct yes_type { char x[100]; };
|
|
||||||
struct no_type { char x[200]; };
|
|
||||||
|
|
||||||
template <class V, class H, class P, class A>
|
|
||||||
yes_type has_unique_key_impl(
|
|
||||||
boost::unordered_set<V, H, P, A> const*);
|
|
||||||
template <class V, class H, class P, class A>
|
|
||||||
no_type has_unique_key_impl(
|
|
||||||
boost::unordered_multiset<V, H, P, A> const*);
|
|
||||||
template <class K, class M, class H, class P, class A>
|
|
||||||
yes_type has_unique_key_impl(
|
|
||||||
boost::unordered_map<K, M, H, P, A> const*);
|
|
||||||
template <class K, class M, class H, class P, class A>
|
|
||||||
no_type has_unique_key_impl(
|
|
||||||
boost::unordered_multimap<K, M, H, P, A> const*);
|
|
||||||
|
|
||||||
template <class Container>
|
template <class Container>
|
||||||
struct has_unique_keys
|
struct has_unique_keys
|
||||||
{
|
{
|
||||||
BOOST_STATIC_CONSTANT(bool, value =
|
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||||
sizeof(has_unique_key_impl((Container const*)0))
|
|
||||||
== sizeof(yes_type));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Container>
|
template <class V, class H, class P, class A>
|
||||||
struct has_equivalent_keys
|
struct has_unique_keys<boost::unordered_set<V, H, P, A> >
|
||||||
{
|
{
|
||||||
BOOST_STATIC_CONSTANT(bool, value =
|
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||||
sizeof(has_unique_key_impl((Container const*)0))
|
};
|
||||||
== sizeof(no_type));
|
|
||||||
|
template <class K, class M, class H, class P, class A>
|
||||||
|
struct has_unique_keys<boost::unordered_map<K, M, H, P, A> >
|
||||||
|
{
|
||||||
|
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include "./list.hpp"
|
#include "./list.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/detail/select_type.hpp>
|
||||||
#include "./generators.hpp"
|
#include "./generators.hpp"
|
||||||
#include "./metafunctions.hpp"
|
#include "./metafunctions.hpp"
|
||||||
|
|
||||||
@@ -81,10 +81,12 @@ namespace test
|
|||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
struct unordered_generator_base
|
struct unordered_generator_base
|
||||||
: public boost::mpl::if_<
|
: public boost::detail::if_true<
|
||||||
test::is_set<X>,
|
test::is_set<X>::value
|
||||||
|
>::BOOST_NESTED_TEMPLATE then<
|
||||||
test::unordered_generator_set<X>,
|
test::unordered_generator_set<X>,
|
||||||
test::unordered_generator_map<X> >
|
test::unordered_generator_map<X>
|
||||||
|
>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include "./metafunctions.hpp"
|
|
||||||
#include "./equivalent.hpp"
|
#include "./equivalent.hpp"
|
||||||
#include "./list.hpp"
|
#include "./list.hpp"
|
||||||
#include "./exception_test.hpp"
|
#include "./exception_test.hpp"
|
||||||
|
@@ -13,9 +13,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/mpl/if.hpp>
|
|
||||||
#include <boost/mpl/eval_if.hpp>
|
|
||||||
#include <boost/mpl/identity.hpp>
|
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include "../objects/fwd.hpp"
|
#include "../objects/fwd.hpp"
|
||||||
#include "./metafunctions.hpp"
|
#include "./metafunctions.hpp"
|
||||||
@@ -25,21 +22,17 @@
|
|||||||
|
|
||||||
namespace test
|
namespace test
|
||||||
{
|
{
|
||||||
template <class X>
|
template <typename X>
|
||||||
struct equals_to_compare2
|
struct equals_to_compare
|
||||||
: public boost::mpl::identity<
|
|
||||||
std::less<BOOST_DEDUCED_TYPENAME X::first_argument_type> >
|
|
||||||
{
|
{
|
||||||
|
typedef std::less<BOOST_DEDUCED_TYPENAME X::first_argument_type>
|
||||||
|
type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class X>
|
template <>
|
||||||
struct equals_to_compare
|
struct equals_to_compare<test::equal_to>
|
||||||
: 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>
|
||||||
@@ -67,51 +60,40 @@ namespace test
|
|||||||
values2.begin(), test::equivalent));
|
values2.begin(), test::equivalent));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class X>
|
template <typename X>
|
||||||
struct ordered_set : public
|
struct ordered_base;
|
||||||
boost::mpl::if_<
|
|
||||||
test::has_unique_keys<X>,
|
|
||||||
std::set<
|
|
||||||
BOOST_DEDUCED_TYPENAME X::value_type,
|
|
||||||
BOOST_DEDUCED_TYPENAME equals_to_compare<
|
|
||||||
BOOST_DEDUCED_TYPENAME X::key_equal
|
|
||||||
>::type
|
|
||||||
>,
|
|
||||||
std::multiset<
|
|
||||||
BOOST_DEDUCED_TYPENAME X::value_type,
|
|
||||||
BOOST_DEDUCED_TYPENAME equals_to_compare<
|
|
||||||
BOOST_DEDUCED_TYPENAME X::key_equal
|
|
||||||
>::type
|
|
||||||
>
|
|
||||||
> {};
|
|
||||||
|
|
||||||
template <class X>
|
template <class V, class H, class P, class A>
|
||||||
struct ordered_map : public
|
struct ordered_base<boost::unordered_set<V, H, P, A> >
|
||||||
boost::mpl::if_<
|
{
|
||||||
test::has_unique_keys<X>,
|
typedef std::set<V,
|
||||||
std::map<
|
BOOST_DEDUCED_TYPENAME equals_to_compare<P>::type>
|
||||||
BOOST_DEDUCED_TYPENAME X::key_type,
|
type;
|
||||||
BOOST_DEDUCED_TYPENAME X::mapped_type,
|
};
|
||||||
BOOST_DEDUCED_TYPENAME equals_to_compare<
|
|
||||||
BOOST_DEDUCED_TYPENAME X::key_equal
|
|
||||||
>::type
|
|
||||||
>,
|
|
||||||
std::multimap<
|
|
||||||
BOOST_DEDUCED_TYPENAME X::key_type,
|
|
||||||
BOOST_DEDUCED_TYPENAME X::mapped_type,
|
|
||||||
BOOST_DEDUCED_TYPENAME equals_to_compare<
|
|
||||||
BOOST_DEDUCED_TYPENAME X::key_equal
|
|
||||||
>::type
|
|
||||||
>
|
|
||||||
> {};
|
|
||||||
|
|
||||||
template <class X>
|
template <class V, class H, class P, class A>
|
||||||
struct ordered_base : public
|
struct ordered_base<boost::unordered_multiset<V, H, P, A> >
|
||||||
boost::mpl::eval_if<
|
{
|
||||||
test::is_set<X>,
|
typedef std::multiset<V,
|
||||||
test::ordered_set<X>,
|
BOOST_DEDUCED_TYPENAME equals_to_compare<P>::type>
|
||||||
test::ordered_map<X>
|
type;
|
||||||
> {};
|
};
|
||||||
|
|
||||||
|
template <class K, class M, class H, class P, class A>
|
||||||
|
struct ordered_base<boost::unordered_map<K, M, H, P, A> >
|
||||||
|
{
|
||||||
|
typedef std::map<K, M,
|
||||||
|
BOOST_DEDUCED_TYPENAME equals_to_compare<P>::type>
|
||||||
|
type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class K, class M, class H, class P, class A>
|
||||||
|
struct ordered_base<boost::unordered_multimap<K, M, H, P, A> >
|
||||||
|
{
|
||||||
|
typedef std::multimap<K, M,
|
||||||
|
BOOST_DEDUCED_TYPENAME equals_to_compare<P>::type>
|
||||||
|
type;
|
||||||
|
};
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
class ordered : public ordered_base<X>::type
|
class ordered : public ordered_base<X>::type
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
#include <boost/unordered/detail/allocate.hpp>
|
#include <boost/unordered/detail/allocate.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/limits.hpp>
|
#include <boost/limits.hpp>
|
||||||
|
|
||||||
// Boilerplate
|
// Boilerplate
|
||||||
@@ -91,15 +91,15 @@ void test_empty_allocator()
|
|||||||
typedef empty_allocator<int> allocator;
|
typedef empty_allocator<int> allocator;
|
||||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||||
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
|
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::size_type,
|
BOOST_STATIC_ASSERT((boost::is_same<traits::size_type,
|
||||||
std::make_unsigned<std::ptrdiff_t>::type>));
|
std::make_unsigned<std::ptrdiff_t>::type>::value));
|
||||||
#else
|
#else
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::size_type, std::size_t>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::size_type, std::size_t>::value));
|
||||||
#endif
|
#endif
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::pointer, int*>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::pointer, int*>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::const_pointer, int const*>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::const_pointer, int const*>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::value_type, int>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::value_type, int>::value));
|
||||||
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
|
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
|
||||||
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
|
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
|
||||||
BOOST_TEST(!traits::propagate_on_container_swap::value);
|
BOOST_TEST(!traits::propagate_on_container_swap::value);
|
||||||
@@ -129,15 +129,15 @@ void test_allocator1()
|
|||||||
typedef allocator1<int> allocator;
|
typedef allocator1<int> allocator;
|
||||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||||
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
|
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::size_type,
|
BOOST_STATIC_ASSERT((boost::is_same<traits::size_type,
|
||||||
std::make_unsigned<std::ptrdiff_t>::type>));
|
std::make_unsigned<std::ptrdiff_t>::type>::value));
|
||||||
#else
|
#else
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::size_type, std::size_t>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::size_type, std::size_t>::value));
|
||||||
#endif
|
#endif
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::pointer, int*>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::pointer, int*>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::const_pointer, int const*>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::const_pointer, int const*>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::value_type, int>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::value_type, int>::value));
|
||||||
BOOST_TEST(traits::propagate_on_container_copy_assignment::value);
|
BOOST_TEST(traits::propagate_on_container_copy_assignment::value);
|
||||||
BOOST_TEST(traits::propagate_on_container_move_assignment::value);
|
BOOST_TEST(traits::propagate_on_container_move_assignment::value);
|
||||||
BOOST_TEST(traits::propagate_on_container_swap::value);
|
BOOST_TEST(traits::propagate_on_container_swap::value);
|
||||||
@@ -174,11 +174,11 @@ void test_allocator2()
|
|||||||
{
|
{
|
||||||
typedef allocator2<int> allocator;
|
typedef allocator2<int> allocator;
|
||||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::size_type, std::size_t>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::size_type, std::size_t>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::pointer, int*>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::pointer, int*>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::const_pointer, int const*>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::const_pointer, int const*>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::value_type, int>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::value_type, int>::value));
|
||||||
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
|
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
|
||||||
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
|
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
|
||||||
BOOST_TEST(!traits::propagate_on_container_swap::value);
|
BOOST_TEST(!traits::propagate_on_container_swap::value);
|
||||||
@@ -233,11 +233,11 @@ void test_allocator3()
|
|||||||
{
|
{
|
||||||
typedef allocator3<int> allocator;
|
typedef allocator3<int> allocator;
|
||||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::size_type, unsigned short>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::size_type, unsigned short>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::pointer, ptr<int> >));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::pointer, ptr<int> >::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::const_pointer, ptr<int const> >));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::const_pointer, ptr<int const> >::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::value_type, int>));
|
BOOST_STATIC_ASSERT((boost::is_same<traits::value_type, int>::value));
|
||||||
BOOST_TEST(traits::propagate_on_container_copy_assignment::value);
|
BOOST_TEST(traits::propagate_on_container_copy_assignment::value);
|
||||||
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
|
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
|
||||||
BOOST_TEST(!traits::propagate_on_container_swap::value);
|
BOOST_TEST(!traits::propagate_on_container_swap::value);
|
||||||
|
@@ -16,8 +16,7 @@
|
|||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/mpl/bool.hpp>
|
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
#include <boost/type_traits/is_convertible.hpp>
|
||||||
#include <boost/iterator/iterator_traits.hpp>
|
#include <boost/iterator/iterator_traits.hpp>
|
||||||
@@ -55,42 +54,38 @@ void container_test(X& r, T const&)
|
|||||||
|
|
||||||
// value_type
|
// value_type
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<T, value_type>));
|
BOOST_STATIC_ASSERT((boost::is_same<T, value_type>::value));
|
||||||
boost::function_requires<boost::CopyConstructibleConcept<X> >();
|
boost::function_requires<boost::CopyConstructibleConcept<X> >();
|
||||||
|
|
||||||
// reference_type / const_reference_type
|
// reference_type / const_reference_type
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<T&, reference>));
|
BOOST_STATIC_ASSERT((boost::is_same<T&, reference>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<T const&, const_reference>));
|
BOOST_STATIC_ASSERT((boost::is_same<T const&, const_reference>::value));
|
||||||
|
|
||||||
// iterator
|
// iterator
|
||||||
|
|
||||||
boost::function_requires<boost::InputIteratorConcept<iterator> >();
|
boost::function_requires<boost::InputIteratorConcept<iterator> >();
|
||||||
BOOST_MPL_ASSERT((boost::is_same<T, iterator_value_type>));
|
BOOST_STATIC_ASSERT((boost::is_same<T, iterator_value_type>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_convertible<iterator, const_iterator>));
|
BOOST_STATIC_ASSERT((boost::is_convertible<iterator, const_iterator>::value));
|
||||||
|
|
||||||
// const_iterator
|
// const_iterator
|
||||||
|
|
||||||
boost::function_requires<boost::InputIteratorConcept<const_iterator> >();
|
boost::function_requires<boost::InputIteratorConcept<const_iterator> >();
|
||||||
BOOST_MPL_ASSERT((boost::is_same<T, const_iterator_value_type>));
|
BOOST_STATIC_ASSERT((boost::is_same<T, const_iterator_value_type>::value));
|
||||||
|
|
||||||
// difference_type
|
// difference_type
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::mpl::bool_<
|
BOOST_STATIC_ASSERT(std::numeric_limits<difference_type>::is_signed);
|
||||||
std::numeric_limits<difference_type>::is_signed>));
|
BOOST_STATIC_ASSERT(std::numeric_limits<difference_type>::is_integer);
|
||||||
BOOST_MPL_ASSERT((boost::mpl::bool_<
|
BOOST_STATIC_ASSERT((boost::is_same<difference_type,
|
||||||
std::numeric_limits<difference_type>::is_integer>));
|
iterator_difference_type>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<difference_type,
|
BOOST_STATIC_ASSERT((boost::is_same<difference_type,
|
||||||
iterator_difference_type>));
|
const_iterator_difference_type>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<difference_type,
|
|
||||||
const_iterator_difference_type>));
|
|
||||||
|
|
||||||
// size_type
|
// size_type
|
||||||
|
|
||||||
BOOST_MPL_ASSERT_NOT((boost::mpl::bool_<
|
BOOST_STATIC_ASSERT(!std::numeric_limits<size_type>::is_signed);
|
||||||
std::numeric_limits<size_type>::is_signed>));
|
BOOST_STATIC_ASSERT(std::numeric_limits<size_type>::is_integer);
|
||||||
BOOST_MPL_ASSERT((boost::mpl::bool_<
|
|
||||||
std::numeric_limits<size_type>::is_integer>));
|
|
||||||
|
|
||||||
// size_type can represent any non-negative value type of difference_type
|
// size_type can represent any non-negative value type of difference_type
|
||||||
// I'm not sure about either of these tests...
|
// I'm not sure about either of these tests...
|
||||||
@@ -184,7 +179,7 @@ void unordered_set_test(X&, Key const&)
|
|||||||
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
|
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
|
||||||
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<value_type, key_type>));
|
BOOST_STATIC_ASSERT((boost::is_same<value_type, key_type>::value));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class X, class Key, class T>
|
template <class X, class Key, class T>
|
||||||
@@ -193,8 +188,8 @@ void unordered_map_test(X& r, Key const& k, T const& v)
|
|||||||
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
|
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
|
||||||
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((
|
BOOST_STATIC_ASSERT((
|
||||||
boost::is_same<value_type, std::pair<key_type const, T> >));
|
boost::is_same<value_type, std::pair<key_type const, T> >::value));
|
||||||
|
|
||||||
r.insert(std::pair<Key const, T>(k, v));
|
r.insert(std::pair<Key const, T>(k, v));
|
||||||
|
|
||||||
@@ -313,36 +308,36 @@ void unordered_test(X& x, Key& k, Hash& hf, Pred& eq)
|
|||||||
boost::iterator_reference<const_local_iterator>::type
|
boost::iterator_reference<const_local_iterator>::type
|
||||||
const_local_iterator_reference;
|
const_local_iterator_reference;
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<Key, key_type>));
|
BOOST_STATIC_ASSERT((boost::is_same<Key, key_type>::value));
|
||||||
//boost::function_requires<boost::CopyConstructibleConcept<key_type> >();
|
//boost::function_requires<boost::CopyConstructibleConcept<key_type> >();
|
||||||
//boost::function_requires<boost::AssignableConcept<key_type> >();
|
//boost::function_requires<boost::AssignableConcept<key_type> >();
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<Hash, hasher>));
|
BOOST_STATIC_ASSERT((boost::is_same<Hash, hasher>::value));
|
||||||
test::check_return_type<std::size_t>::equals(hf(k));
|
test::check_return_type<std::size_t>::equals(hf(k));
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<Pred, key_equal>));
|
BOOST_STATIC_ASSERT((boost::is_same<Pred, key_equal>::value));
|
||||||
test::check_return_type<bool>::convertible(eq(k, k));
|
test::check_return_type<bool>::convertible(eq(k, k));
|
||||||
|
|
||||||
boost::function_requires<boost::InputIteratorConcept<local_iterator> >();
|
boost::function_requires<boost::InputIteratorConcept<local_iterator> >();
|
||||||
BOOST_MPL_ASSERT((boost::is_same<local_iterator_category,
|
BOOST_STATIC_ASSERT((boost::is_same<local_iterator_category,
|
||||||
iterator_category>));
|
iterator_category>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<local_iterator_difference,
|
BOOST_STATIC_ASSERT((boost::is_same<local_iterator_difference,
|
||||||
iterator_difference>));
|
iterator_difference>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<local_iterator_pointer,
|
BOOST_STATIC_ASSERT((boost::is_same<local_iterator_pointer,
|
||||||
iterator_pointer>));
|
iterator_pointer>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<local_iterator_reference,
|
BOOST_STATIC_ASSERT((boost::is_same<local_iterator_reference,
|
||||||
iterator_reference>));
|
iterator_reference>::value));
|
||||||
|
|
||||||
boost::function_requires<
|
boost::function_requires<
|
||||||
boost::InputIteratorConcept<const_local_iterator> >();
|
boost::InputIteratorConcept<const_local_iterator> >();
|
||||||
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_category,
|
BOOST_STATIC_ASSERT((boost::is_same<const_local_iterator_category,
|
||||||
const_iterator_category>));
|
const_iterator_category>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_difference,
|
BOOST_STATIC_ASSERT((boost::is_same<const_local_iterator_difference,
|
||||||
const_iterator_difference>));
|
const_iterator_difference>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_pointer,
|
BOOST_STATIC_ASSERT((boost::is_same<const_local_iterator_pointer,
|
||||||
const_iterator_pointer>));
|
const_iterator_pointer>::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_reference,
|
BOOST_STATIC_ASSERT((boost::is_same<const_local_iterator_reference,
|
||||||
const_iterator_reference>));
|
const_iterator_reference>::value));
|
||||||
|
|
||||||
X(10, hf, eq);
|
X(10, hf, eq);
|
||||||
X a(10, hf, eq);
|
X a(10, hf, eq);
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
#include <boost/unordered/detail/allocate.hpp>
|
#include <boost/unordered/detail/allocate.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include "../objects/test.hpp"
|
#include "../objects/test.hpp"
|
||||||
|
|
||||||
template <class Tp>
|
template <class Tp>
|
||||||
@@ -41,22 +41,22 @@ void test_simple_allocator()
|
|||||||
typedef boost::unordered::detail::allocator_traits<
|
typedef boost::unordered::detail::allocator_traits<
|
||||||
SimpleAllocator<T> > traits;
|
SimpleAllocator<T> > traits;
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<typename traits::allocator_type, SimpleAllocator<T> >));
|
BOOST_STATIC_ASSERT((boost::is_same<typename traits::allocator_type, SimpleAllocator<T> >::value));
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<typename traits::value_type, T>));
|
BOOST_STATIC_ASSERT((boost::is_same<typename traits::value_type, T>::value));
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<typename traits::pointer, T* >));
|
BOOST_STATIC_ASSERT((boost::is_same<typename traits::pointer, T* >::value));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<typename traits::const_pointer, T const*>));
|
BOOST_STATIC_ASSERT((boost::is_same<typename traits::const_pointer, T const*>::value));
|
||||||
//BOOST_MPL_ASSERT((boost::is_same<typename traits::void_pointer, void* >));
|
//BOOST_STATIC_ASSERT((boost::is_same<typename traits::void_pointer, void* >::value));
|
||||||
//BOOST_MPL_ASSERT((boost::is_same<typename traits::const_void_pointer, void const*>));
|
//BOOST_STATIC_ASSERT((boost::is_same<typename traits::const_void_pointer, void const*>::value));
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<typename traits::difference_type, std::ptrdiff_t>));
|
BOOST_STATIC_ASSERT((boost::is_same<typename traits::difference_type, std::ptrdiff_t>::value));
|
||||||
|
|
||||||
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
|
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
|
||||||
BOOST_MPL_ASSERT((boost::is_same<typename traits::size_type,
|
BOOST_STATIC_ASSERT((boost::is_same<typename traits::size_type,
|
||||||
std::make_unsigned<std::ptrdiff_t>::type>));
|
std::make_unsigned<std::ptrdiff_t>::type>::value));
|
||||||
#else
|
#else
|
||||||
BOOST_MPL_ASSERT((boost::is_same<typename traits::size_type, std::size_t>));
|
BOOST_STATIC_ASSERT((boost::is_same<typename traits::size_type, std::size_t>::value));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
|
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
|
||||||
|
@@ -162,12 +162,12 @@ namespace move_tests
|
|||||||
#elif defined(BOOST_HAS_NRVO)
|
#elif defined(BOOST_HAS_NRVO)
|
||||||
BOOST_TEST(
|
BOOST_TEST(
|
||||||
test::global_object_count.constructions - count.constructions <=
|
test::global_object_count.constructions - count.constructions <=
|
||||||
(test::is_map<T>::value ? 50 : 25));
|
(test::is_set<T>::value ? 25 : 50));
|
||||||
BOOST_TEST(count.instances == test::global_object_count.instances);
|
BOOST_TEST(count.instances == test::global_object_count.instances);
|
||||||
#else
|
#else
|
||||||
BOOST_TEST(
|
BOOST_TEST(
|
||||||
test::global_object_count.constructions - count.constructions <=
|
test::global_object_count.constructions - count.constructions <=
|
||||||
(test::is_map<T>::value ? 100 : 50));
|
(test::is_set<T>::value ? 50 : 100));
|
||||||
BOOST_TEST(count.instances == test::global_object_count.instances);
|
BOOST_TEST(count.instances == test::global_object_count.instances);
|
||||||
#endif
|
#endif
|
||||||
test::check_container(y, v);
|
test::check_container(y, v);
|
||||||
|
Reference in New Issue
Block a user