forked from boostorg/unordered
Add insert_hint_tests
This commit is contained in:
@ -14,6 +14,7 @@
|
|||||||
#include <boost/unordered/unordered_flat_map_fwd.hpp>
|
#include <boost/unordered/unordered_flat_map_fwd.hpp>
|
||||||
|
|
||||||
#include <boost/core/allocator_access.hpp>
|
#include <boost/core/allocator_access.hpp>
|
||||||
|
#include <boost/functional/hash.hpp>
|
||||||
|
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@ -33,8 +34,7 @@ namespace boost {
|
|||||||
static Key const& extract(init_type const& kv) { return kv.first; }
|
static Key const& extract(init_type const& kv) { return kv.first; }
|
||||||
static Key const& extract(value_type const& kv) { return kv.first; }
|
static Key const& extract(value_type const& kv) { return kv.first; }
|
||||||
|
|
||||||
template<typename F>
|
template <typename F> static void move_parts_to(value_type& x, F f)
|
||||||
static void move_parts_to(value_type& x,F f)
|
|
||||||
{
|
{
|
||||||
// TODO: we probably need to launder here
|
// TODO: we probably need to launder here
|
||||||
f(std::move(const_cast<Key&>(x.first)), std::move(x.second));
|
f(std::move(const_cast<Key&>(x.first)), std::move(x.second));
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <boost/unordered/unordered_flat_set_fwd.hpp>
|
#include <boost/unordered/unordered_flat_set_fwd.hpp>
|
||||||
|
|
||||||
#include <boost/core/allocator_access.hpp>
|
#include <boost/core/allocator_access.hpp>
|
||||||
|
#include <boost/functional/hash.hpp>
|
||||||
|
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@ -32,8 +33,10 @@ namespace boost {
|
|||||||
using value_type = Key;
|
using value_type = Key;
|
||||||
static Key const& extract(value_type const& key) { return key; }
|
static Key const& extract(value_type const& key) { return key; }
|
||||||
|
|
||||||
template<typename F>
|
template <typename F> static void move_parts_to(value_type& x, F f)
|
||||||
static void move_parts_to(value_type& x,F f) { f(std::move(x)); }
|
{
|
||||||
|
f(std::move(x));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using table_type = detail::foa::table<set_types, Hash, KeyEqual,
|
using table_type = detail::foa::table<set_types, Hash, KeyEqual,
|
||||||
|
@ -107,5 +107,6 @@ build_foa copy_tests ;
|
|||||||
build_foa move_tests ;
|
build_foa move_tests ;
|
||||||
build_foa assign_tests ;
|
build_foa assign_tests ;
|
||||||
build_foa insert_tests ;
|
build_foa insert_tests ;
|
||||||
|
build_foa insert_hint_tests ;
|
||||||
build_foa erase_tests ;
|
build_foa erase_tests ;
|
||||||
build_foa find_tests ;
|
build_foa find_tests ;
|
||||||
|
@ -5,8 +5,14 @@
|
|||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#include "../helpers/prefix.hpp"
|
#include "../helpers/prefix.hpp"
|
||||||
|
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||||
|
#include <boost/unordered/detail/implementation.hpp>
|
||||||
|
#include <boost/unordered_flat_set.hpp>
|
||||||
|
#include <boost/unordered_flat_map.hpp>
|
||||||
|
#else
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
|
#endif
|
||||||
#include "../helpers/postfix.hpp"
|
#include "../helpers/postfix.hpp"
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
@ -17,6 +23,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
namespace insert_hint {
|
namespace insert_hint {
|
||||||
|
#ifndef BOOST_UNORDERED_FOA_TESTS
|
||||||
UNORDERED_AUTO_TEST (insert_hint_empty) {
|
UNORDERED_AUTO_TEST (insert_hint_empty) {
|
||||||
typedef boost::unordered_multiset<int> container;
|
typedef boost::unordered_multiset<int> container;
|
||||||
container x;
|
container x;
|
||||||
@ -90,9 +97,13 @@ namespace insert_hint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
UNORDERED_AUTO_TEST (insert_hint_unique) {
|
UNORDERED_AUTO_TEST (insert_hint_unique) {
|
||||||
|
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||||
|
typedef boost::unordered_flat_set<int> container;
|
||||||
|
#else
|
||||||
typedef boost::unordered_set<int> container;
|
typedef boost::unordered_set<int> container;
|
||||||
|
#endif
|
||||||
container x;
|
container x;
|
||||||
x.insert(x.cbegin(), 10);
|
x.insert(x.cbegin(), 10);
|
||||||
BOOST_TEST_EQ(x.size(), 1u);
|
BOOST_TEST_EQ(x.size(), 1u);
|
||||||
@ -101,7 +112,11 @@ namespace insert_hint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UNORDERED_AUTO_TEST (insert_hint_unique_single) {
|
UNORDERED_AUTO_TEST (insert_hint_unique_single) {
|
||||||
|
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||||
|
typedef boost::unordered_flat_set<int> container;
|
||||||
|
#else
|
||||||
typedef boost::unordered_set<int> container;
|
typedef boost::unordered_set<int> container;
|
||||||
|
#endif
|
||||||
container x;
|
container x;
|
||||||
x.insert(10);
|
x.insert(10);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user