Unordered: Fix object counts in tests.

[SVN r80417]
This commit is contained in:
Daniel James 2012-09-06 08:49:43 +00:00
parent f47f0f8d16
commit e68f0c341e
3 changed files with 16 additions and 12 deletions

View File

@ -35,11 +35,11 @@ namespace test
int* int_ptr = 0;
len += x.size();
while(x.size() < len) {
for (std::size_t i = 0; i < len; ++i) {
value_type value = generate(value_ptr);
int count = type_ == generate_collisions ?
1 + (generate(int_ptr) % 10) : 1;
1 + (generate(int_ptr) % 5) : 1;
for(int i = 0; i < count; ++i) {
x.push_back(value);
@ -64,13 +64,12 @@ namespace test
key_type* key_ptr = 0;
mapped_type* mapped_ptr = 0;
int* int_ptr = 0;
len += x.size();
while(x.size() < len) {
for (std::size_t i = 0; i < len; ++i) {
key_type key = generate(key_ptr);
int count = type_ == generate_collisions ?
1 + (generate(int_ptr) % 10) : 1;
1 + (generate(int_ptr) % 5) : 1;
for(int i = 0; i < count; ++i) {
x.push_back(std::pair<key_type const, mapped_type>(

View File

@ -158,13 +158,17 @@ namespace move_tests
BOOST_TEST(count == test::global_object_count);
#elif defined(BOOST_HAS_NRVO)
BOOST_TEST(
test::global_object_count.constructions - count.constructions <=
(test::is_set<T>::value ? 25 : 50));
static_cast<std::size_t>(test::global_object_count.constructions
- count.constructions) <=
(test::is_set<T>::value ? 1 : 2) *
(test::has_unique_keys<T>::value ? 25 : v.size()));
BOOST_TEST(count.instances == test::global_object_count.instances);
#else
BOOST_TEST(
test::global_object_count.constructions - count.constructions <=
(test::is_set<T>::value ? 50 : 100));
static_cast<std::size_t>(test::global_object_count.constructions
- count.constructions) <=
(test::is_set<T>::value ? 2 : 4) *
(test::has_unique_keys<T>::value ? 25 : v.size()));
BOOST_TEST(count.instances == test::global_object_count.instances);
#endif
test::check_container(y, v);

View File

@ -11,6 +11,7 @@
#include "../helpers/test.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp"
#include "../helpers/metafunctions.hpp"
namespace rehash_tests
{
@ -115,7 +116,7 @@ void reserve_test1(X*, test::random_generator generator)
// For the current standard this should reserve i+1, I've
// submitted a defect report and will assume it's a defect
// for now.
x.reserve(v.size());
x.reserve(test::has_unique_keys<X>::value ? i : v.size());
// Insert an element before the range insert, otherwise there are
// no iterators to invalidate in the range insert, and it can
@ -148,9 +149,9 @@ void reserve_test2(X*, test::random_generator generator)
x.max_load_factor(random_mlf ?
static_cast<float>(std::rand() % 1000) / 500.0f + 0.5f : 1.0f);
x.reserve(v.size());
std::size_t bucket_count = x.bucket_count();
x.reserve(test::has_unique_keys<X>::value ? i : v.size());
std::size_t bucket_count = x.bucket_count();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it)
{