mirror of
https://github.com/boostorg/unordered.git
synced 2025-05-11 13:34:06 +00:00
Merge new changes to unordered & hash.
- Unordered tests can run lightweight test or Boost.Test (at least theoretically). - Workaround Open BSD's incorrect numeric_limits. - Move the hash extensions in their own file. - Various small improvements to the unordered docs. - Fix some unordered examples. Merged revisions 43117-43837 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk [SVN r43838]
This commit is contained in:
parent
535a41a2f5
commit
e07e7e889d
@ -12,4 +12,15 @@ boostbook standalone : unordered :
|
|||||||
<xsl:param>chunk.section.depth=2
|
<xsl:param>chunk.section.depth=2
|
||||||
<xsl:param>generate.section.toc.level=2
|
<xsl:param>generate.section.toc.level=2
|
||||||
<xsl:param>toc.section.depth=1
|
<xsl:param>toc.section.depth=1
|
||||||
<xsl:param>toc.max.depth=1 ;
|
<xsl:param>toc.max.depth=1
|
||||||
|
|
||||||
|
<dependency>css
|
||||||
|
<dependency>images
|
||||||
|
;
|
||||||
|
|
||||||
|
install css : [ glob $(BOOST_ROOT)/doc/src/*.css ]
|
||||||
|
: <location>html ;
|
||||||
|
install images : [ glob $(BOOST_ROOT)/doc/src/images/*.png ]
|
||||||
|
: <location>html/images ;
|
||||||
|
explicit css ;
|
||||||
|
explicit images ;
|
||||||
|
@ -83,7 +83,7 @@
|
|||||||
]
|
]
|
||||||
[
|
[
|
||||||
[`erase` never throws an exception]
|
[`erase` never throws an exception]
|
||||||
[The containers hash or predicate function can throw exceptions
|
[The containers' hash or predicate function can throw exceptions
|
||||||
from `erase`]
|
from `erase`]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -6,32 +6,35 @@
|
|||||||
|
|
||||||
While the associative containers use an ordering relation to specify how the
|
While the associative containers use an ordering relation to specify how the
|
||||||
elements are stored, the unordered associative containers use an equality
|
elements are stored, the unordered associative containers use an equality
|
||||||
predicate and a hash function. For example, [classref boost::unordered_set]
|
predicate and a hash function. For example, [classref boost::unordered_map]
|
||||||
is declared as:
|
is declared as:
|
||||||
|
|
||||||
template<typename Value,
|
template <
|
||||||
typename Hash = ``[classref boost::hash]``<Value>,
|
class Key, class Mapped,
|
||||||
typename Pred = std::equal_to<Value>,
|
class Hash = ``[classref boost::hash]``<Key>,
|
||||||
typename Alloc = std::allocator<Value> >
|
class Pred = std::equal_to<Key>,
|
||||||
class ``[classref boost::unordered_set unordered_set]``;
|
class Alloc = std::allocator<Key> >
|
||||||
|
class ``[classref boost::unordered_map unordered_map]``;
|
||||||
|
|
||||||
The hash function comes first as you might want to change the hash function
|
The hash function comes first as you might want to change the hash function
|
||||||
but not the equality predicate, while if you were to change the behavior
|
but not the equality predicate. For example, if you wanted to use the
|
||||||
of the equality predicate you would have to change the hash function to match
|
|
||||||
it. So, if you wanted to use the
|
|
||||||
[@http://www.isthe.com/chongo/tech/comp/fnv/ FNV-1 hash] you could write:
|
[@http://www.isthe.com/chongo/tech/comp/fnv/ FNV-1 hash] you could write:
|
||||||
|
|
||||||
``[classref boost::unordered_set]``<std::string, hash::fnv_1> words;
|
[import src_code/dictionary.cpp]
|
||||||
|
[case_sensitive_dictionary_fnv]
|
||||||
|
|
||||||
An example implementation of FNV-1, and some other hash functions are supplied
|
An example implementation of FNV-1, and some other hash functions are supplied
|
||||||
in the examples directory.
|
in the examples directory.
|
||||||
|
|
||||||
Alternatively, you might wish to use a different equality function. If you do
|
If you wish to use a different equality function,
|
||||||
this you will need to use a hash function that matches it. So to implement a
|
you will also need to use a matching hash function. For
|
||||||
case-insensitive dictionary:
|
example, to implement a case insensitive dictionary you need to define a
|
||||||
|
case insensitive equality predicate and hash function:
|
||||||
|
|
||||||
[import src_code/insensitive.cpp]
|
|
||||||
[case_insensitive_functions]
|
[case_insensitive_functions]
|
||||||
|
|
||||||
|
Which you can then use in a case insensitive dictionary:
|
||||||
|
|
||||||
[case_insensitive_dictionary]
|
[case_insensitive_dictionary]
|
||||||
|
|
||||||
This is a simplified version of the example at
|
This is a simplified version of the example at
|
||||||
@ -45,8 +48,9 @@ Similarly, a custom hash function can be used for custom types:
|
|||||||
[import src_code/point1.cpp]
|
[import src_code/point1.cpp]
|
||||||
[point_example1]
|
[point_example1]
|
||||||
|
|
||||||
Although, [link hash.custom extending boost::hash to support the type] is
|
Since the default hash function is [link hash Boost.Hash],
|
||||||
probably a better solution:
|
we can [link hash.custom extend it to support the type]
|
||||||
|
so that the hash function doesn't need to be explicitly given:
|
||||||
|
|
||||||
[import src_code/point2.cpp]
|
[import src_code/point2.cpp]
|
||||||
[point_example2]
|
[point_example2]
|
||||||
|
@ -84,32 +84,18 @@ When using Boost.TR1, these classes are included from `<unordered_set>` and
|
|||||||
The containers are used in a similar manner to the normal associative
|
The containers are used in a similar manner to the normal associative
|
||||||
containers:
|
containers:
|
||||||
|
|
||||||
#include <``[headerref boost/unordered_map.hpp]``>
|
[import src_code/intro.cpp]
|
||||||
#include <cassert>
|
[intro_example1_2]
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
boost::unordered_map<std::string, int> x;
|
|
||||||
x["one"] = 1;
|
|
||||||
x["two"] = 2;
|
|
||||||
x["three"] = 3;
|
|
||||||
|
|
||||||
assert(x["one"] == 1);
|
|
||||||
assert(x["missing"] == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
But since the elements aren't ordered, the output of:
|
But since the elements aren't ordered, the output of:
|
||||||
|
|
||||||
BOOST_FOREACH(map::value_type i, x) {
|
[intro_example1_3]
|
||||||
std::cout<<i.first<<","<<i.second<<"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
can be in any order. For example, it might be:
|
can be in any order. For example, it might be:
|
||||||
|
|
||||||
two,2
|
two,2
|
||||||
one,1
|
one,1
|
||||||
three,3
|
three,3
|
||||||
missing,0
|
|
||||||
|
|
||||||
To store an object in an unordered associative container requires both an
|
To store an object in an unordered associative container requires both an
|
||||||
key equality function and a hash function. The default function objects in
|
key equality function and a hash function. The default function objects in
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
N2345, 'Placement Insert for Containers']]
|
N2345, 'Placement Insert for Containers']]
|
||||||
[def __n2369__
|
[def __n2369__
|
||||||
[@http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2007/n2369.pdf
|
[@http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2007/n2369.pdf
|
||||||
the August 2008 version of the working draft standard]]
|
the August 2007 version of the working draft standard]]
|
||||||
|
|
||||||
[section:rationale Implementation Rationale]
|
[section:rationale Implementation Rationale]
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
|
#include "../../examples/hash_functions/fnv-1.hpp"
|
||||||
|
|
||||||
//[case_insensitive_functions
|
//[case_insensitive_functions
|
||||||
struct iequal_to
|
struct iequal_to
|
||||||
@ -35,45 +36,68 @@
|
|||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct word_info;
|
|
||||||
//]
|
//]
|
||||||
|
|
||||||
struct word_info {
|
|
||||||
int tag;
|
|
||||||
explicit word_info(int t = 0) : tag(t) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
//[case_sensitive_dictionary_fnv
|
||||||
|
boost::unordered_map<std::string, int, hash::fnv_1>
|
||||||
|
dictionary;
|
||||||
|
//]
|
||||||
|
|
||||||
|
BOOST_TEST(dictionary.empty());
|
||||||
|
|
||||||
|
dictionary["one"] = 1;
|
||||||
|
BOOST_TEST(dictionary.size() == 1);
|
||||||
|
BOOST_TEST(dictionary.find("ONE") == dictionary.end());
|
||||||
|
|
||||||
|
dictionary.insert(std::make_pair("ONE", 2));
|
||||||
|
BOOST_TEST(dictionary.size() == 2);
|
||||||
|
BOOST_TEST(dictionary.find("ONE") != dictionary.end() &&
|
||||||
|
dictionary.find("ONE")->first == "ONE" &&
|
||||||
|
dictionary.find("ONE")->second == 2);
|
||||||
|
|
||||||
|
dictionary["One"] = 3;
|
||||||
|
BOOST_TEST(dictionary.size() == 3);
|
||||||
|
BOOST_TEST(dictionary.find("One") != dictionary.end() &&
|
||||||
|
dictionary.find("One")->first == "One" &&
|
||||||
|
dictionary.find("One")->second == 3);
|
||||||
|
|
||||||
|
dictionary["two"] = 4;
|
||||||
|
BOOST_TEST(dictionary.size() == 4);
|
||||||
|
BOOST_TEST(dictionary.find("Two") == dictionary.end() &&
|
||||||
|
dictionary.find("two") != dictionary.end() &&
|
||||||
|
dictionary.find("two")->second == 4);
|
||||||
|
|
||||||
|
|
||||||
//[case_insensitive_dictionary
|
//[case_insensitive_dictionary
|
||||||
boost::unordered_map<std::string, word_info, ihash, iequal_to>
|
boost::unordered_map<std::string, int, ihash, iequal_to>
|
||||||
idictionary;
|
idictionary;
|
||||||
//]
|
//]
|
||||||
|
|
||||||
BOOST_TEST(idictionary.empty());
|
BOOST_TEST(idictionary.empty());
|
||||||
|
|
||||||
idictionary["one"] = word_info(1);
|
idictionary["one"] = 1;
|
||||||
BOOST_TEST(idictionary.size() == 1);
|
BOOST_TEST(idictionary.size() == 1);
|
||||||
BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
|
BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
|
||||||
idictionary.find("ONE") == idictionary.find("one"));
|
idictionary.find("ONE") == idictionary.find("one"));
|
||||||
|
|
||||||
idictionary.insert(std::make_pair("ONE", word_info(2)));
|
idictionary.insert(std::make_pair("ONE", 2));
|
||||||
BOOST_TEST(idictionary.size() == 1);
|
BOOST_TEST(idictionary.size() == 1);
|
||||||
BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
|
BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
|
||||||
idictionary.find("ONE")->first == "one" &&
|
idictionary.find("ONE")->first == "one" &&
|
||||||
idictionary.find("ONE")->second.tag == 1);
|
idictionary.find("ONE")->second == 1);
|
||||||
|
|
||||||
idictionary["One"] = word_info(3);
|
idictionary["One"] = 3;
|
||||||
BOOST_TEST(idictionary.size() == 1);
|
BOOST_TEST(idictionary.size() == 1);
|
||||||
BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
|
BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
|
||||||
idictionary.find("ONE")->first == "one" &&
|
idictionary.find("ONE")->first == "one" &&
|
||||||
idictionary.find("ONE")->second.tag == 3);
|
idictionary.find("ONE")->second == 3);
|
||||||
|
|
||||||
idictionary["two"] = word_info(4);
|
idictionary["two"] = 4;
|
||||||
BOOST_TEST(idictionary.size() == 2);
|
BOOST_TEST(idictionary.size() == 2);
|
||||||
BOOST_TEST(idictionary.find("two") != idictionary.end() &&
|
BOOST_TEST(idictionary.find("two") != idictionary.end() &&
|
||||||
idictionary.find("TWO")->first == "two" &&
|
idictionary.find("TWO")->first == "two" &&
|
||||||
idictionary.find("Two")->second.tag == 4);
|
idictionary.find("Two")->second == 4);
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
30
doc/src_code/intro.cpp
Normal file
30
doc/src_code/intro.cpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
// Copyright 2006-2008 Daniel James.
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
//[intro_example1_1
|
||||||
|
#include <boost/unordered_map.hpp>
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
#include <cassert>
|
||||||
|
#include <iostream>
|
||||||
|
//]
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
//[intro_example1_2
|
||||||
|
typedef boost::unordered_map<std::string, int> map;
|
||||||
|
map x;
|
||||||
|
x["one"] = 1;
|
||||||
|
x["two"] = 2;
|
||||||
|
x["three"] = 3;
|
||||||
|
|
||||||
|
assert(x.at("one") == 1);
|
||||||
|
assert(x.find("missing") == x.end());
|
||||||
|
//]
|
||||||
|
|
||||||
|
//[intro_example1_3
|
||||||
|
BOOST_FOREACH(map::value_type i, x) {
|
||||||
|
std::cout<<i.first<<","<<i.second<<"\n";
|
||||||
|
}
|
||||||
|
//]
|
||||||
|
}
|
@ -29,8 +29,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
boost::unordered_multiset<point, point_hash, std::equal_to<point> >
|
boost::unordered_multiset<point, point_hash> points;
|
||||||
points;
|
|
||||||
//]
|
//]
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
@ -7,7 +7,7 @@ namespace hash
|
|||||||
template <std::size_t FnvPrime, std::size_t OffsetBias>
|
template <std::size_t FnvPrime, std::size_t OffsetBias>
|
||||||
struct basic_fnv_1
|
struct basic_fnv_1
|
||||||
{
|
{
|
||||||
std::size_t operator()(std::string const& text)
|
std::size_t operator()(std::string const& text) const
|
||||||
{
|
{
|
||||||
std::size_t hash = OffsetBias;
|
std::size_t hash = OffsetBias;
|
||||||
for(std::string::const_iterator it = text.begin(), end = text.end();
|
for(std::string::const_iterator it = text.begin(), end = text.end();
|
||||||
@ -24,7 +24,7 @@ namespace hash
|
|||||||
template <std::size_t FnvPrime, std::size_t OffsetBias>
|
template <std::size_t FnvPrime, std::size_t OffsetBias>
|
||||||
struct basic_fnv_1a
|
struct basic_fnv_1a
|
||||||
{
|
{
|
||||||
std::size_t operator()(std::string const& text)
|
std::size_t operator()(std::string const& text) const
|
||||||
{
|
{
|
||||||
std::size_t hash = OffsetBias;
|
std::size_t hash = OffsetBias;
|
||||||
for(std::string::const_iterator it = text.begin(), end = text.end();
|
for(std::string::const_iterator it = text.begin(), end = text.end();
|
||||||
|
@ -19,30 +19,28 @@
|
|||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_USE_TEST)
|
#if defined(BOOST_UNORDERED_USE_TEST)
|
||||||
# define UNORDERED_EXCEPTION_TEST_PREFIX
|
|
||||||
# define UNORDERED_EXCEPTION_TEST_CASE(name, test_func, type) \
|
# define UNORDERED_EXCEPTION_TEST_CASE(name, test_func, type) \
|
||||||
BOOST_AUTO_TEST_CASE(name) \
|
UNORDERED_AUTO_TEST(name) \
|
||||||
{ \
|
{ \
|
||||||
test_func< type > fixture; \
|
test_func< type > fixture; \
|
||||||
::test::exception_safety(fixture, BOOST_STRINGIZE(test_func<type>)); \
|
::test::exception_safety(fixture, BOOST_STRINGIZE(test_func<type>)); \
|
||||||
}
|
}
|
||||||
# define UNORDERED_EXCEPTION_TEST_POSTFIX
|
|
||||||
# define UNORDERED_EPOINT_IMPL BOOST_ITEST_EPOINT
|
# define UNORDERED_EPOINT_IMPL BOOST_ITEST_EPOINT
|
||||||
#else
|
#else
|
||||||
# define UNORDERED_EXCEPTION_TEST_PREFIX int main() {
|
# define UNORDERED_EXCEPTION_TEST_CASE(name, test_func, type) \
|
||||||
# define UNORDERED_EXCEPTION_TEST_CASE(name, test_func, type) \
|
UNORDERED_AUTO_TEST(name) \
|
||||||
{ \
|
{ \
|
||||||
test_func< type > fixture; \
|
test_func< type > fixture; \
|
||||||
::test::lightweight::exception_safety(fixture, BOOST_STRINGIZE(test_func<type>)); \
|
::test::lightweight::exception_safety(fixture, BOOST_STRINGIZE(test_func<type>)); \
|
||||||
}
|
}
|
||||||
# define UNORDERED_EXCEPTION_TEST_POSTFIX return boost::report_errors(); }
|
|
||||||
# define UNORDERED_EPOINT_IMPL ::test::lightweight::epoint
|
# define UNORDERED_EPOINT_IMPL ::test::lightweight::epoint
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define UNORDERED_EXCEPTION_TEST_POSTFIX RUN_TESTS()
|
||||||
|
|
||||||
#define RUN_EXCEPTION_TESTS(test_seq, param_seq) \
|
#define RUN_EXCEPTION_TESTS(test_seq, param_seq) \
|
||||||
UNORDERED_EXCEPTION_TEST_PREFIX \
|
|
||||||
BOOST_PP_SEQ_FOR_EACH_PRODUCT(RUN_EXCEPTION_TESTS_OP, (test_seq)(param_seq)) \
|
BOOST_PP_SEQ_FOR_EACH_PRODUCT(RUN_EXCEPTION_TESTS_OP, (test_seq)(param_seq)) \
|
||||||
UNORDERED_EXCEPTION_TEST_POSTFIX
|
RUN_TESTS()
|
||||||
|
|
||||||
#define RUN_EXCEPTION_TESTS_OP(r, product) \
|
#define RUN_EXCEPTION_TESTS_OP(r, product) \
|
||||||
UNORDERED_EXCEPTION_TEST_CASE( \
|
UNORDERED_EXCEPTION_TEST_CASE( \
|
||||||
|
@ -7,13 +7,90 @@
|
|||||||
#define BOOST_UNORDERED_TEST_TEST_HEADER
|
#define BOOST_UNORDERED_TEST_TEST_HEADER
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_USE_TEST)
|
#if defined(BOOST_UNORDERED_USE_TEST)
|
||||||
|
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#define UNORDERED_CHECK(x) BOOST_CHECK(x)
|
#define UNORDERED_CHECK(x) BOOST_CHECK(x)
|
||||||
#define UNORDERED_REQUIRE(x) BOOST_REQUIRE(x)
|
#define UNORDERED_REQUIRE(x) BOOST_REQUIRE(x)
|
||||||
|
#define UNORDERED_AUTO_TEST(x) BOOST_AUTO_TEST_CASE(x)
|
||||||
|
#define RUN_TESTS()
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
|
||||||
#define UNORDERED_CHECK(x) BOOST_TEST(x)
|
#define UNORDERED_CHECK(x) BOOST_TEST(x)
|
||||||
#define UNORDERED_REQUIRE(x) if(!(x)) { BOOST_ERROR(BOOST_STRINGIZE(x)); throw test::lightweight::test_failure(); }
|
#define UNORDERED_REQUIRE(x) if(!(x)) { BOOST_ERROR(BOOST_STRINGIZE(x)); throw ::test::lightweight::test_failure(); }
|
||||||
#endif
|
#define UNORDERED_AUTO_TEST(x) \
|
||||||
|
struct BOOST_PP_CAT(x, _type) : public ::test::registered_test_base { \
|
||||||
|
BOOST_PP_CAT(x, _type)() { \
|
||||||
|
::test::test_list::add_test(this); \
|
||||||
|
} \
|
||||||
|
void run(); \
|
||||||
|
}; \
|
||||||
|
BOOST_PP_CAT(x, _type) x; \
|
||||||
|
void BOOST_PP_CAT(x, _type)::run()
|
||||||
|
#define RUN_TESTS() int main() { ::test::test_list::run_tests(); return boost::report_errors(); }
|
||||||
|
|
||||||
|
namespace test {
|
||||||
|
struct registered_test_base {
|
||||||
|
registered_test_base* next;
|
||||||
|
virtual void run() = 0;
|
||||||
|
virtual ~registered_test_base() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace test_list {
|
||||||
|
static inline registered_test_base*& first() {
|
||||||
|
static registered_test_base* ptr = 0;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline registered_test_base*& last() {
|
||||||
|
static registered_test_base* ptr = 0;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void add_test(registered_test_base* test) {
|
||||||
|
if(last()) {
|
||||||
|
last()->next = test;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
first() = test;
|
||||||
|
}
|
||||||
|
|
||||||
|
last() = test;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void run_tests() {
|
||||||
|
for(registered_test_base* i = first(); i; i = i->next)
|
||||||
|
i->run();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <boost/preprocessor/seq/for_each_product.hpp>
|
||||||
|
#include <boost/preprocessor/seq/fold_left.hpp>
|
||||||
|
#include <boost/preprocessor/seq/to_tuple.hpp>
|
||||||
|
#include <boost/preprocessor/seq/seq.hpp>
|
||||||
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
|
||||||
|
// Run test with every combination of the parameters (a sequence of sequences)
|
||||||
|
#define UNORDERED_TEST(name, parameters) \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH_PRODUCT(UNORDERED_TEST_OP, ((name)) parameters)
|
||||||
|
|
||||||
|
#define UNORDERED_TEST_OP(r, product) \
|
||||||
|
UNORDERED_TEST_OP2( \
|
||||||
|
BOOST_PP_SEQ_HEAD(product), \
|
||||||
|
BOOST_PP_SEQ_TAIL(product))
|
||||||
|
|
||||||
|
#define UNORDERED_TEST_OP2(name, params) \
|
||||||
|
UNORDERED_AUTO_TEST(BOOST_PP_SEQ_FOLD_LEFT(UNORDERED_TEST_OP_JOIN, name, params)) { \
|
||||||
|
name BOOST_PP_SEQ_TO_TUPLE(params); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define UNORDERED_TEST_OP_JOIN(s, state, elem) \
|
||||||
|
BOOST_PP_CAT(state, BOOST_PP_CAT(_, elem))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include "../objects/test.hpp"
|
#include "../objects/test.hpp"
|
||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
#include "../helpers/tracker.hpp"
|
#include "../helpers/tracker.hpp"
|
||||||
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace assign_tests {
|
||||||
|
|
||||||
test::seed_t seed(96785);
|
test::seed_t seed(96785);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -83,32 +85,24 @@ void assign_tests2(T*, test::random_generator generator = test::default_generato
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
||||||
{
|
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
||||||
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
||||||
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
||||||
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
|
||||||
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
|
||||||
|
|
||||||
assign_tests1(test_set);
|
using test::default_generator;
|
||||||
assign_tests1(test_multiset);
|
using test::generate_collisions;
|
||||||
assign_tests1(test_map);
|
|
||||||
assign_tests1(test_multimap);
|
|
||||||
|
|
||||||
assign_tests1(test_set, test::generate_collisions);
|
UNORDERED_TEST(assign_tests1,
|
||||||
assign_tests1(test_multiset, test::generate_collisions);
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
||||||
assign_tests1(test_map, test::generate_collisions);
|
((default_generator)(generate_collisions))
|
||||||
assign_tests1(test_multimap, test::generate_collisions);
|
)
|
||||||
|
|
||||||
assign_tests2(test_set);
|
UNORDERED_TEST(assign_tests2,
|
||||||
assign_tests2(test_multiset);
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
||||||
assign_tests2(test_map);
|
((default_generator)(generate_collisions))
|
||||||
assign_tests2(test_multimap);
|
)
|
||||||
|
|
||||||
assign_tests2(test_set, test::generate_collisions);
|
|
||||||
assign_tests2(test_multiset, test::generate_collisions);
|
|
||||||
assign_tests2(test_map, test::generate_collisions);
|
|
||||||
assign_tests2(test_multimap, test::generate_collisions);
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
||||||
|
@ -4,10 +4,12 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int main() {
|
namespace at_tests {
|
||||||
|
|
||||||
|
UNORDERED_AUTO_TEST(at_tests) {
|
||||||
boost::unordered_map<std::string, int> x;
|
boost::unordered_map<std::string, int> x;
|
||||||
typedef boost::unordered_map<std::string, int>::iterator iterator;
|
typedef boost::unordered_map<std::string, int>::iterator iterator;
|
||||||
|
|
||||||
@ -23,6 +25,8 @@ int main() {
|
|||||||
}
|
}
|
||||||
catch(std::out_of_range) {
|
catch(std::out_of_range) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
||||||
|
@ -5,12 +5,14 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../objects/test.hpp"
|
#include "../objects/test.hpp"
|
||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
#include "../helpers/helpers.hpp"
|
#include "../helpers/helpers.hpp"
|
||||||
|
|
||||||
|
namespace bucket_tests {
|
||||||
|
|
||||||
test::seed_t seed(54635);
|
test::seed_t seed(54635);
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
@ -48,12 +50,13 @@ void bucket_tests(X* = 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
||||||
{
|
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
||||||
bucket_tests((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
||||||
bucket_tests((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
||||||
bucket_tests((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
|
||||||
bucket_tests((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
UNORDERED_TEST(bucket_tests, ((test_set)(test_multiset)(test_map)(test_multimap)))
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include "../objects/minimal.hpp"
|
#include "../objects/minimal.hpp"
|
||||||
#include "./compile_tests.hpp"
|
#include "./compile_tests.hpp"
|
||||||
|
|
||||||
void test0()
|
UNORDERED_AUTO_TEST(test0)
|
||||||
{
|
{
|
||||||
typedef std::pair<test::minimal::assignable const,
|
typedef std::pair<test::minimal::assignable const,
|
||||||
test::minimal::copy_constructible> value_type;
|
test::minimal::copy_constructible> value_type;
|
||||||
@ -42,8 +42,7 @@ void test0()
|
|||||||
container_test(multimap, value);
|
container_test(multimap, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test1()
|
UNORDERED_AUTO_TEST(test1) {
|
||||||
{
|
|
||||||
boost::hash<int> hash;
|
boost::hash<int> hash;
|
||||||
std::equal_to<int> equal_to;
|
std::equal_to<int> equal_to;
|
||||||
int value = 0;
|
int value = 0;
|
||||||
@ -67,7 +66,7 @@ void test1()
|
|||||||
unordered_test(multimap, value, map_value, hash, equal_to);
|
unordered_test(multimap, value, map_value, hash, equal_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test2()
|
UNORDERED_AUTO_TEST(test2)
|
||||||
{
|
{
|
||||||
test::minimal::assignable assignable
|
test::minimal::assignable assignable
|
||||||
= test::minimal::assignable::create();
|
= test::minimal::assignable::create();
|
||||||
@ -121,11 +120,4 @@ void test2()
|
|||||||
unordered_test(multimap, assignable, map_value, hash, equal_to);
|
unordered_test(multimap, assignable, map_value, hash, equal_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
RUN_TESTS()
|
||||||
{
|
|
||||||
test0();
|
|
||||||
test1();
|
|
||||||
test2();
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include "../objects/minimal.hpp"
|
#include "../objects/minimal.hpp"
|
||||||
#include "./compile_tests.hpp"
|
#include "./compile_tests.hpp"
|
||||||
|
|
||||||
void test0()
|
UNORDERED_AUTO_TEST(test0)
|
||||||
{
|
{
|
||||||
test::minimal::assignable assignable = test::minimal::assignable::create();
|
test::minimal::assignable assignable = test::minimal::assignable::create();
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ void test0()
|
|||||||
container_test(multiset, assignable);
|
container_test(multiset, assignable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test1()
|
UNORDERED_AUTO_TEST(test1)
|
||||||
{
|
{
|
||||||
boost::hash<int> hash;
|
boost::hash<int> hash;
|
||||||
std::equal_to<int> equal_to;
|
std::equal_to<int> equal_to;
|
||||||
@ -59,7 +59,7 @@ void test1()
|
|||||||
unordered_test(multiset, value, value, hash, equal_to);
|
unordered_test(multiset, value, value, hash, equal_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test2()
|
UNORDERED_AUTO_TEST(test2)
|
||||||
{
|
{
|
||||||
test::minimal::assignable assignable
|
test::minimal::assignable assignable
|
||||||
= test::minimal::assignable::create();
|
= test::minimal::assignable::create();
|
||||||
@ -95,10 +95,4 @@ void test2()
|
|||||||
unordered_test(multiset, assignable, assignable, hash, equal_to);
|
unordered_test(multiset, assignable, assignable, hash, equal_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
RUN_TESTS()
|
||||||
test0();
|
|
||||||
test1();
|
|
||||||
test2();
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include "../objects/test.hpp"
|
#include "../objects/test.hpp"
|
||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
#include "../helpers/tracker.hpp"
|
#include "../helpers/tracker.hpp"
|
||||||
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace constructor_tests {
|
||||||
|
|
||||||
test::seed_t seed(356730);
|
test::seed_t seed(356730);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -255,53 +257,28 @@ void map_constructor_test(T* = 0)
|
|||||||
test::check_equivalent_keys(x);
|
test::check_equivalent_keys(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
||||||
{
|
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
||||||
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
||||||
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
||||||
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
|
||||||
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
|
||||||
|
|
||||||
std::cerr<<"Test1 test_set\n";
|
using test::default_generator;
|
||||||
constructor_tests1(test_set);
|
using test::generate_collisions;
|
||||||
std::cerr<<"Test1 test_multiset\n";
|
|
||||||
constructor_tests1(test_multiset);
|
|
||||||
std::cerr<<"Test1 test_map\n";
|
|
||||||
constructor_tests1(test_map);
|
|
||||||
std::cerr<<"Test1 test_multimap\n";
|
|
||||||
constructor_tests1(test_multimap);
|
|
||||||
|
|
||||||
std::cerr<<"Test1 test_set, collisions\n";
|
UNORDERED_TEST(constructor_tests1,
|
||||||
constructor_tests1(test_set, test::generate_collisions);
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
||||||
std::cerr<<"Test1 test_multiset, collisions\n";
|
((default_generator)(generate_collisions))
|
||||||
constructor_tests1(test_multiset, test::generate_collisions);
|
)
|
||||||
std::cerr<<"Test1 test_map, collisions\n";
|
|
||||||
constructor_tests1(test_map, test::generate_collisions);
|
|
||||||
std::cerr<<"Test1 test_multimap, collisions\n";
|
|
||||||
constructor_tests1(test_multimap, test::generate_collisions);
|
|
||||||
|
|
||||||
std::cerr<<"Test2 test_set\n";
|
UNORDERED_TEST(constructor_tests2,
|
||||||
constructor_tests2(test_set);
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
||||||
std::cerr<<"Test2 test_multiset\n";
|
((default_generator)(generate_collisions))
|
||||||
constructor_tests2(test_multiset);
|
)
|
||||||
std::cerr<<"Test2 test_map\n";
|
|
||||||
constructor_tests2(test_map);
|
|
||||||
std::cerr<<"Test2 test_multimap\n";
|
|
||||||
constructor_tests2(test_multimap);
|
|
||||||
|
|
||||||
std::cerr<<"Test2 test_set, collisions\n";
|
UNORDERED_TEST(map_constructor_test,
|
||||||
constructor_tests2(test_set, test::generate_collisions);
|
((test_map)(test_multimap))
|
||||||
std::cerr<<"Test2 test_multiset, collisions\n";
|
)
|
||||||
constructor_tests2(test_multiset, test::generate_collisions);
|
|
||||||
std::cerr<<"Test2 test_map, collisions\n";
|
|
||||||
constructor_tests2(test_map, test::generate_collisions);
|
|
||||||
std::cerr<<"Test2 test_multimap, collisions\n";
|
|
||||||
constructor_tests2(test_multimap, test::generate_collisions);
|
|
||||||
|
|
||||||
std::cerr<<"Map Test unordered_map<test::object, test::object>\n";
|
|
||||||
map_constructor_test(test_map);
|
|
||||||
std::cerr<<"Map Test unordered_multimap<test::object, test::object>\n";
|
|
||||||
map_constructor_test(test_multimap);
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include "../objects/test.hpp"
|
#include "../objects/test.hpp"
|
||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
#include "../helpers/tracker.hpp"
|
#include "../helpers/tracker.hpp"
|
||||||
@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
test::seed_t seed(9063);
|
test::seed_t seed(9063);
|
||||||
|
|
||||||
|
namespace copy_tests
|
||||||
|
{
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void copy_construct_tests1(T*, test::random_generator const& generator = test::default_generator)
|
void copy_construct_tests1(T*, test::random_generator const& generator = test::default_generator)
|
||||||
{
|
{
|
||||||
@ -90,27 +93,23 @@ void copy_construct_tests2(T* ptr, test::random_generator const& generator = tes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
||||||
{
|
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
||||||
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
||||||
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
||||||
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
|
||||||
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
|
||||||
|
|
||||||
copy_construct_tests1(test_set);
|
using test::default_generator;
|
||||||
copy_construct_tests1(test_multiset);
|
using test::generate_collisions;
|
||||||
copy_construct_tests1(test_map);
|
|
||||||
copy_construct_tests1(test_multimap);
|
|
||||||
|
|
||||||
copy_construct_tests2(test_set);
|
UNORDERED_TEST(copy_construct_tests1,
|
||||||
copy_construct_tests2(test_multiset);
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
||||||
copy_construct_tests2(test_map);
|
)
|
||||||
copy_construct_tests2(test_multimap);
|
|
||||||
|
|
||||||
copy_construct_tests2(test_set, test::generate_collisions);
|
UNORDERED_TEST(copy_construct_tests2,
|
||||||
copy_construct_tests2(test_multiset, test::generate_collisions);
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
||||||
copy_construct_tests2(test_map, test::generate_collisions);
|
((default_generator)(generate_collisions))
|
||||||
copy_construct_tests2(test_multimap, test::generate_collisions);
|
)
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
@ -32,7 +32,7 @@ void test_equal_insertion(Iterator begin, Iterator end)
|
|||||||
test::check_equivalent_keys(x1);
|
test::check_equivalent_keys(x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_tests()
|
UNORDERED_AUTO_TEST(set_tests)
|
||||||
{
|
{
|
||||||
int values[][5] = {
|
int values[][5] = {
|
||||||
{1},
|
{1},
|
||||||
@ -55,7 +55,7 @@ void set_tests()
|
|||||||
test_equal_insertion<boost::unordered_multiset<int> >(values[4], values[4] + 3);
|
test_equal_insertion<boost::unordered_multiset<int> >(values[4], values[4] + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void map_tests()
|
UNORDERED_AUTO_TEST(map_tests)
|
||||||
{
|
{
|
||||||
typedef std::list<std::pair<int const, int> > values_type;
|
typedef std::list<std::pair<int const, int> > values_type;
|
||||||
values_type v[5];
|
values_type v[5];
|
||||||
@ -76,10 +76,4 @@ void map_tests()
|
|||||||
v[i2].begin(), v[i2].end());
|
v[i2].begin(), v[i2].end());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
RUN_TESTS()
|
||||||
{
|
|
||||||
set_tests();
|
|
||||||
map_tests();
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
// hairy with several tricky edge cases - so explicitly test each one.
|
// hairy with several tricky edge cases - so explicitly test each one.
|
||||||
|
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -52,8 +52,7 @@ typedef boost::unordered_multimap<int, int,
|
|||||||
typedef collide_map::value_type collide_value;
|
typedef collide_map::value_type collide_value;
|
||||||
typedef std::list<collide_value> collide_list;
|
typedef std::list<collide_value> collide_list;
|
||||||
|
|
||||||
|
UNORDERED_AUTO_TEST(empty_range_tests)
|
||||||
void empty_range_tests()
|
|
||||||
{
|
{
|
||||||
collide_map x;
|
collide_map x;
|
||||||
x.erase(x.begin(), x.end());
|
x.erase(x.begin(), x.end());
|
||||||
@ -61,7 +60,7 @@ void empty_range_tests()
|
|||||||
x.erase(x.end(), x.end());
|
x.erase(x.end(), x.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void single_item_tests()
|
UNORDERED_AUTO_TEST(single_item_tests)
|
||||||
{
|
{
|
||||||
collide_list init;
|
collide_list init;
|
||||||
init.push_back(collide_value(1,1));
|
init.push_back(collide_value(1,1));
|
||||||
@ -75,7 +74,7 @@ void single_item_tests()
|
|||||||
BOOST_TEST(x.count(1) == 0 && x.size() == 0);
|
BOOST_TEST(x.count(1) == 0 && x.size() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void two_equivalent_item_tests()
|
UNORDERED_AUTO_TEST(two_equivalent_item_tests)
|
||||||
{
|
{
|
||||||
collide_list init;
|
collide_list init;
|
||||||
init.push_back(collide_value(1,1));
|
init.push_back(collide_value(1,1));
|
||||||
@ -172,7 +171,7 @@ void exhaustive_erase_tests(Container* x, int num_values,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void exhaustive_collide_tests()
|
UNORDERED_AUTO_TEST(exhaustive_collide_tests)
|
||||||
{
|
{
|
||||||
std::cout<<"exhaustive_collide_tests:\n";
|
std::cout<<"exhaustive_collide_tests:\n";
|
||||||
collide_map m;
|
collide_map m;
|
||||||
@ -180,20 +179,11 @@ void exhaustive_collide_tests()
|
|||||||
std::cout<<"\n";
|
std::cout<<"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void exhaustive_collide2_tests()
|
UNORDERED_AUTO_TEST(exhaustive_collide2_tests)
|
||||||
{
|
{
|
||||||
std::cout<<"exhaustive_collide2_tests:\n";
|
std::cout<<"exhaustive_collide2_tests:\n";
|
||||||
exhaustive_erase_tests((collide_map2*) 0, 8, 4);
|
exhaustive_erase_tests((collide_map2*) 0, 8, 4);
|
||||||
std::cout<<"\n";
|
std::cout<<"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
RUN_TESTS()
|
||||||
{
|
|
||||||
empty_range_tests();
|
|
||||||
single_item_tests();
|
|
||||||
two_equivalent_item_tests();
|
|
||||||
exhaustive_collide_tests();
|
|
||||||
exhaustive_collide2_tests();
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include <boost/next_prior.hpp>
|
#include <boost/next_prior.hpp>
|
||||||
#include "../objects/test.hpp"
|
#include "../objects/test.hpp"
|
||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace erase_tests
|
||||||
|
{
|
||||||
|
|
||||||
test::seed_t seed(85638);
|
test::seed_t seed(85638);
|
||||||
|
|
||||||
template <class Container>
|
template <class Container>
|
||||||
@ -119,30 +122,19 @@ void erase_tests1(Container*, test::random_generator generator = test::default_g
|
|||||||
std::cerr<<"\n";
|
std::cerr<<"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
||||||
{
|
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
||||||
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
||||||
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
||||||
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
|
||||||
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
|
||||||
|
|
||||||
std::cerr<<"Erase test_set.\n";
|
using test::default_generator;
|
||||||
erase_tests1(test_set);
|
using test::generate_collisions;
|
||||||
std::cerr<<"Erase test_multiset.\n";
|
|
||||||
erase_tests1(test_multiset);
|
|
||||||
std::cerr<<"Erase test_map.\n";
|
|
||||||
erase_tests1(test_map);
|
|
||||||
std::cerr<<"Erase test_multimap.\n";
|
|
||||||
erase_tests1(test_multimap);
|
|
||||||
|
|
||||||
std::cerr<<"Erase test_set, collisions.\n";
|
UNORDERED_TEST(erase_tests1,
|
||||||
erase_tests1(test_set, test::generate_collisions);
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
||||||
std::cerr<<"Erase test_multiset, collisions.\n";
|
((default_generator)(generate_collisions))
|
||||||
erase_tests1(test_multiset, test::generate_collisions);
|
)
|
||||||
std::cerr<<"Erase test_map, collisions.\n";
|
|
||||||
erase_tests1(test_map, test::generate_collisions);
|
|
||||||
std::cerr<<"Erase test_multimap, collisions.\n";
|
|
||||||
erase_tests1(test_multimap, test::generate_collisions);
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
||||||
|
@ -5,12 +5,15 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include "../objects/test.hpp"
|
#include "../objects/test.hpp"
|
||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
#include "../helpers/tracker.hpp"
|
#include "../helpers/tracker.hpp"
|
||||||
#include "../helpers/helpers.hpp"
|
#include "../helpers/helpers.hpp"
|
||||||
|
|
||||||
|
namespace find_tests
|
||||||
|
{
|
||||||
|
|
||||||
test::seed_t seed(78937);
|
test::seed_t seed(78937);
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
@ -78,22 +81,19 @@ void find_tests1(X*, test::random_generator generator = test::default_generator)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
||||||
{
|
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
||||||
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
||||||
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
||||||
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
|
||||||
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
|
||||||
|
|
||||||
find_tests1(test_set);
|
using test::default_generator;
|
||||||
find_tests1(test_multiset);
|
using test::generate_collisions;
|
||||||
find_tests1(test_map);
|
|
||||||
find_tests1(test_multimap);
|
|
||||||
|
|
||||||
find_tests1(test_set, test::generate_collisions);
|
UNORDERED_TEST(find_tests1,
|
||||||
find_tests1(test_multiset, test::generate_collisions);
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
||||||
find_tests1(test_map, test::generate_collisions);
|
((default_generator)(generate_collisions))
|
||||||
find_tests1(test_multimap, test::generate_collisions);
|
)
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ namespace insert_stable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void stable_insert_test1() {
|
UNORDERED_AUTO_TEST(stable_insert_test1) {
|
||||||
boost::unordered_multiset<insert_stable::member> x;
|
boost::unordered_multiset<insert_stable::member> x;
|
||||||
|
|
||||||
x.insert(insert_stable::member(1,1));
|
x.insert(insert_stable::member(1,1));
|
||||||
@ -56,7 +56,7 @@ void stable_insert_test1() {
|
|||||||
BOOST_TEST(it == end);
|
BOOST_TEST(it == end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stable_insert_test2() {
|
UNORDERED_AUTO_TEST(stable_insert_test2) {
|
||||||
boost::unordered_multimap<insert_stable::member, int> x;
|
boost::unordered_multimap<insert_stable::member, int> x;
|
||||||
typedef boost::unordered_multimap<insert_stable::member, int>::const_iterator iterator;
|
typedef boost::unordered_multimap<insert_stable::member, int>::const_iterator iterator;
|
||||||
|
|
||||||
@ -75,10 +75,4 @@ void stable_insert_test2() {
|
|||||||
BOOST_TEST(it == end);
|
BOOST_TEST(it == end);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
RUN_TESTS()
|
||||||
{
|
|
||||||
stable_insert_test1();
|
|
||||||
stable_insert_test2();
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include <boost/next_prior.hpp>
|
#include <boost/next_prior.hpp>
|
||||||
#include "../objects/test.hpp"
|
#include "../objects/test.hpp"
|
||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include <boost/limits.hpp>
|
#include <boost/limits.hpp>
|
||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
|
|
||||||
@ -14,6 +14,9 @@
|
|||||||
#pragma warning(disable:4127) // conditional expression is constant
|
#pragma warning(disable:4127) // conditional expression is constant
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace load_factor_tests
|
||||||
|
{
|
||||||
|
|
||||||
test::seed_t seed(783656);
|
test::seed_t seed(783656);
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
@ -63,21 +66,23 @@ void load_factor_insert_tests(X* ptr = 0)
|
|||||||
insert_test(ptr, std::numeric_limits<float>::infinity());
|
insert_test(ptr, std::numeric_limits<float>::infinity());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
boost::unordered_set<int>* int_set_ptr;
|
||||||
{
|
boost::unordered_multiset<int>* int_multiset_ptr;
|
||||||
load_factor_tests((boost::unordered_set<int>*) 0);
|
boost::unordered_map<int, int>* int_map_ptr;
|
||||||
load_factor_tests((boost::unordered_multiset<int>*) 0);
|
boost::unordered_multimap<int, int>* int_multimap_ptr;
|
||||||
load_factor_tests((boost::unordered_map<int, int>*) 0);
|
|
||||||
load_factor_tests((boost::unordered_multimap<int, int>*) 0);
|
|
||||||
|
|
||||||
load_factor_insert_tests((boost::unordered_set<int>*) 0);
|
UNORDERED_TEST(load_factor_tests,
|
||||||
load_factor_insert_tests((boost::unordered_multiset<int>*) 0);
|
((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr))
|
||||||
load_factor_insert_tests((boost::unordered_map<int, int>*) 0);
|
)
|
||||||
load_factor_insert_tests((boost::unordered_multimap<int, int>*) 0);
|
|
||||||
|
UNORDERED_TEST(load_factor_insert_tests,
|
||||||
|
((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr))
|
||||||
|
)
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
#if defined(BOOST_MSVC)
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#pragma warning(disable:4127) // conditional expression is constant
|
#pragma warning(disable:4127) // conditional expression is constant
|
||||||
|
@ -5,10 +5,13 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
#include "../helpers/tracker.hpp"
|
#include "../helpers/tracker.hpp"
|
||||||
|
|
||||||
|
namespace rehash_tests
|
||||||
|
{
|
||||||
|
|
||||||
test::seed_t seed(2974);
|
test::seed_t seed(2974);
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
@ -59,11 +62,15 @@ void rehash_tests(X* ptr = 0)
|
|||||||
rehash_test1(ptr);
|
rehash_test1(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
boost::unordered_set<int>* int_set_ptr;
|
||||||
rehash_tests((boost::unordered_set<int>*) 0);
|
boost::unordered_multiset<int>* int_multiset_ptr;
|
||||||
rehash_tests((boost::unordered_multiset<int>*) 0);
|
boost::unordered_map<int, int>* int_map_ptr;
|
||||||
rehash_tests((boost::unordered_map<int, int>*) 0);
|
boost::unordered_multimap<int, int>* int_multimap_ptr;
|
||||||
rehash_tests((boost::unordered_multimap<int, int>*) 0);
|
|
||||||
|
UNORDERED_TEST(rehash_tests,
|
||||||
|
((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr))
|
||||||
|
)
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../helpers/equivalent.hpp"
|
#include "../helpers/equivalent.hpp"
|
||||||
@ -83,7 +83,7 @@ void simple_test(X const& a)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
UNORDERED_AUTO_TEST(simple_tests)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
srand(14878);
|
srand(14878);
|
||||||
@ -123,6 +123,6 @@ int main()
|
|||||||
multimap.insert(std::pair<const int, int>(index, rand()));
|
multimap.insert(std::pair<const int, int>(index, rand()));
|
||||||
}
|
}
|
||||||
simple_test(multimap);
|
simple_test(multimap);
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
||||||
|
@ -8,12 +8,15 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
#include "../objects/test.hpp"
|
#include "../objects/test.hpp"
|
||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
#include "../helpers/tracker.hpp"
|
#include "../helpers/tracker.hpp"
|
||||||
#include "../helpers/invariants.hpp"
|
#include "../helpers/invariants.hpp"
|
||||||
|
|
||||||
|
namespace swap_tests
|
||||||
|
{
|
||||||
|
|
||||||
test::seed_t seed(783472);
|
test::seed_t seed(783472);
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
@ -114,22 +117,18 @@ void swap_tests2(X* ptr = 0)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
||||||
{
|
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
||||||
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
||||||
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
||||||
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
|
||||||
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
|
||||||
|
|
||||||
swap_tests1(test_set);
|
UNORDERED_TEST(swap_tests1,
|
||||||
swap_tests1(test_multiset);
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
||||||
swap_tests1(test_map);
|
)
|
||||||
swap_tests1(test_multimap);
|
|
||||||
|
|
||||||
swap_tests2(test_set);
|
UNORDERED_TEST(swap_tests2,
|
||||||
swap_tests2(test_multiset);
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
||||||
swap_tests2(test_map);
|
)
|
||||||
swap_tests2(test_multimap);
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
RUN_TESTS()
|
||||||
|
@ -5,9 +5,10 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include "../helpers/test.hpp"
|
||||||
|
|
||||||
namespace test {
|
namespace unnecessary_copy_tests
|
||||||
|
{
|
||||||
struct count_copies
|
struct count_copies
|
||||||
{
|
{
|
||||||
static int count;
|
static int count;
|
||||||
@ -17,22 +18,24 @@ namespace test {
|
|||||||
count_copies& operator=(count_copies const&);
|
count_copies& operator=(count_copies const&);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(test::count_copies const&, test::count_copies const&) {
|
bool operator==(count_copies const&, count_copies const&) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
||||||
namespace boost {
|
namespace boost
|
||||||
#else
|
#else
|
||||||
namespace test {
|
namespace unnecessary_copy_tests
|
||||||
#endif
|
#endif
|
||||||
std::size_t hash_value(test::count_copies const&) {
|
{
|
||||||
|
std::size_t hash_value(unnecessary_copy_tests::count_copies const&) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace test {
|
namespace unnecessary_copy_tests
|
||||||
|
{
|
||||||
int count_copies::count;
|
int count_copies::count;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -45,14 +48,13 @@ namespace test {
|
|||||||
x.insert(a);
|
x.insert(a);
|
||||||
BOOST_TEST(count_copies::count == 2);
|
BOOST_TEST(count_copies::count == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::unordered_set<count_copies>* set;
|
||||||
|
boost::unordered_multiset<count_copies>* multiset;
|
||||||
|
boost::unordered_map<int, count_copies>* map;
|
||||||
|
boost::unordered_multimap<int, count_copies>* multimap;
|
||||||
|
|
||||||
|
UNORDERED_TEST(unnecessary_copy_test, ((set)(multiset)(map)(multimap)))
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
RUN_TESTS()
|
||||||
{
|
|
||||||
test::unnecessary_copy_test((boost::unordered_set<test::count_copies>*) 0);
|
|
||||||
test::unnecessary_copy_test((boost::unordered_multiset<test::count_copies>*) 0);
|
|
||||||
test::unnecessary_copy_test((boost::unordered_map<int, test::count_copies>*) 0);
|
|
||||||
test::unnecessary_copy_test((boost::unordered_multimap<int, test::count_copies>*) 0);
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user