mirror of
https://github.com/boostorg/unordered.git
synced 2025-10-04 19:51:01 +02:00
Merge the latest unordered changes. These are concerned with getting the tests
working on more compilers. The biggest change is that the exception tests have been changed to use a very simple exception testing mechanism on top of lightweight_test. This was because Boost.Test exception testing isn't working on several platforms. I'm trying to set this up so that I can use Boost.Test on compilers which it completely supports, and lightweight test on others. Boost.Test tests more than my simple exception testing code ever will so it's worth using where I can. [SVN r42698]
This commit is contained in:
@@ -4,16 +4,12 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "./containers.hpp"
|
||||
|
||||
#define BOOST_TEST_MAIN
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/exception_safety.hpp>
|
||||
#include <string>
|
||||
#include "../helpers/random_values.hpp"
|
||||
#include "../helpers/invariants.hpp"
|
||||
#include "../helpers/strong.hpp"
|
||||
#include "../helpers/input_iterator.hpp"
|
||||
|
||||
#include <boost/utility.hpp>
|
||||
#include <cmath>
|
||||
|
||||
test::seed_t seed(747373);
|
||||
@@ -105,17 +101,18 @@ struct insert_test_rehash1 : public insert_test_base<T>
|
||||
insert_test_rehash1() : insert_test_base<T>(1000) {}
|
||||
|
||||
T init() const {
|
||||
using namespace std;
|
||||
typedef BOOST_DEDUCED_TYPENAME T::size_type size_type;
|
||||
|
||||
T x;
|
||||
x.max_load_factor(0.25);
|
||||
size_type bucket_count = x.bucket_count();
|
||||
size_type initial_elements = static_cast<size_type>(
|
||||
std::ceil(bucket_count * x.max_load_factor()) - 1);
|
||||
BOOST_REQUIRE(initial_elements < this->values.size());
|
||||
ceil(bucket_count * (double) x.max_load_factor()) - 1);
|
||||
UNORDERED_REQUIRE(initial_elements < this->values.size());
|
||||
x.insert(this->values.begin(),
|
||||
boost::next(this->values.begin(), initial_elements));
|
||||
BOOST_REQUIRE(bucket_count == x.bucket_count());
|
||||
UNORDERED_REQUIRE(bucket_count == x.bucket_count());
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -134,7 +131,7 @@ struct insert_test_rehash1 : public insert_test_base<T>
|
||||
|
||||
// This isn't actually a failure, but it means the test isn't doing its
|
||||
// job.
|
||||
BOOST_REQUIRE(x.bucket_count() != bucket_count);
|
||||
UNORDERED_REQUIRE(x.bucket_count() != bucket_count);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -157,7 +154,7 @@ struct insert_test_rehash2 : public insert_test_rehash1<T>
|
||||
|
||||
// This isn't actually a failure, but it means the test isn't doing its
|
||||
// job.
|
||||
BOOST_REQUIRE(x.bucket_count() != bucket_count);
|
||||
UNORDERED_REQUIRE(x.bucket_count() != bucket_count);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -169,6 +166,7 @@ struct insert_test_rehash3 : public insert_test_base<T>
|
||||
insert_test_rehash3() : insert_test_base<T>(1000) {}
|
||||
|
||||
T init() const {
|
||||
using namespace std;
|
||||
typedef BOOST_DEDUCED_TYPENAME T::size_type size_type;
|
||||
|
||||
T x;
|
||||
@@ -176,14 +174,14 @@ struct insert_test_rehash3 : public insert_test_base<T>
|
||||
|
||||
original_bucket_count = x.bucket_count();
|
||||
rehash_bucket_count = static_cast<size_type>(
|
||||
std::ceil(original_bucket_count * x.max_load_factor())) - 1;
|
||||
ceil(original_bucket_count * (double) x.max_load_factor())) - 1;
|
||||
|
||||
size_type initial_elements = rehash_bucket_count - 5;
|
||||
|
||||
BOOST_REQUIRE(initial_elements < this->values.size());
|
||||
UNORDERED_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());
|
||||
UNORDERED_REQUIRE(original_bucket_count == x.bucket_count());
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -195,7 +193,7 @@ struct insert_test_rehash3 : public insert_test_base<T>
|
||||
|
||||
// This isn't actually a failure, but it means the test isn't doing its
|
||||
// job.
|
||||
BOOST_REQUIRE(x.bucket_count() != bucket_count);
|
||||
UNORDERED_REQUIRE(x.bucket_count() != bucket_count);
|
||||
}
|
||||
|
||||
void check(T const& x) const {
|
||||
|
Reference in New Issue
Block a user