Use pre-review copy of unordered for trunk.

[SVN r42183]
This commit is contained in:
Daniel James
2007-12-19 22:42:12 +00:00
parent 3f2f75faf6
commit 56f91ea407
26 changed files with 508 additions and 1164 deletions
+6 -13
View File
@@ -111,7 +111,6 @@ void container_test(X& r, T&)
(&a1)->~X();
X const a_const;
test::check_return_type<iterator>::equals(a.begin());
test::check_return_type<const_iterator>::equals(a_const.begin());
test::check_return_type<const_iterator>::equals(a.cbegin());
@@ -120,18 +119,12 @@ void container_test(X& r, T&)
test::check_return_type<const_iterator>::equals(a_const.end());
test::check_return_type<const_iterator>::equals(a.cend());
test::check_return_type<const_iterator>::equals(a_const.cend());
}
template <class X, class T>
void equality_test(X& r, T&)
{
X const a = r, b = r;
// No tests for ==, != since they're not required for unordered containers.
test::check_return_type<bool>::equals(a == b);
test::check_return_type<bool>::equals(a != b);
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
test::check_return_type<std::size_t>::equals(boost::hash_value(a));
#else
test::check_return_type<std::size_t>::equals(hash_value(a));
#endif
a.swap(b);
test::check_return_type<X>::equals_ref(r = a);
test::check_return_type<size_type>::equals(a.size());
test::check_return_type<size_type>::equals(a.max_size());
test::check_return_type<bool>::convertible(a.empty());
}
+1 -31
View File
@@ -13,7 +13,7 @@
#include "../objects/minimal.hpp"
#include "./compile_tests.hpp"
void container_tests()
int main()
{
typedef std::pair<test::minimal::assignable const,
test::minimal::copy_constructible> value_type;
@@ -40,36 +40,6 @@ void container_tests()
test::minimal::allocator<value_type> > multimap;
container_test(multimap, value);
}
void equality_tests() {
typedef std::pair<test::minimal::assignable const,
test::minimal::copy_constructible_equality_comparable> value_type;
value_type value(
test::minimal::assignable::create(),
test::minimal::copy_constructible_equality_comparable::create());
boost::unordered_map<
test::minimal::assignable,
test::minimal::copy_constructible_equality_comparable,
test::minimal::hash<test::minimal::assignable>,
test::minimal::equal_to<test::minimal::assignable>,
test::minimal::allocator<value_type> > map;
equality_test(map, value);
boost::unordered_multimap<
test::minimal::assignable,
test::minimal::copy_constructible_equality_comparable,
test::minimal::hash<test::minimal::assignable>,
test::minimal::equal_to<test::minimal::assignable>,
test::minimal::allocator<value_type> > multimap;
equality_test(multimap, value);
}
int main() {
container_tests();
equality_tests();
return boost::report_errors();
}
-2
View File
@@ -25,7 +25,6 @@ int main()
test::minimal::allocator<test::minimal::assignable> > set;
container_test(set, assignable);
equality_test(set, assignable);
std::cout<<"Test unordered_multiset.\n";
boost::unordered_multiset<
@@ -35,7 +34,6 @@ int main()
test::minimal::allocator<test::minimal::assignable> > multiset;
container_test(multiset, assignable);
equality_test(multiset, assignable);
return boost::report_errors();
}
+1 -1
View File
@@ -21,5 +21,5 @@ test-suite unordered-tests
[ run erase_tests.cpp framework ]
[ run rehash_tests.cpp framework ]
[ run swap_tests.cpp framework : : :
<define>BOOST_UNORDERED_SWAP_METHOD=2 ]
<define>BOOST_UNORDERED_SWAP_METHOD=3 ]
;
+6 -47
View File
@@ -73,7 +73,11 @@ struct insert_test2 : public insert_test_base<T>
template <class T>
struct insert_test3 : public insert_test_base<T>
{
void run(T& x) const {
typedef typename insert_test_base<T>::strong_type strong_type;
void run(T& x, strong_type& strong) const {
// I don't think there's any need for this here.
//strong.store(x);
x.insert(this->values.begin(), this->values.end());
}
@@ -161,52 +165,7 @@ struct insert_test_rehash2 : public insert_test_rehash1<T>
}
};
template <class T>
struct insert_test_rehash3 : public insert_test_base<T>
{
typename T::size_type mutable rehash_bucket_count, original_bucket_count;
insert_test_rehash3() : insert_test_base<T>(1000) {}
T init() const {
typedef typename T::size_type size_type;
T x;
x.max_load_factor(0.25);
original_bucket_count = x.bucket_count();
rehash_bucket_count = static_cast<size_type>(
std::ceil(original_bucket_count * x.max_load_factor())) - 1;
size_type initial_elements = rehash_bucket_count - 5;
BOOST_REQUIRE(initial_elements < this->values.size());
x.insert(this->values.begin(),
boost::next(this->values.begin(), initial_elements));
BOOST_REQUIRE(original_bucket_count == x.bucket_count());
return x;
}
void run(T& x) const {
typename T::size_type bucket_count = x.bucket_count();
x.insert(boost::next(this->values.begin(), x.size()),
boost::next(this->values.begin(), x.size() + 20));
// This isn't actually a failure, but it means the test isn't doing its
// job.
BOOST_REQUIRE(x.bucket_count() != bucket_count);
}
void check(T const& x) const {
if(x.size() < rehash_bucket_count) {
//BOOST_CHECK(x.bucket_count() == original_bucket_count);
}
test::check_equivalent_keys(x);
}
};
RUN_EXCEPTION_TESTS(
(insert_test1)(insert_test2)(insert_test3)(insert_test4)
(insert_test_rehash1)(insert_test_rehash2)(insert_test_rehash3),
(insert_test_rehash1)(insert_test_rehash2),
CONTAINER_SEQ)
+1
View File
@@ -7,6 +7,7 @@
#define BOOST_UNORDERED_TEST_HELPERS_INPUT_ITERATOR_HEADER
#include <boost/iterator_adaptors.hpp>
#include <boost/shared_ptr.hpp>
namespace test
{
+1 -26
View File
@@ -18,7 +18,6 @@ namespace test
namespace minimal
{
class copy_constructible;
class copy_constructible_equality_comparable;
class default_copy_constructible;
class assignable;
template <class T> class hash;
@@ -38,29 +37,6 @@ namespace minimal
copy_constructible() {}
};
class copy_constructible_equality_comparable
{
public:
static copy_constructible_equality_comparable create() { return copy_constructible_equality_comparable(); }
copy_constructible_equality_comparable(copy_constructible_equality_comparable const&) {}
~copy_constructible_equality_comparable() {}
private:
copy_constructible_equality_comparable& operator=(copy_constructible_equality_comparable const&);
copy_constructible_equality_comparable() {}
};
bool operator==(copy_constructible_equality_comparable, copy_constructible_equality_comparable) {
return true;
}
bool operator!=(copy_constructible_equality_comparable, copy_constructible_equality_comparable) {
return false;
}
std::size_t hash_value(copy_constructible_equality_comparable) {
return 1;
}
class default_copy_constructible
{
public:
@@ -241,8 +217,7 @@ namespace minimal
size_type max_size() const { return 1000; }
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) || \
BOOST_WORKAROUND(MSVC, <= 1300)
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
public: allocator& operator=(allocator const&) { return *this;}
#else
private: allocator& operator=(allocator const&);
+1 -1
View File
@@ -27,5 +27,5 @@ test-suite unordered-tests
[ run bucket_tests.cpp ]
[ run load_factor_tests.cpp ]
[ run rehash_tests.cpp ]
[ run swap_tests.cpp : : : <define>BOOST_UNORDERED_SWAP_METHOD=2 ]
[ run swap_tests.cpp : : : <define>BOOST_UNORDERED_SWAP_METHOD=3 ]
;
-2
View File
@@ -41,10 +41,8 @@ void bucket_tests(X* = 0)
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.cbegin(i), x.cend(i)));
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.cbegin(i), x_ref.cend(i)));
}
}
-5
View File
@@ -190,11 +190,6 @@ void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq)
test::check_return_type<local_iterator>::equals(a.end(0));
test::check_return_type<const_local_iterator>::equals(b.end(0));
test::check_return_type<const_local_iterator>::equals(a.cbegin(0));
test::check_return_type<const_local_iterator>::equals(b.cbegin(0));
test::check_return_type<const_local_iterator>::equals(a.cend(0));
test::check_return_type<const_local_iterator>::equals(b.cend(0));
test::check_return_type<float>::equals(b.load_factor());
test::check_return_type<float>::equals(b.max_load_factor());
a.max_load_factor((float) 2.0);