mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 03:17:15 +02:00
Add load_factor_tests
This commit is contained in:
@ -112,4 +112,5 @@ build_foa emplace_tests ;
|
|||||||
build_foa erase_tests ;
|
build_foa erase_tests ;
|
||||||
build_foa find_tests ;
|
build_foa find_tests ;
|
||||||
build_foa at_tests ;
|
build_foa at_tests ;
|
||||||
|
build_foa load_factor_tests ;
|
||||||
build_foa rehash_tests ;
|
build_foa rehash_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/unordered_flat_map.hpp>
|
||||||
|
#include <boost/unordered/unordered_flat_set.hpp>
|
||||||
|
#include <boost/unordered/detail/implementation.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
|
||||||
|
|
||||||
@ -26,7 +32,17 @@ namespace load_factor_tests {
|
|||||||
template <class X> void set_load_factor_tests(X*)
|
template <class X> void set_load_factor_tests(X*)
|
||||||
{
|
{
|
||||||
X x;
|
X x;
|
||||||
|
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||||
|
BOOST_TEST(x.max_load_factor() == boost::unordered::detail::foa::mlf);
|
||||||
|
BOOST_TEST(x.load_factor() == 0);
|
||||||
|
|
||||||
|
// A valid implementation could fail these tests, but I think they're
|
||||||
|
// reasonable.
|
||||||
|
x.max_load_factor(2.0);
|
||||||
|
BOOST_TEST(x.max_load_factor() == boost::unordered::detail::foa::mlf);
|
||||||
|
x.max_load_factor(0.5);
|
||||||
|
BOOST_TEST(x.max_load_factor() == boost::unordered::detail::foa::mlf);
|
||||||
|
#else
|
||||||
BOOST_TEST(x.max_load_factor() == 1.0);
|
BOOST_TEST(x.max_load_factor() == 1.0);
|
||||||
BOOST_TEST(x.load_factor() == 0);
|
BOOST_TEST(x.load_factor() == 0);
|
||||||
|
|
||||||
@ -36,6 +52,7 @@ namespace load_factor_tests {
|
|||||||
BOOST_TEST(x.max_load_factor() == 2.0);
|
BOOST_TEST(x.max_load_factor() == 2.0);
|
||||||
x.max_load_factor(0.5);
|
x.max_load_factor(0.5);
|
||||||
BOOST_TEST(x.max_load_factor() == 0.5);
|
BOOST_TEST(x.max_load_factor() == 0.5);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
@ -72,21 +89,32 @@ namespace load_factor_tests {
|
|||||||
insert_test(ptr, std::numeric_limits<float>::infinity(), generator);
|
insert_test(ptr, std::numeric_limits<float>::infinity(), generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using test::default_generator;
|
||||||
|
using test::generate_collisions;
|
||||||
|
using test::limited_range;
|
||||||
|
|
||||||
|
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||||
|
boost::unordered_flat_set<int>* int_set_ptr;
|
||||||
|
boost::unordered_flat_map<int, int>* int_map_ptr;
|
||||||
|
|
||||||
|
UNORDERED_TEST(set_load_factor_tests, ((int_set_ptr)(int_map_ptr)))
|
||||||
|
|
||||||
|
UNORDERED_TEST(load_factor_insert_tests,
|
||||||
|
((int_set_ptr)(int_map_ptr))(
|
||||||
|
(default_generator)(generate_collisions)(limited_range)))
|
||||||
|
#else
|
||||||
boost::unordered_set<int>* int_set_ptr;
|
boost::unordered_set<int>* int_set_ptr;
|
||||||
boost::unordered_multiset<int>* int_multiset_ptr;
|
boost::unordered_multiset<int>* int_multiset_ptr;
|
||||||
boost::unordered_map<int, int>* int_map_ptr;
|
boost::unordered_map<int, int>* int_map_ptr;
|
||||||
boost::unordered_multimap<int, int>* int_multimap_ptr;
|
boost::unordered_multimap<int, int>* int_multimap_ptr;
|
||||||
|
|
||||||
using test::default_generator;
|
|
||||||
using test::generate_collisions;
|
|
||||||
using test::limited_range;
|
|
||||||
|
|
||||||
UNORDERED_TEST(set_load_factor_tests,
|
UNORDERED_TEST(set_load_factor_tests,
|
||||||
((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr)))
|
((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr)))
|
||||||
|
|
||||||
UNORDERED_TEST(load_factor_insert_tests,
|
UNORDERED_TEST(load_factor_insert_tests,
|
||||||
((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr))(
|
((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr))(
|
||||||
(default_generator)(generate_collisions)(limited_range)))
|
(default_generator)(generate_collisions)(limited_range)))
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
RUN_TESTS()
|
RUN_TESTS()
|
||||||
|
Reference in New Issue
Block a user