mirror of
https://github.com/boostorg/unordered.git
synced 2025-05-12 14:01:43 +00:00
Unordered: Fix object counts in tests.
[SVN r80417]
This commit is contained in:
parent
f47f0f8d16
commit
e68f0c341e
@ -35,11 +35,11 @@ namespace test
|
|||||||
int* int_ptr = 0;
|
int* int_ptr = 0;
|
||||||
len += x.size();
|
len += x.size();
|
||||||
|
|
||||||
while(x.size() < len) {
|
for (std::size_t i = 0; i < len; ++i) {
|
||||||
value_type value = generate(value_ptr);
|
value_type value = generate(value_ptr);
|
||||||
|
|
||||||
int count = type_ == generate_collisions ?
|
int count = type_ == generate_collisions ?
|
||||||
1 + (generate(int_ptr) % 10) : 1;
|
1 + (generate(int_ptr) % 5) : 1;
|
||||||
|
|
||||||
for(int i = 0; i < count; ++i) {
|
for(int i = 0; i < count; ++i) {
|
||||||
x.push_back(value);
|
x.push_back(value);
|
||||||
@ -64,13 +64,12 @@ namespace test
|
|||||||
key_type* key_ptr = 0;
|
key_type* key_ptr = 0;
|
||||||
mapped_type* mapped_ptr = 0;
|
mapped_type* mapped_ptr = 0;
|
||||||
int* int_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);
|
key_type key = generate(key_ptr);
|
||||||
|
|
||||||
int count = type_ == generate_collisions ?
|
int count = type_ == generate_collisions ?
|
||||||
1 + (generate(int_ptr) % 10) : 1;
|
1 + (generate(int_ptr) % 5) : 1;
|
||||||
|
|
||||||
for(int i = 0; i < count; ++i) {
|
for(int i = 0; i < count; ++i) {
|
||||||
x.push_back(std::pair<key_type const, mapped_type>(
|
x.push_back(std::pair<key_type const, mapped_type>(
|
||||||
|
@ -158,13 +158,17 @@ namespace move_tests
|
|||||||
BOOST_TEST(count == test::global_object_count);
|
BOOST_TEST(count == test::global_object_count);
|
||||||
#elif defined(BOOST_HAS_NRVO)
|
#elif defined(BOOST_HAS_NRVO)
|
||||||
BOOST_TEST(
|
BOOST_TEST(
|
||||||
test::global_object_count.constructions - count.constructions <=
|
static_cast<std::size_t>(test::global_object_count.constructions
|
||||||
(test::is_set<T>::value ? 25 : 50));
|
- 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);
|
BOOST_TEST(count.instances == test::global_object_count.instances);
|
||||||
#else
|
#else
|
||||||
BOOST_TEST(
|
BOOST_TEST(
|
||||||
test::global_object_count.constructions - count.constructions <=
|
static_cast<std::size_t>(test::global_object_count.constructions
|
||||||
(test::is_set<T>::value ? 50 : 100));
|
- 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);
|
BOOST_TEST(count.instances == test::global_object_count.instances);
|
||||||
#endif
|
#endif
|
||||||
test::check_container(y, v);
|
test::check_container(y, v);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "../helpers/test.hpp"
|
#include "../helpers/test.hpp"
|
||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
#include "../helpers/tracker.hpp"
|
#include "../helpers/tracker.hpp"
|
||||||
|
#include "../helpers/metafunctions.hpp"
|
||||||
|
|
||||||
namespace rehash_tests
|
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
|
// For the current standard this should reserve i+1, I've
|
||||||
// submitted a defect report and will assume it's a defect
|
// submitted a defect report and will assume it's a defect
|
||||||
// for now.
|
// 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
|
// Insert an element before the range insert, otherwise there are
|
||||||
// no iterators to invalidate in the range insert, and it can
|
// 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 ?
|
x.max_load_factor(random_mlf ?
|
||||||
static_cast<float>(std::rand() % 1000) / 500.0f + 0.5f : 1.0f);
|
static_cast<float>(std::rand() % 1000) / 500.0f + 0.5f : 1.0f);
|
||||||
|
|
||||||
x.reserve(v.size());
|
x.reserve(test::has_unique_keys<X>::value ? i : v.size());
|
||||||
std::size_t bucket_count = x.bucket_count();
|
|
||||||
|
|
||||||
|
std::size_t bucket_count = x.bucket_count();
|
||||||
for (typename test::random_values<X>::iterator it = v.begin();
|
for (typename test::random_values<X>::iterator it = v.begin();
|
||||||
it != v.end(); ++it)
|
it != v.end(); ++it)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user