$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r56559 - in trunk/libs/unordered/test: exception helpers
From: daniel_james_at_[hidden]
Date: 2009-10-03 12:41:12
Author: danieljames
Date: 2009-10-03 12:41:11 EDT (Sat, 03 Oct 2009)
New Revision: 56559
URL: http://svn.boost.org/trac/boost/changeset/56559
Log:
Stricter insert exception tests.
Text files modified: 
   trunk/libs/unordered/test/exception/insert_exception_tests.cpp |    14 +++++++-------                          
   trunk/libs/unordered/test/helpers/strong.hpp                   |     8 ++++++--                                
   2 files changed, 13 insertions(+), 9 deletions(-)
Modified: trunk/libs/unordered/test/exception/insert_exception_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/exception/insert_exception_tests.cpp	(original)
+++ trunk/libs/unordered/test/exception/insert_exception_tests.cpp	2009-10-03 12:41:11 EDT (Sat, 03 Oct 2009)
@@ -31,7 +31,7 @@
         std::string scope(test::scope);
 
         if(scope.find("hash::operator()") == std::string::npos)
-            strong.test(x);
+            strong.test(x, test::exception::detail::tracker.count_allocations);
         test::check_equivalent_keys(x);
     }
 };
@@ -47,7 +47,7 @@
         for(BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
                 it = this->values.begin(), end = this->values.end(); it != end; ++it)
         {
-            strong.store(x);
+            strong.store(x, test::exception::detail::tracker.count_allocations);
             x.emplace(*it);
         }
     }
@@ -64,7 +64,7 @@
         for(BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
                 it = this->values.begin(), end = this->values.end(); it != end; ++it)
         {
-            strong.store(x);
+            strong.store(x, test::exception::detail::tracker.count_allocations);
             x.insert(*it);
         }
     }
@@ -79,7 +79,7 @@
         for(BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
                 it = this->values.begin(), end = this->values.end(); it != end; ++it)
         {
-            strong.store(x);
+            strong.store(x, test::exception::detail::tracker.count_allocations);
             x.insert(x.begin(), *it);
         }
     }
@@ -106,7 +106,7 @@
         for(BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
                 it = this->values.begin(), end = this->values.end(); it != end; ++it)
         {
-            strong.store(x);
+            strong.store(x, test::exception::detail::tracker.count_allocations);
             x.insert(it, boost::next(it));
         }
     }
@@ -144,7 +144,7 @@
             it = boost::next(this->values.begin(), x.size()), end = this->values.end();
             it != end && count < 10; ++it, ++count)
         {
-            strong.store(x);
+            strong.store(x, test::exception::detail::tracker.count_allocations);
             pos = x.insert(pos, *it);
         }
 
@@ -167,7 +167,7 @@
             it = boost::next(this->values.begin(), x.size()), end = this->values.end();
             it != end && count < 10; ++it, ++count)
         {
-            strong.store(x);
+            strong.store(x, test::exception::detail::tracker.count_allocations);
             x.insert(*it);
         }
 
Modified: trunk/libs/unordered/test/helpers/strong.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/strong.hpp	(original)
+++ trunk/libs/unordered/test/helpers/strong.hpp	2009-10-03 12:41:11 EDT (Sat, 03 Oct 2009)
@@ -20,18 +20,22 @@
     {
         typedef test::list<BOOST_DEDUCED_TYPENAME X::value_type> values_type;
         values_type values_;
+        unsigned int allocations_;
     public:
-        void store(X const& x) {
+        void store(X const& x, unsigned int allocations = 0) {
             DISABLE_EXCEPTIONS;
             values_.clear();
             values_.insert(x.cbegin(), x.cend());
+            allocations_ = allocations;
         }
 
-        void test(X const& x) const {
+        void test(X const& x, unsigned int allocations = 0) const {
             if(!(x.size() == values_.size() &&
                     std::equal(x.cbegin(), x.cend(), values_.begin(),
                         test::equivalent)))
                 BOOST_ERROR("Strong exception safety failure.");
+            if(allocations != allocations_)
+                BOOST_ERROR("Strong exception failure: extra allocations.");
         }
     };
 }