forked from boostorg/unordered
Loosen restrictions on erase exceptions tests to accomodate runs where there are no successful erasures
This commit is contained in:
@ -118,8 +118,6 @@ namespace {
|
|||||||
{
|
{
|
||||||
using value_type = typename X::value_type;
|
using value_type = typename X::value_type;
|
||||||
|
|
||||||
std::atomic<std::uint64_t> num_erased{0};
|
|
||||||
|
|
||||||
auto const old_size = x.size();
|
auto const old_size = x.size();
|
||||||
|
|
||||||
auto const old_dc = +raii::default_constructor;
|
auto const old_dc = +raii::default_constructor;
|
||||||
@ -145,29 +143,24 @@ namespace {
|
|||||||
});
|
});
|
||||||
|
|
||||||
enable_exceptions();
|
enable_exceptions();
|
||||||
thread_runner(
|
thread_runner(values, [&x, threshold](boost::span<T> /* s */) {
|
||||||
values, [&num_erased, &x, threshold](boost::span<T> /* s */) {
|
for (std::size_t i = 0; i < 256; ++i) {
|
||||||
for (std::size_t i = 0; i < 256; ++i) {
|
try {
|
||||||
try {
|
x.erase_if([threshold](value_type& v) {
|
||||||
auto count = x.erase_if([threshold](value_type& v) {
|
static std::atomic<std::uint32_t> c{0};
|
||||||
static std::atomic<std::uint32_t> c{0};
|
auto t = ++c;
|
||||||
auto t = ++c;
|
if (should_throw && (t % throw_threshold == 0)) {
|
||||||
if (should_throw && (t % throw_threshold == 0)) {
|
throw exception_tag{};
|
||||||
throw exception_tag{};
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return v.second.x_ > threshold;
|
return v.second.x_ > threshold;
|
||||||
});
|
});
|
||||||
|
} catch (...) {
|
||||||
num_erased += count;
|
|
||||||
} catch (...) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
disable_exceptions();
|
disable_exceptions();
|
||||||
|
|
||||||
BOOST_TEST_GT(num_erased, 0u);
|
|
||||||
|
|
||||||
BOOST_TEST_EQ(raii::default_constructor, old_dc);
|
BOOST_TEST_EQ(raii::default_constructor, old_dc);
|
||||||
BOOST_TEST_EQ(raii::copy_constructor, old_cc);
|
BOOST_TEST_EQ(raii::copy_constructor, old_cc);
|
||||||
BOOST_TEST_EQ(raii::move_constructor, old_mc);
|
BOOST_TEST_EQ(raii::move_constructor, old_mc);
|
||||||
@ -182,8 +175,6 @@ namespace {
|
|||||||
{
|
{
|
||||||
using value_type = typename X::value_type;
|
using value_type = typename X::value_type;
|
||||||
|
|
||||||
std::atomic<std::uint64_t> num_erased{0};
|
|
||||||
|
|
||||||
auto const old_size = x.size();
|
auto const old_size = x.size();
|
||||||
|
|
||||||
auto const old_dc = +raii::default_constructor;
|
auto const old_dc = +raii::default_constructor;
|
||||||
@ -201,39 +192,26 @@ namespace {
|
|||||||
|
|
||||||
auto threshold = max / 2;
|
auto threshold = max / 2;
|
||||||
|
|
||||||
auto expected_erasures = 0u;
|
enable_exceptions();
|
||||||
x.visit_all([&expected_erasures, threshold](value_type const& v) {
|
thread_runner(values, [&x, threshold](boost::span<T> /* s */) {
|
||||||
if (v.second.x_ > threshold) {
|
for (std::size_t i = 0; i < 256; ++i) {
|
||||||
++expected_erasures;
|
try {
|
||||||
|
boost::unordered::erase_if(x, [threshold](value_type& v) {
|
||||||
|
static std::atomic<std::uint32_t> c{0};
|
||||||
|
auto t = ++c;
|
||||||
|
if (should_throw && (t % throw_threshold == 0)) {
|
||||||
|
throw exception_tag{};
|
||||||
|
}
|
||||||
|
|
||||||
|
return v.second.x_ > threshold;
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (...) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
enable_exceptions();
|
|
||||||
thread_runner(
|
|
||||||
values, [&num_erased, &x, threshold](boost::span<T> /* s */) {
|
|
||||||
for (std::size_t i = 0; i < 256; ++i) {
|
|
||||||
try {
|
|
||||||
auto count =
|
|
||||||
boost::unordered::erase_if(x, [threshold](value_type& v) {
|
|
||||||
static std::atomic<std::uint32_t> c{0};
|
|
||||||
auto t = ++c;
|
|
||||||
if (should_throw && (t % throw_threshold == 0)) {
|
|
||||||
throw exception_tag{};
|
|
||||||
}
|
|
||||||
|
|
||||||
return v.second.x_ > threshold;
|
|
||||||
});
|
|
||||||
|
|
||||||
num_erased += count;
|
|
||||||
} catch (...) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
disable_exceptions();
|
disable_exceptions();
|
||||||
|
|
||||||
BOOST_TEST_GT(num_erased, 0u);
|
|
||||||
BOOST_TEST_LE(num_erased, expected_erasures);
|
|
||||||
|
|
||||||
BOOST_TEST_EQ(raii::default_constructor, old_dc);
|
BOOST_TEST_EQ(raii::default_constructor, old_dc);
|
||||||
BOOST_TEST_EQ(raii::copy_constructor, old_cc);
|
BOOST_TEST_EQ(raii::copy_constructor, old_cc);
|
||||||
BOOST_TEST_EQ(raii::move_constructor, old_mc);
|
BOOST_TEST_EQ(raii::move_constructor, old_mc);
|
||||||
|
Reference in New Issue
Block a user