Clean up tests to properly use boost::unordered::piecewise_construct and ensure it's a humble alias for its std counterpart

This commit is contained in:
Christian Mazakas 2023-09-29 08:29:06 -07:00
parent 4fcc6a9cab
commit c37d9a3bf1
5 changed files with 28 additions and 25 deletions

View File

@ -295,7 +295,7 @@ struct pair_emplace_type : inserter_base
x.emplace(std::piecewise_construct, std::make_tuple(it->first),
std::make_tuple(it->second));
#else
x.emplace(std::piecewise_construct,
x.emplace(boost::unordered::piecewise_construct,
boost::make_tuple(it->first), boost::make_tuple(it->second));
#endif
}
@ -310,7 +310,7 @@ struct pair_emplace2_type : inserter_base
std::make_tuple(it->first),
std::make_tuple(it->second.tag1_, it->second.tag2_));
#else
x.emplace_hint(x.begin(), std::piecewise_construct,
x.emplace_hint(x.begin(), boost::unordered::piecewise_construct,
boost::make_tuple(it->first),
boost::make_tuple(it->second.tag1_, it->second.tag2_));
#endif

View File

@ -446,7 +446,7 @@ void unordered_map_test(X& r, Key const& k, T const& v)
#ifdef BOOST_UNORDERED_FOA_TESTS
r.emplace(std::piecewise_construct, std::make_tuple(k), std::make_tuple(v));
#else
r.emplace(std::piecewise_construct, boost::make_tuple(k),
r.emplace(boost::unordered::piecewise_construct, boost::make_tuple(k),
boost::make_tuple(v));
#endif
@ -460,7 +460,7 @@ void unordered_map_test(X& r, Key const& k, T const& v)
r.emplace_hint(r.begin(), std::piecewise_construct, std::make_tuple(k),
std::make_tuple(v));
#else
r.emplace_hint(r.begin(), std::piecewise_construct,
r.emplace_hint(r.begin(), boost::unordered::piecewise_construct,
boost::make_tuple(k), boost::make_tuple(v));
#endif

View File

@ -11,10 +11,14 @@
#include <boost/container_hash/hash.hpp>
#include <boost/tuple/tuple.hpp>
#include <string>
#include <type_traits>
// Test that various emplace methods work with different numbers of
// arguments.
BOOST_UNORDERED_STATIC_ASSERT(std::is_same<std::piecewise_construct_t,
boost::unordered::piecewise_construct_t>::value);
namespace emplace_tests {
// Constructible with 2 to 10 arguments
struct emplace_value : private test::counted_object
@ -529,7 +533,7 @@ namespace emplace_tests {
emplace_value k1(5, "", 'b', 4, 5);
emplace_value m1(8, "xxx", 'z', 4, 5, 6, 7, 8);
r1 =
x.emplace(std::piecewise_construct, boost::make_tuple(5, "", 'b', 4, 5),
x.emplace(boost::unordered::piecewise_construct, boost::make_tuple(5, "", 'b', 4, 5),
boost::make_tuple(8, "xxx", 'z', 4, 5, 6, 7, 8));
BOOST_TEST_EQ(x.size(), 1u);
BOOST_TEST(r1.second);
@ -539,7 +543,7 @@ namespace emplace_tests {
BOOST_TEST_EQ(check_.constructions(), 4);
r2 =
x.emplace(std::piecewise_construct, boost::make_tuple(5, "", 'b', 4, 5),
x.emplace(boost::unordered::piecewise_construct, boost::make_tuple(5, "", 'b', 4, 5),
boost::make_tuple(8, "xxx", 'z', 4, 5, 6, 7, 8));
BOOST_TEST_EQ(x.size(), 1u);
BOOST_TEST(!r2.second);
@ -554,7 +558,7 @@ namespace emplace_tests {
emplace_value k2(9, "", 'b', 4, 5, 6, 7, 8, 9);
emplace_value m2(3, "aaa", 'm');
r1 = x.emplace(std::piecewise_construct,
r1 = x.emplace(boost::unordered::piecewise_construct,
boost::make_tuple(9, "", 'b', 4, 5, 6, 7, 8, 9),
boost::make_tuple(3, "aaa", 'm'));
BOOST_TEST_EQ(x.size(), 2u);
@ -566,13 +570,16 @@ namespace emplace_tests {
BOOST_TEST_EQ(check_.instances(), 8);
BOOST_TEST_EQ(check_.constructions(), 10);
BOOST_TEST(r1.first == x.emplace_hint(r1.first, std::piecewise_construct,
BOOST_TEST(r1.first == x.emplace_hint(r1.first,
boost::unordered::piecewise_construct,
boost::make_tuple(9, "", 'b', 4, 5, 6, 7, 8, 9),
boost::make_tuple(15, "jkjk")));
BOOST_TEST(r1.first == x.emplace_hint(r2.first, std::piecewise_construct,
BOOST_TEST(r1.first == x.emplace_hint(r2.first,
boost::unordered::piecewise_construct,
boost::make_tuple(9, "", 'b', 4, 5, 6, 7, 8, 9),
boost::make_tuple(275, "xxx", 'm', 6)));
BOOST_TEST(r1.first == x.emplace_hint(x.end(), std::piecewise_construct,
BOOST_TEST(r1.first == x.emplace_hint(x.end(),
boost::unordered::piecewise_construct,
boost::make_tuple(9, "", 'b', 4, 5, 6, 7, 8, 9),
boost::make_tuple(-10, "blah blah", '\0')));
BOOST_TEST_EQ(x.size(), 2u);
@ -613,7 +620,7 @@ namespace emplace_tests {
emplace_value k1(5, "", 'b', 4, 5);
emplace_value m1(8, "xxx", 'z', 4, 5, 6, 7, 8);
i1 = x.emplace(std::piecewise_construct,
i1 = x.emplace(boost::unordered::piecewise_construct,
boost::make_tuple(5, "", 'b', 4, 5),
boost::make_tuple(8, "xxx", 'z', 4, 5, 6, 7, 8));
BOOST_TEST_EQ(x.size(), 1u);
@ -623,7 +630,7 @@ namespace emplace_tests {
BOOST_TEST_EQ(check_.constructions(), 4);
emplace_value m1a(8, "xxx", 'z', 4, 5, 6, 7, 8);
i2 = x.emplace(std::piecewise_construct,
i2 = x.emplace(boost::unordered::piecewise_construct,
boost::make_tuple(5, "", 'b', 4, 5),
boost::make_tuple(8, "xxx", 'z', 4, 5, 6, 7, 8));
BOOST_TEST_EQ(x.size(), 2u);
@ -637,7 +644,7 @@ namespace emplace_tests {
emplace_value k2(9, "", 'b', 4, 5, 6, 7, 8, 9);
emplace_value m2(3, "aaa", 'm');
i1 = x.emplace(std::piecewise_construct,
i1 = x.emplace(boost::unordered::piecewise_construct,
boost::make_tuple(9, "", 'b', 4, 5, 6, 7, 8, 9),
boost::make_tuple(3, "aaa", 'm'));
BOOST_TEST_EQ(x.size(), 3u);
@ -647,15 +654,15 @@ namespace emplace_tests {
BOOST_TEST_EQ(check_.constructions(), 11);
emplace_value m2a(15, "jkjk");
i2 = x.emplace_hint(i2, std::piecewise_construct,
i2 = x.emplace_hint(i2, boost::unordered::piecewise_construct,
boost::make_tuple(9, "", 'b', 4, 5, 6, 7, 8, 9),
boost::make_tuple(15, "jkjk"));
emplace_value m2b(275, "xxx", 'm', 6);
i3 = x.emplace_hint(i1, std::piecewise_construct,
i3 = x.emplace_hint(i1, boost::unordered::piecewise_construct,
boost::make_tuple(9, "", 'b', 4, 5, 6, 7, 8, 9),
boost::make_tuple(275, "xxx", 'm', 6));
emplace_value m2c(-10, "blah blah", '\0');
i4 = x.emplace_hint(x.end(), std::piecewise_construct,
i4 = x.emplace_hint(x.end(), boost::unordered::piecewise_construct,
boost::make_tuple(9, "", 'b', 4, 5, 6, 7, 8, 9),
boost::make_tuple(-10, "blah blah", '\0'));
BOOST_TEST_EQ(x.size(), 6u);

View File

@ -1323,7 +1323,7 @@ namespace insert_tests {
#endif
struct derived_from_piecewise_construct_t
: std::piecewise_construct_t
: boost::unordered::piecewise_construct_t
{
};
@ -1334,18 +1334,14 @@ namespace insert_tests {
struct convertible_to_piecewise
{
operator std::piecewise_construct_t() const
operator boost::unordered::piecewise_construct_t() const
{
return std::piecewise_construct;
return boost::unordered::piecewise_construct;
}
};
#ifndef BOOST_UNORDERED_FOA_TESTS
UNORDERED_AUTO_TEST (map_emplace_test2) {
// Emulating piecewise construction with boost::tuple bypasses the
// allocator's construct method, but still uses test destroy method.
test::detail::disable_construction_tracking _scoped;
{
boost::unordered_map<overloaded_constructor, overloaded_constructor,
boost::hash<overloaded_constructor>,

View File

@ -441,7 +441,7 @@ namespace unnecessary_copy_tests {
#endif
reset();
x.emplace(std::piecewise_construct, boost::make_tuple(),
x.emplace(boost::unordered::piecewise_construct, boost::make_tuple(),
boost::make_tuple());
COPY_COUNT(2);
MOVE_COUNT(0);
@ -508,7 +508,7 @@ namespace unnecessary_copy_tests {
MOVE_COUNT(0);
reset();
x.emplace(std::piecewise_construct,
x.emplace(boost::unordered::piecewise_construct,
boost::make_tuple(boost::ref(b.first)),
boost::make_tuple(boost::ref(b.second)));
COPY_COUNT(0);