mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 03:17:15 +02:00
Add strong exception guarantees around Hash, KeyEqual for move_assign_exception_tests
This commit is contained in:
@ -20,6 +20,7 @@ template <class T> struct move_assign_base : public test::exception_base
|
|||||||
{
|
{
|
||||||
test::random_values<T> x_values, y_values;
|
test::random_values<T> x_values, y_values;
|
||||||
T x, y;
|
T x, y;
|
||||||
|
int t1, t2;
|
||||||
|
|
||||||
typedef typename T::hasher hasher;
|
typedef typename T::hasher hasher;
|
||||||
typedef typename T::key_equal key_equal;
|
typedef typename T::key_equal key_equal;
|
||||||
@ -28,7 +29,9 @@ template <class T> struct move_assign_base : public test::exception_base
|
|||||||
move_assign_base(int tag1, int tag2, float mlf1 = 1.0, float mlf2 = 1.0)
|
move_assign_base(int tag1, int tag2, float mlf1 = 1.0, float mlf2 = 1.0)
|
||||||
: x_values(), y_values(),
|
: x_values(), y_values(),
|
||||||
x(0, hasher(tag1), key_equal(tag1), allocator_type(tag1)),
|
x(0, hasher(tag1), key_equal(tag1), allocator_type(tag1)),
|
||||||
y(0, hasher(tag2), key_equal(tag2), allocator_type(tag2))
|
y(0, hasher(tag2), key_equal(tag2), allocator_type(tag2)),
|
||||||
|
t1(tag1),
|
||||||
|
t2(tag2)
|
||||||
{
|
{
|
||||||
x.max_load_factor(mlf1);
|
x.max_load_factor(mlf1);
|
||||||
y.max_load_factor(mlf2);
|
y.max_load_factor(mlf2);
|
||||||
@ -52,6 +55,22 @@ template <class T> struct move_assign_base : public test::exception_base
|
|||||||
{
|
{
|
||||||
test::check_equivalent_keys(x1);
|
test::check_equivalent_keys(x1);
|
||||||
|
|
||||||
|
if (x1.hash_function() == hasher(t1)) {
|
||||||
|
BOOST_TEST(x1.key_eq() == key_equal(t1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x1.hash_function() == hasher(t2)) {
|
||||||
|
BOOST_TEST(x1.key_eq() == key_equal(t2));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x1.key_eq() == key_equal(t1)) {
|
||||||
|
BOOST_TEST(x1.hash_function() == hasher(t1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x1.key_eq() == key_equal(t2)) {
|
||||||
|
BOOST_TEST(x1.hash_function() == hasher(t2));
|
||||||
|
}
|
||||||
|
|
||||||
// If the container is empty at the point of the exception, the
|
// If the container is empty at the point of the exception, the
|
||||||
// internal structure is hidden, this exposes it, at the cost of
|
// internal structure is hidden, this exposes it, at the cost of
|
||||||
// messing up the data.
|
// messing up the data.
|
||||||
|
Reference in New Issue
Block a user