From 4ac3dcc90c360fdb56c48d2d1582787996ed2cd4 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Thu, 1 Dec 2022 14:31:19 -0800 Subject: [PATCH] Update assign_exception_tests to assert strong guarantee around Hash, KeyEqual pairing --- test/exception/assign_exception_tests.cpp | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/exception/assign_exception_tests.cpp b/test/exception/assign_exception_tests.cpp index c036da52..e96e8465 100644 --- a/test/exception/assign_exception_tests.cpp +++ b/test/exception/assign_exception_tests.cpp @@ -60,6 +60,9 @@ template struct assign_base : public test::exception_base test::random_values x_values, y_values; T x, y; + int t1; + int t2; + typedef typename T::hasher hasher; typedef typename T::key_equal key_equal; typedef typename T::allocator_type allocator_type; @@ -67,7 +70,10 @@ template struct assign_base : public test::exception_base assign_base(int tag1, int tag2, float mlf1 = 1.0, float mlf2 = 1.0) : x_values(), y_values(), 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); y.max_load_factor(mlf2); @@ -89,6 +95,22 @@ template struct assign_base : public test::exception_base { 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 // internal structure is hidden, this exposes it, at the cost of // messing up the data.