Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80226 - trunk/libs/unordered/test/helpers
From: dnljms_at_[hidden]
Date: 2012-08-25 17:55:19


Author: danieljames
Date: 2012-08-25 17:55:18 EDT (Sat, 25 Aug 2012)
New Revision: 80226
URL: http://svn.boost.org/trac/boost/changeset/80226

Log:
Unordered: More invariant testing.

In case there are elements in buckets that aren't in the element list. Required
because the data structure has changed since the original implementation.
Text files modified:
   trunk/libs/unordered/test/helpers/invariants.hpp | 25 ++++++++++++++++++++++++-
   1 files changed, 24 insertions(+), 1 deletions(-)

Modified: trunk/libs/unordered/test/helpers/invariants.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/invariants.hpp (original)
+++ trunk/libs/unordered/test/helpers/invariants.hpp 2012-08-25 17:55:18 EDT (Sat, 25 Aug 2012)
@@ -82,16 +82,39 @@
             }
         };
 
- // Finally, check that size matches up.
+ // Check that size matches up.
+
         if(x1.size() != size) {
             BOOST_ERROR("x1.size() doesn't match actual size.");
             std::cout<<x1.size()<<"/"<<size<<std::endl;
         }
+
+ // Check the load factor.
+
         float load_factor =
             static_cast<float>(size) / static_cast<float>(x1.bucket_count());
         using namespace std;
         if(fabs(x1.load_factor() - load_factor) > x1.load_factor() / 64)
             BOOST_ERROR("x1.load_factor() doesn't match actual load_factor.");
+
+ // Check that size in the buckets matches up.
+
+ BOOST_DEDUCED_TYPENAME X::size_type bucket_size = 0;
+
+ for (BOOST_DEDUCED_TYPENAME X::size_type
+ i = 0; i < x1.bucket_count(); ++i)
+ {
+ for (BOOST_DEDUCED_TYPENAME X::const_local_iterator
+ begin = x1.begin(i), end = x1.end(i); begin != end; ++begin)
+ {
+ ++bucket_size;
+ }
+ }
+
+ if(x1.size() != bucket_size) {
+ BOOST_ERROR("x1.size() doesn't match bucket size.");
+ std::cout<<x1.size()<<"/"<<bucket_size<<std::endl;
+ }
     }
 }
 


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