Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80417 - in trunk/libs/unordered/test: helpers unordered
From: dnljms_at_[hidden]
Date: 2012-09-06 04:49:44


Author: danieljames
Date: 2012-09-06 04:49:43 EDT (Thu, 06 Sep 2012)
New Revision: 80417
URL: http://svn.boost.org/trac/boost/changeset/80417

Log:
Unordered: Fix object counts in tests.
Text files modified:
   trunk/libs/unordered/test/helpers/random_values.hpp | 9 ++++-----
   trunk/libs/unordered/test/unordered/move_tests.cpp | 12 ++++++++----
   trunk/libs/unordered/test/unordered/rehash_tests.cpp | 7 ++++---
   3 files changed, 16 insertions(+), 12 deletions(-)

Modified: trunk/libs/unordered/test/helpers/random_values.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/random_values.hpp (original)
+++ trunk/libs/unordered/test/helpers/random_values.hpp 2012-09-06 04:49:43 EDT (Thu, 06 Sep 2012)
@@ -35,11 +35,11 @@
             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 @@
             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>(

Modified: trunk/libs/unordered/test/unordered/move_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/move_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/move_tests.cpp 2012-09-06 04:49:43 EDT (Thu, 06 Sep 2012)
@@ -158,13 +158,17 @@
             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);

Modified: trunk/libs/unordered/test/unordered/rehash_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/rehash_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/rehash_tests.cpp 2012-09-06 04:49:43 EDT (Thu, 06 Sep 2012)
@@ -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 @@
             // 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 @@
             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)
             {


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