Remember to disable exceptions before checking final value

This commit is contained in:
Daniel James
2017-05-05 00:46:07 +01:00
parent 47a8c3fc67
commit 6ef17a0f0e
8 changed files with 58 additions and 9 deletions

View File

@ -3595,8 +3595,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
n2->set_first_in_group();
}
--other.size_;
other.fix_bucket(
other.node_bucket(n), prev, n2);
other.fix_bucket(other.node_bucket(n), prev, n2);
this->add_node_unique(n, key_hash);
}
}
@ -4274,7 +4273,8 @@ inline void table<Types>::rehash_impl(std::size_t num_buckets)
}
}
}
BOOST_CATCH(...) {
BOOST_CATCH(...)
{
delete_nodes(prev, node_pointer());
BOOST_RETHROW
}

View File

@ -23,8 +23,11 @@ template <class T> struct self_assign_base : public test::exception_base
typedef T data_type;
T init() const { return T(values.begin(), values.end()); }
void run(T& x) const {
void run(T& x) const
{
x = x;
DISABLE_EXCEPTIONS;
test::check_container(x, values);
test::check_equivalent_keys(x);
}
@ -65,8 +68,11 @@ template <class T> struct assign_base : public test::exception_base
typedef T data_type;
T init() const { return T(x); }
void run(T& x1) const {
void run(T& x1) const
{
x1 = y;
DISABLE_EXCEPTIONS;
test::check_container(x1, y_values);
test::check_equivalent_keys(x1);
}

View File

@ -6,8 +6,8 @@
#include "./containers.hpp"
#include "../helpers/input_iterator.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/invariants.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp"
template <typename T> inline void avoid_unused_warning(T const&) {}
@ -27,6 +27,8 @@ template <class T> struct construct_test1 : public objects, test::exception_base
void run() const
{
T x;
DISABLE_EXCEPTIONS;
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
@ -37,6 +39,8 @@ template <class T> struct construct_test2 : public objects, test::exception_base
void run() const
{
T x(300);
DISABLE_EXCEPTIONS;
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
@ -47,6 +51,8 @@ template <class T> struct construct_test3 : public objects, test::exception_base
void run() const
{
T x(0, hash);
DISABLE_EXCEPTIONS;
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
@ -57,6 +63,8 @@ template <class T> struct construct_test4 : public objects, test::exception_base
void run() const
{
T x(0, hash, equal_to);
DISABLE_EXCEPTIONS;
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
@ -67,6 +75,8 @@ template <class T> struct construct_test5 : public objects, test::exception_base
void run() const
{
T x(50, hash, equal_to, allocator);
DISABLE_EXCEPTIONS;
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
@ -77,6 +87,8 @@ template <class T> struct construct_test6 : public objects, test::exception_base
void run() const
{
T x(allocator);
DISABLE_EXCEPTIONS;
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
@ -95,6 +107,8 @@ template <class T> struct range_construct_test1 : public range<T>, objects
void run() const
{
T x(this->values.begin(), this->values.end());
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
@ -105,6 +119,8 @@ template <class T> struct range_construct_test2 : public range<T>, objects
void run() const
{
T x(this->values.begin(), this->values.end(), 0);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
@ -115,6 +131,8 @@ template <class T> struct range_construct_test3 : public range<T>, objects
void run() const
{
T x(this->values.begin(), this->values.end(), 0, hash);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
@ -125,6 +143,8 @@ template <class T> struct range_construct_test4 : public range<T>, objects
void run() const
{
T x(this->values.begin(), this->values.end(), 100, hash, equal_to);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
@ -140,6 +160,8 @@ template <class T> struct range_construct_test5 : public range<T>, objects
{
T x(this->values.begin(), this->values.end(), 0, hash, equal_to,
allocator);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
@ -156,6 +178,8 @@ template <class T> struct input_range_construct_test : public range<T>, objects
end = this->values.end();
T x(test::input_iterator(begin), test::input_iterator(end), 0, hash,
equal_to, allocator);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
@ -170,6 +194,8 @@ template <class T> struct copy_range_construct_test : public range<T>, objects
T x(test::copy_iterator(this->values.begin()),
test::copy_iterator(this->values.end()), 0, hash, equal_to,
allocator);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}

View File

@ -5,8 +5,8 @@
#include "./containers.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/invariants.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp"
template <typename T> inline void avoid_unused_warning(T const&) {}
@ -20,6 +20,8 @@ template <class T> struct copy_test1 : public test::exception_base
void run() const
{
T y(x);
DISABLE_EXCEPTIONS;
BOOST_TEST(y.empty());
test::check_equivalent_keys(y);
}
@ -35,6 +37,8 @@ template <class T> struct copy_test2 : public test::exception_base
void run() const
{
T y(x);
DISABLE_EXCEPTIONS;
test::check_container(y, this->values);
test::check_equivalent_keys(y);
}
@ -50,6 +54,8 @@ template <class T> struct copy_test3 : public test::exception_base
void run() const
{
T y(x);
DISABLE_EXCEPTIONS;
test::check_container(y, this->values);
test::check_equivalent_keys(y);
}
@ -66,6 +72,8 @@ template <class T> struct copy_with_allocator_test : public test::exception_base
void run() const
{
T y(x, allocator);
DISABLE_EXCEPTIONS;
test::check_container(y, this->values);
test::check_equivalent_keys(y);
}

View File

@ -44,8 +44,9 @@ template <class T> struct erase_by_key_test1 : public erase_test_base<T>
x.erase(test::get_key<T>(*it));
}
DISABLE_EXCEPTIONS;
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
test::check_equivalent_keys(x);
}
};

View File

@ -44,6 +44,7 @@ template <class T> struct move_assign_base : public test::exception_base
disable_exceptions.release();
x1 = boost::move(y1);
DISABLE_EXCEPTIONS;
test::check_container(x1, y_values);
test::check_equivalent_keys(x1);
}

View File

@ -53,6 +53,7 @@ template <class T> struct rehash_test0 : rehash_test_base<T>
void run(T& x) const
{
x.rehash(0);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
@ -65,6 +66,7 @@ template <class T> struct rehash_test1 : rehash_test_base<T>
void run(T& x) const
{
x.rehash(200);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
@ -77,6 +79,7 @@ template <class T> struct rehash_test2 : rehash_test_base<T>
void run(T& x) const
{
x.rehash(0);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
@ -89,6 +92,7 @@ template <class T> struct rehash_test3 : rehash_test_base<T>
void run(T& x) const
{
x.rehash(200);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
@ -101,6 +105,7 @@ template <class T> struct rehash_test4 : rehash_test_base<T>
void run(T& x) const
{
x.rehash(0);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);
@ -113,6 +118,7 @@ template <class T> struct rehash_test5 : rehash_test_base<T>
void run(T& x) const
{
x.rehash(0);
DISABLE_EXCEPTIONS;
test::check_container(x, this->values);
test::check_equivalent_keys(x);

View File

@ -23,7 +23,8 @@ template <class T> struct self_swap_base : public test::exception_base
typedef T data_type;
T init() const { return T(values.begin(), values.end()); }
void run(T& x) const {
void run(T& x) const
{
x.swap(x);
DISABLE_EXCEPTIONS;