Update insert_tests to handle new open-addressing table implementation

This commit is contained in:
Christian Mazakas
2022-09-26 15:17:54 -07:00
parent 12b9bd0a6d
commit 505b060637
3 changed files with 23 additions and 0 deletions

View File

@ -5,6 +5,9 @@
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
import testing ;
import ../../config/checks/config : requires ;
CPP14 = [ requires cxx14 ] ;
# Adding -Wundef is blocked on (at least)
# https://github.com/boostorg/type_traits/issues/165
@ -49,6 +52,7 @@ run unordered/copy_tests.cpp ;
run unordered/move_tests.cpp ;
run unordered/assign_tests.cpp ;
run unordered/insert_tests.cpp ;
run unordered/insert_tests.cpp : : : $(CPP14) <define>BOOST_UNORDERED_FOA_TESTS : foa_insert_tests ;
run unordered/insert_stable_tests.cpp ;
run unordered/insert_hint_tests.cpp ;
run unordered/emplace_tests.cpp ;

View File

@ -58,6 +58,7 @@ namespace test {
std::cerr << x1.count(key) << "," << count << "\n";
}
#ifndef BOOST_UNORDERED_FOA_TESTS
// Check that the keys are in the correct bucket and are
// adjacent in the bucket.
typename X::size_type bucket = x1.bucket(key);
@ -86,6 +87,7 @@ namespace test {
}
}
}
#endif
};
// Check that size matches up.
@ -104,6 +106,7 @@ namespace test {
if (fabs(x1.load_factor() - load_factor) > x1.load_factor() / 64)
BOOST_ERROR("x1.load_factor() doesn't match actual load_factor.");
#ifndef BOOST_UNORDERED_FOA_TESTS
// Check that size in the buckets matches up.
typename X::size_type bucket_size = 0;
@ -120,6 +123,7 @@ namespace test {
BOOST_ERROR("x1.size() doesn't match bucket size.");
std::cout << x1.size() << "/" << bucket_size << std::endl;
}
#endif
}
}

View File

@ -12,6 +12,10 @@
#include "../helpers/postfix.hpp"
// clang-format on
#ifdef BOOST_UNORDERED_FOA_TESTS
#include <boost/unordered/unordered_flat_map.hpp>
#endif
#include "../helpers/test.hpp"
#include "../objects/test.hpp"
#include "../helpers/random_values.hpp"
@ -884,13 +888,24 @@ namespace insert_tests {
boost::unordered_multimap<test::object, test::object, test::hash,
test::equal_to, test::allocator1<test::object> >* test_multimap;
#ifdef BOOST_UNORDERED_FOA_TESTS
boost::unordered::unordered_flat_map<test::movable, test::movable, test::hash,
test::equal_to, test::allocator2<test::movable> >* test_flat_map;
#endif
using test::default_generator;
using test::generate_collisions;
using test::limited_range;
#ifdef BOOST_UNORDERED_FOA_TESTS
UNORDERED_TEST(unique_insert_tests1,
((test_set_std_alloc)(test_set)(test_map)(test_flat_map))(
(default_generator)(generate_collisions)(limited_range)))
#else
UNORDERED_TEST(unique_insert_tests1,
((test_set_std_alloc)(test_set)(test_map))(
(default_generator)(generate_collisions)(limited_range)))
#endif
UNORDERED_TEST(equivalent_insert_tests1,
((test_multimap_std_alloc)(test_multiset)(test_multimap))(