|
Boost-Commit : |
From: daniel_james_at_[hidden]
Date: 2007-12-09 14:24:08
Author: danieljames
Date: 2007-12-09 14:24:07 EST (Sun, 09 Dec 2007)
New Revision: 41929
URL: http://svn.boost.org/trac/boost/changeset/41929
Log:
An extra rehash test for inserting a range.
Text files modified:
sandbox/unordered/libs/unordered/test/exception/insert_tests.cpp | 53 +++++++++++++++++++++++++++++++++++----
1 files changed, 47 insertions(+), 6 deletions(-)
Modified: sandbox/unordered/libs/unordered/test/exception/insert_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/exception/insert_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/exception/insert_tests.cpp 2007-12-09 14:24:07 EST (Sun, 09 Dec 2007)
@@ -73,11 +73,7 @@
template <class T>
struct insert_test3 : public insert_test_base<T>
{
- 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);
+ void run(T& x) const {
x.insert(this->values.begin(), this->values.end());
}
@@ -165,7 +161,52 @@
}
};
+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_rehash1)(insert_test_rehash2)(insert_test_rehash3),
CONTAINER_SEQ)
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk