diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index fa593e24..4d9b4a8e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -141,4 +141,5 @@ run exception/move_assign_exception_tests.cpp : : : 98:no 98:no 03:no 0x:no BOOST_UNORDERED_FOA_TESTS : foa_insert_exception_tests ; run exception/erase_exception_tests.cpp : : : 98:no 03:no 0x:no BOOST_UNORDERED_FOA_TESTS : foa_erase_exception_tests ; run exception/rehash_exception_tests.cpp : : : 98:no 03:no 0x:no BOOST_UNORDERED_FOA_TESTS : foa_rehash_exception_tests ; +run exception/swap_exception_tests.cpp : : : 98:no 03:no 0x:no BOOST_UNORDERED_FOA_TESTS : foa_swap_exception_tests ; run exception/merge_exception_tests.cpp : : : 98:no 03:no 0x:no BOOST_UNORDERED_FOA_TESTS : foa_merge_exception_tests ; diff --git a/test/exception/swap_exception_tests.cpp b/test/exception/swap_exception_tests.cpp index 1569e814..2745ede5 100644 --- a/test/exception/swap_exception_tests.cpp +++ b/test/exception/swap_exception_tests.cpp @@ -5,6 +5,10 @@ #include "./containers.hpp" +#if defined(BOOST_UNORDERED_FOA_TESTS) +#define BOOST_UNORDERED_FOA_WEAK_GUARANTEE_SWAP_EXCEPTIONS_TESTS +#endif + #include "../helpers/invariants.hpp" #include "../helpers/random_values.hpp" #include "../helpers/tracker.hpp" diff --git a/test/helpers/invariants.hpp b/test/helpers/invariants.hpp index 3a4ddedf..849fe983 100644 --- a/test/helpers/invariants.hpp +++ b/test/helpers/invariants.hpp @@ -53,10 +53,20 @@ namespace test { if (test::has_unique_keys::value && count != 1) BOOST_ERROR("Non-unique key."); +#if !defined(BOOST_UNORDERED_FOA_WEAK_GUARANTEE_SWAP_EXCEPTIONS_TESTS) + // we conditionally compile this check because our FOA implementation only + // exhibits the weak guarantee when swapping throws + // + // in this case, the hasher may be changed before the predicate and the + // arrays are swapped in which case, we can can find an element by + // iteration but unfortunately, it's in the wrong slot according to the + // new hash function so count(key) can wind up returning nothing when + // there really is something if (x1.count(key) != count) { BOOST_ERROR("Incorrect output of count."); std::cerr << x1.count(key) << "," << count << "\n"; } +#endif #ifndef BOOST_UNORDERED_FOA_TESTS // Check that the keys are in the correct bucket and are