mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 03:17:15 +02:00
Add forwarding tests
This commit is contained in:
@ -22,9 +22,28 @@ namespace boost {
|
|||||||
class KeyEqual = std::equal_to<Key>,
|
class KeyEqual = std::equal_to<Key>,
|
||||||
class Allocator = std::allocator<std::pair<const Key, T> > >
|
class Allocator = std::allocator<std::pair<const Key, T> > >
|
||||||
class unordered_flat_map;
|
class unordered_flat_map;
|
||||||
}
|
|
||||||
|
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
|
||||||
|
bool operator==(
|
||||||
|
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& lhs,
|
||||||
|
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& rhs);
|
||||||
|
|
||||||
|
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
|
||||||
|
bool operator!=(
|
||||||
|
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& lhs,
|
||||||
|
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& rhs);
|
||||||
|
|
||||||
|
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
|
||||||
|
void swap(unordered_flat_map<Key, T, Hash, KeyEqual, Allocator>& lhs,
|
||||||
|
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator>& rhs)
|
||||||
|
noexcept(noexcept(lhs.swap(rhs)));
|
||||||
|
} // namespace unordered
|
||||||
|
|
||||||
using boost::unordered::unordered_flat_map;
|
using boost::unordered::unordered_flat_map;
|
||||||
|
|
||||||
|
using boost::unordered::swap;
|
||||||
|
using boost::unordered::operator==;
|
||||||
|
using boost::unordered::operator!=;
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,9 +22,28 @@ namespace boost {
|
|||||||
class KeyEqual = std::equal_to<Key>,
|
class KeyEqual = std::equal_to<Key>,
|
||||||
class Allocator = std::allocator<Key> >
|
class Allocator = std::allocator<Key> >
|
||||||
class unordered_flat_set;
|
class unordered_flat_set;
|
||||||
}
|
|
||||||
|
template <class Key, class Hash, class KeyEqual, class Allocator>
|
||||||
|
bool operator==(
|
||||||
|
unordered_flat_set<Key, Hash, KeyEqual, Allocator> const& lhs,
|
||||||
|
unordered_flat_set<Key, Hash, KeyEqual, Allocator> const& rhs);
|
||||||
|
|
||||||
|
template <class Key, class Hash, class KeyEqual, class Allocator>
|
||||||
|
bool operator!=(
|
||||||
|
unordered_flat_set<Key, Hash, KeyEqual, Allocator> const& lhs,
|
||||||
|
unordered_flat_set<Key, Hash, KeyEqual, Allocator> const& rhs);
|
||||||
|
|
||||||
|
template <class Key, class Hash, class KeyEqual, class Allocator>
|
||||||
|
void swap(unordered_flat_set<Key, Hash, KeyEqual, Allocator>& lhs,
|
||||||
|
unordered_flat_set<Key, Hash, KeyEqual, Allocator>& rhs)
|
||||||
|
noexcept(noexcept(lhs.swap(rhs)));
|
||||||
|
} // namespace unordered
|
||||||
|
|
||||||
using boost::unordered::unordered_flat_set;
|
using boost::unordered::unordered_flat_set;
|
||||||
|
|
||||||
|
using boost::unordered::swap;
|
||||||
|
using boost::unordered::operator==;
|
||||||
|
using boost::unordered::operator!=;
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -102,6 +102,8 @@ rule build_foa ( name )
|
|||||||
run unordered/$(name).cpp : : : <cxxstd>98:<build>no <cxxstd>03:<build>no <cxxstd>0x:<build>no <define>BOOST_UNORDERED_FOA_TESTS : foa_$(name) ;
|
run unordered/$(name).cpp : : : <cxxstd>98:<build>no <cxxstd>03:<build>no <cxxstd>0x:<build>no <define>BOOST_UNORDERED_FOA_TESTS : foa_$(name) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
build_foa fwd_set_test ;
|
||||||
|
build_foa fwd_map_test ;
|
||||||
build_foa constructor_tests ;
|
build_foa constructor_tests ;
|
||||||
build_foa copy_tests ;
|
build_foa copy_tests ;
|
||||||
build_foa move_tests ;
|
build_foa move_tests ;
|
||||||
|
@ -5,10 +5,39 @@
|
|||||||
|
|
||||||
// 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_fwd.hpp>
|
||||||
|
#include <boost/unordered/detail/implementation.hpp>
|
||||||
|
#else
|
||||||
#include <boost/unordered/unordered_map_fwd.hpp>
|
#include <boost/unordered/unordered_map_fwd.hpp>
|
||||||
|
#endif
|
||||||
#include "../helpers/postfix.hpp"
|
#include "../helpers/postfix.hpp"
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||||
|
template <typename T>
|
||||||
|
void call_swap(
|
||||||
|
boost::unordered_flat_map<T, T>& x, boost::unordered_flat_map<T, T>& y)
|
||||||
|
{
|
||||||
|
swap(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool call_equals(
|
||||||
|
boost::unordered_flat_map<T, T>& x, boost::unordered_flat_map<T, T>& y)
|
||||||
|
{
|
||||||
|
return x == y;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool call_not_equals(
|
||||||
|
boost::unordered_flat_map<T, T>& x, boost::unordered_flat_map<T, T>& y)
|
||||||
|
{
|
||||||
|
return x != y;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <boost/unordered/unordered_flat_map.hpp>
|
||||||
|
#else
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void call_swap(boost::unordered_map<T, T>& x, boost::unordered_map<T, T>& y)
|
void call_swap(boost::unordered_map<T, T>& x, boost::unordered_map<T, T>& y)
|
||||||
{
|
{
|
||||||
@ -50,10 +79,15 @@ bool call_not_equals(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
|
#endif
|
||||||
#include "../helpers/test.hpp"
|
#include "../helpers/test.hpp"
|
||||||
|
|
||||||
|
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||||
|
typedef boost::unordered_flat_map<int, int> int_map;
|
||||||
|
#else
|
||||||
typedef boost::unordered_map<int, int> int_map;
|
typedef boost::unordered_map<int, int> int_map;
|
||||||
typedef boost::unordered_multimap<int, int> int_multimap;
|
typedef boost::unordered_multimap<int, int> int_multimap;
|
||||||
|
#endif
|
||||||
|
|
||||||
UNORDERED_AUTO_TEST (use_map_fwd_declared_function) {
|
UNORDERED_AUTO_TEST (use_map_fwd_declared_function) {
|
||||||
int_map x, y;
|
int_map x, y;
|
||||||
@ -71,11 +105,13 @@ UNORDERED_AUTO_TEST (use_map_fwd_declared_function) {
|
|||||||
BOOST_TEST(call_not_equals(x, y));
|
BOOST_TEST(call_not_equals(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef BOOST_UNORDERED_FOA_TESTS
|
||||||
UNORDERED_AUTO_TEST (use_multimap_fwd_declared_function) {
|
UNORDERED_AUTO_TEST (use_multimap_fwd_declared_function) {
|
||||||
int_multimap x, y;
|
int_multimap x, y;
|
||||||
call_swap(x, y);
|
call_swap(x, y);
|
||||||
BOOST_TEST(call_equals(x, y));
|
BOOST_TEST(call_equals(x, y));
|
||||||
BOOST_TEST(!call_not_equals(x, y));
|
BOOST_TEST(!call_not_equals(x, y));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
RUN_TESTS()
|
RUN_TESTS()
|
||||||
|
@ -5,7 +5,12 @@
|
|||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#include "../helpers/prefix.hpp"
|
#include "../helpers/prefix.hpp"
|
||||||
|
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||||
|
#include <boost/unordered/unordered_flat_set_fwd.hpp>
|
||||||
|
#include <boost/unordered/detail/implementation.hpp>
|
||||||
|
#else
|
||||||
#include <boost/unordered/unordered_set_fwd.hpp>
|
#include <boost/unordered/unordered_set_fwd.hpp>
|
||||||
|
#endif
|
||||||
#include "../helpers/postfix.hpp"
|
#include "../helpers/postfix.hpp"
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
@ -20,6 +25,31 @@ struct false_type
|
|||||||
|
|
||||||
false_type is_unordered_set_impl(void*);
|
false_type is_unordered_set_impl(void*);
|
||||||
|
|
||||||
|
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||||
|
template <class Value, class Hash, class Pred, class Alloc>
|
||||||
|
true_type is_unordered_set_impl(
|
||||||
|
boost::unordered_flat_set<Value, Hash, Pred, Alloc>*);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void call_swap(boost::unordered_flat_set<T>& x, boost::unordered_flat_set<T>& y)
|
||||||
|
{
|
||||||
|
swap(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool call_equals(
|
||||||
|
boost::unordered_flat_set<T>& x, boost::unordered_flat_set<T>& y)
|
||||||
|
{
|
||||||
|
return x == y;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool call_not_equals(
|
||||||
|
boost::unordered_flat_set<T>& x, boost::unordered_flat_set<T>& y)
|
||||||
|
{
|
||||||
|
return x != y;
|
||||||
|
}
|
||||||
|
#else
|
||||||
template <class Value, class Hash, class Pred, class Alloc>
|
template <class Value, class Hash, class Pred, class Alloc>
|
||||||
true_type is_unordered_set_impl(
|
true_type is_unordered_set_impl(
|
||||||
boost::unordered_set<Value, Hash, Pred, Alloc>*);
|
boost::unordered_set<Value, Hash, Pred, Alloc>*);
|
||||||
@ -41,7 +71,9 @@ bool call_not_equals(boost::unordered_set<T>& x, boost::unordered_set<T>& y)
|
|||||||
{
|
{
|
||||||
return x != y;
|
return x != y;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BOOST_UNORDERED_FOA_TESTS
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void call_swap(boost::unordered_multiset<T>& x, boost::unordered_multiset<T>& y)
|
void call_swap(boost::unordered_multiset<T>& x, boost::unordered_multiset<T>& y)
|
||||||
{
|
{
|
||||||
@ -61,20 +93,29 @@ bool call_not_equals(
|
|||||||
{
|
{
|
||||||
return x != y;
|
return x != y;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../helpers/test.hpp"
|
#include "../helpers/test.hpp"
|
||||||
|
|
||||||
|
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||||
|
typedef boost::unordered_flat_set<int> int_set;
|
||||||
|
#else
|
||||||
typedef boost::unordered_set<int> int_set;
|
typedef boost::unordered_set<int> int_set;
|
||||||
typedef boost::unordered_multiset<int> int_multiset;
|
typedef boost::unordered_multiset<int> int_multiset;
|
||||||
|
#endif
|
||||||
|
|
||||||
UNORDERED_AUTO_TEST (use_fwd_declared_trait_without_definition) {
|
UNORDERED_AUTO_TEST (use_fwd_declared_trait_without_definition) {
|
||||||
BOOST_TEST(sizeof(is_unordered_set_impl((int_set*)0)) == sizeof(true_type));
|
BOOST_TEST(sizeof(is_unordered_set_impl((int_set*)0)) == sizeof(true_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||||
|
#include <boost/unordered_flat_set.hpp>
|
||||||
|
#else
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
UNORDERED_AUTO_TEST (use_fwd_declared_trait) {
|
UNORDERED_AUTO_TEST (use_fwd_declared_trait) {
|
||||||
boost::unordered_set<int> x;
|
int_set x;
|
||||||
BOOST_TEST(sizeof(is_unordered_set_impl(&x)) == sizeof(true_type));
|
BOOST_TEST(sizeof(is_unordered_set_impl(&x)) == sizeof(true_type));
|
||||||
|
|
||||||
BOOST_TEST(sizeof(is_unordered_set_impl((int*)0)) == sizeof(false_type));
|
BOOST_TEST(sizeof(is_unordered_set_impl((int*)0)) == sizeof(false_type));
|
||||||
@ -96,11 +137,13 @@ UNORDERED_AUTO_TEST (use_set_fwd_declared_function) {
|
|||||||
BOOST_TEST(call_not_equals(x, y));
|
BOOST_TEST(call_not_equals(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef BOOST_UNORDERED_FOA_TESTS
|
||||||
UNORDERED_AUTO_TEST (use_multiset_fwd_declared_function) {
|
UNORDERED_AUTO_TEST (use_multiset_fwd_declared_function) {
|
||||||
int_multiset x, y;
|
int_multiset x, y;
|
||||||
call_swap(x, y);
|
call_swap(x, y);
|
||||||
BOOST_TEST(call_equals(x, y));
|
BOOST_TEST(call_equals(x, y));
|
||||||
BOOST_TEST(!call_not_equals(x, y));
|
BOOST_TEST(!call_not_equals(x, y));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
RUN_TESTS()
|
RUN_TESTS()
|
||||||
|
Reference in New Issue
Block a user