Add node-based foa containers to simple_tests

This commit is contained in:
Christian Mazakas
2023-01-25 10:49:12 -08:00
parent 8ac6019d30
commit c85dd289f9

View File

@ -1,6 +1,6 @@
// Copyright 2006-2009 Daniel James.
// Copyright 2022 Christian Mazakas.
// Copyright 2022-2023 Christian Mazakas.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -8,10 +8,13 @@
#include "../helpers/unordered.hpp"
#include "../helpers/test.hpp"
#include <cstdlib>
#include <algorithm>
#include "../helpers/equivalent.hpp"
#include "../helpers/generators.hpp"
#include "../helpers/test.hpp"
#include <algorithm>
#include <cstdlib>
test::seed_t initialize_seed(14878);
template <class X> void simple_test(X const& a)
{
@ -84,26 +87,22 @@ template <class X> void simple_test(X const& a)
}
}
UNORDERED_AUTO_TEST (simple_tests) {
using namespace std;
srand(14878);
template <class X> static void simple_set_tests(X*)
{
X set;
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Test unordered_set.\n";
#ifdef BOOST_UNORDERED_FOA_TESTS
boost::unordered_flat_set<int> set;
#else
boost::unordered_set<int> set;
#endif
simple_test(set);
set.insert(1);
set.insert(2);
set.insert(1456);
simple_test(set);
}
#ifndef BOOST_UNORDERED_FOA_TESTS
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Test unordered_multiset.\n";
boost::unordered_multiset<int> multiset;
template <class X> static void simple_multiset_tests(X*)
{
X multiset;
simple_test(multiset);
for (int i1 = 0; i1 < 1000; ++i1) {
@ -112,23 +111,23 @@ UNORDERED_AUTO_TEST (simple_tests) {
multiset.insert(index);
}
simple_test(multiset);
}
#endif
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Test unordered_map.\n";
#ifdef BOOST_UNORDERED_FOA_TESTS
boost::unordered_flat_map<int, int> map;
#else
boost::unordered_map<int, int> map;
#endif
template <class X> static void simple_map_tests(X*)
{
X map;
for (int i2 = 0; i2 < 1000; ++i2) {
map.insert(std::pair<const int, int>(rand(), rand()));
}
simple_test(map);
}
#ifndef BOOST_UNORDERED_FOA_TESTS
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Test unordered_multimap.\n";
boost::unordered_multimap<int, int> multimap;
template <class X> static void simple_multimap_tests(X*)
{
X multimap;
for (int i3 = 0; i3 < 1000; ++i3) {
int count = rand() % 10, index = rand();
@ -136,7 +135,28 @@ UNORDERED_AUTO_TEST (simple_tests) {
multimap.insert(std::pair<const int, int>(index, rand()));
}
simple_test(multimap);
#endif
}
#endif
#ifdef BOOST_UNORDERED_FOA_TESTS
static boost::unordered_flat_set<int>* flat_set;
static boost::unordered_flat_map<int, int>* flat_map;
static boost::unordered_node_set<int>* node_set;
static boost::unordered_node_map<int, int>* node_map;
UNORDERED_TEST(simple_map_tests, ((flat_map)(node_map)))
UNORDERED_TEST(simple_set_tests, ((flat_set)(node_set)))
#else
static boost::unordered_set<int>* set;
static boost::unordered_map<int, int>* map;
static boost::unordered_multiset<int>* multiset;
static boost::unordered_multimap<int, int>* multimap;
UNORDERED_TEST(simple_set_tests, ((set)))
UNORDERED_TEST(simple_map_tests, ((map)))
UNORDERED_TEST(simple_multiset_tests, ((multiset)))
UNORDERED_TEST(simple_multimap_tests, ((multimap)))
#endif
RUN_TESTS()