Add equivalent_keys_tests

This commit is contained in:
Christian Mazakas
2022-10-13 11:59:44 -07:00
parent 7339f4264a
commit d538f6184c
2 changed files with 17 additions and 1 deletions

View File

@ -110,6 +110,7 @@ build_foa noexcept_tests ;
run unordered/link_test_1.cpp unordered/link_test_2.cpp : : : <cxxstd>98:<build>no <cxxstd>03:<build>no <cxxstd>0x:<build>no <define>BOOST_UNORDERED_FOA_TESTS : foa_link_test ; run unordered/link_test_1.cpp unordered/link_test_2.cpp : : : <cxxstd>98:<build>no <cxxstd>03:<build>no <cxxstd>0x:<build>no <define>BOOST_UNORDERED_FOA_TESTS : foa_link_test ;
build_foa incomplete_test ; build_foa incomplete_test ;
build_foa simple_tests ; build_foa simple_tests ;
build_foa equivalent_keys_tests ;
build_foa constructor_tests ; build_foa constructor_tests ;
build_foa copy_tests ; build_foa copy_tests ;
build_foa move_tests ; build_foa move_tests ;

View File

@ -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_flat_set.hpp>
#include <boost/unordered_flat_map.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
@ -38,8 +44,11 @@ void test_equal_insertion(Iterator begin, Iterator end)
UNORDERED_AUTO_TEST (set_tests) { UNORDERED_AUTO_TEST (set_tests) {
int values[][5] = {{1}, {54, 23}, {-13, 65}, {77, 77}, {986, 25, 986}}; int values[][5] = {{1}, {54, 23}, {-13, 65}, {77, 77}, {986, 25, 986}};
#ifdef BOOST_UNORDERED_FOA_TESTS
typedef boost::unordered_flat_set<int> set;
#else
typedef boost::unordered_set<int> set; typedef boost::unordered_set<int> set;
typedef boost::unordered_multiset<int> multiset; #endif
test_equal_insertion<set>(values[0], values[0] + 1); test_equal_insertion<set>(values[0], values[0] + 1);
test_equal_insertion<set>(values[1], values[1] + 2); test_equal_insertion<set>(values[1], values[1] + 2);
@ -47,6 +56,7 @@ UNORDERED_AUTO_TEST (set_tests) {
test_equal_insertion<set>(values[3], values[3] + 2); test_equal_insertion<set>(values[3], values[3] + 2);
test_equal_insertion<set>(values[4], values[4] + 3); test_equal_insertion<set>(values[4], values[4] + 3);
typedef boost::unordered_multiset<int> multiset;
test_equal_insertion<multiset>(values[0], values[0] + 1); test_equal_insertion<multiset>(values[0], values[0] + 1);
test_equal_insertion<multiset>(values[1], values[1] + 2); test_equal_insertion<multiset>(values[1], values[1] + 2);
test_equal_insertion<multiset>(values[2], values[2] + 2); test_equal_insertion<multiset>(values[2], values[2] + 2);
@ -66,12 +76,17 @@ UNORDERED_AUTO_TEST (map_tests) {
v[2].push_back(std::pair<int const, int>(432, 24)); v[2].push_back(std::pair<int const, int>(432, 24));
for (int i = 0; i < 5; ++i) for (int i = 0; i < 5; ++i)
#ifdef BOOST_UNORDERED_FOA_TESTS
test_equal_insertion<boost::unordered_flat_map<int, int> >(
v[i].begin(), v[i].end());
#else
test_equal_insertion<boost::unordered_map<int, int> >( test_equal_insertion<boost::unordered_map<int, int> >(
v[i].begin(), v[i].end()); v[i].begin(), v[i].end());
for (int i2 = 0; i2 < 5; ++i2) for (int i2 = 0; i2 < 5; ++i2)
test_equal_insertion<boost::unordered_multimap<int, int> >( test_equal_insertion<boost::unordered_multimap<int, int> >(
v[i2].begin(), v[i2].end()); v[i2].begin(), v[i2].end());
#endif
} }
RUN_TESTS() RUN_TESTS()