diff --git a/test/exception/insert_exception_tests.cpp b/test/exception/insert_exception_tests.cpp index acb47b48..cf7d04e0 100644 --- a/test/exception/insert_exception_tests.cpp +++ b/test/exception/insert_exception_tests.cpp @@ -31,7 +31,7 @@ struct insert_test_base : public test::exception_base 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 @@ struct emplace_test1 : public insert_test_base for(BOOST_DEDUCED_TYPENAME test::random_values::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 @@ struct insert_test1 : public insert_test_base for(BOOST_DEDUCED_TYPENAME test::random_values::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 @@ struct insert_test2 : public insert_test_base for(BOOST_DEDUCED_TYPENAME test::random_values::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 @@ struct insert_test4 : public insert_test_base for(BOOST_DEDUCED_TYPENAME test::random_values::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 @@ struct insert_test_rehash1 : public insert_test_base 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 @@ struct insert_test_rehash2 : public insert_test_rehash1 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); } diff --git a/test/helpers/strong.hpp b/test/helpers/strong.hpp index 4ffcca2b..a297fe07 100644 --- a/test/helpers/strong.hpp +++ b/test/helpers/strong.hpp @@ -20,18 +20,22 @@ namespace test { typedef test::list 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."); } }; }