|
Boost-Commit : |
From: daniel_james_at_[hidden]
Date: 2008-03-24 13:22:26
Author: danieljames
Date: 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
New Revision: 43839
URL: http://svn.boost.org/trac/boost/changeset/43839
Log:
Merged revisions 42740-43816,43819-43838 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
Added:
branches/unordered/dev/libs/unordered/doc/src_code/dictionary.cpp (contents, props changed)
branches/unordered/dev/libs/unordered/doc/src_code/intro.cpp (contents, props changed)
Removed:
branches/unordered/dev/Jamfile.v2
branches/unordered/dev/libs/unordered/doc/src_code/insensitive.cpp
Properties modified:
branches/unordered/dev/ (props changed)
Text files modified:
branches/unordered/dev/boost/functional/hash.hpp | 3 -
branches/unordered/dev/boost/functional/hash/hash.hpp | 21 ++++---
branches/unordered/dev/boost/unordered/detail/hash_table.hpp | 12 ++++
branches/unordered/dev/boost/unordered/detail/hash_table_impl.hpp | 8 +-
branches/unordered/dev/doc/Jamfile.v2 | 10 +++
branches/unordered/dev/libs/functional/hash/doc/Jamfile.v2 | 15 ++++-
branches/unordered/dev/libs/functional/hash/doc/intro.qbk | 3
branches/unordered/dev/libs/functional/hash/test/hash_number_test.cpp | 4
branches/unordered/dev/libs/unordered/doc/Jamfile.v2 | 15 ++++-
branches/unordered/dev/libs/unordered/doc/comparison.qbk | 2
branches/unordered/dev/libs/unordered/doc/hash_equality.qbk | 36 +++++++------
branches/unordered/dev/libs/unordered/doc/intro.qbk | 20 +------
branches/unordered/dev/libs/unordered/doc/rationale.qbk | 2
branches/unordered/dev/libs/unordered/doc/src_code/point1.cpp | 3
branches/unordered/dev/libs/unordered/doc/unordered.qbk | 2
branches/unordered/dev/libs/unordered/examples/hash_functions/fnv-1.hpp | 4
branches/unordered/dev/libs/unordered/test/exception/assign_exception_tests.cpp | 8 ++
branches/unordered/dev/libs/unordered/test/exception/swap_exception_tests.cpp | 12 +++-
branches/unordered/dev/libs/unordered/test/helpers/allocator.hpp | 15 ++---
branches/unordered/dev/libs/unordered/test/helpers/exception_test.hpp | 14 ++---
branches/unordered/dev/libs/unordered/test/helpers/fwd.hpp | 2
branches/unordered/dev/libs/unordered/test/helpers/generators.hpp | 28 ---------
branches/unordered/dev/libs/unordered/test/helpers/random_values.hpp | 92 +++++++++++++++++++++++++++++++++-
branches/unordered/dev/libs/unordered/test/helpers/test.hpp | 79 +++++++++++++++++++++++++++++
branches/unordered/dev/libs/unordered/test/objects/exception.hpp | 12 +---
branches/unordered/dev/libs/unordered/test/objects/memory.hpp | 28 ++++++++--
branches/unordered/dev/libs/unordered/test/objects/minimal.hpp | 3
branches/unordered/dev/libs/unordered/test/objects/test.hpp | 62 +----------------------
branches/unordered/dev/libs/unordered/test/unordered/assign_tests.cpp | 55 ++++++++++----------
branches/unordered/dev/libs/unordered/test/unordered/at_tests.cpp | 10 ++-
branches/unordered/dev/libs/unordered/test/unordered/bucket_tests.cpp | 24 ++++----
branches/unordered/dev/libs/unordered/test/unordered/compile_map.cpp | 21 ++-----
branches/unordered/dev/libs/unordered/test/unordered/compile_set.cpp | 16 +----
branches/unordered/dev/libs/unordered/test/unordered/constructor_tests.cpp | 105 ++++++++++++++-------------------------
branches/unordered/dev/libs/unordered/test/unordered/copy_tests.cpp | 44 +++++++++-------
branches/unordered/dev/libs/unordered/test/unordered/equivalent_keys_tests.cpp | 18 ++----
branches/unordered/dev/libs/unordered/test/unordered/erase_equiv_tests.cpp | 24 ++------
branches/unordered/dev/libs/unordered/test/unordered/erase_tests.cpp | 62 +++++++++-------------
branches/unordered/dev/libs/unordered/test/unordered/find_tests.cpp | 44 ++++++++--------
branches/unordered/dev/libs/unordered/test/unordered/insert_stable_tests.cpp | 14 +---
branches/unordered/dev/libs/unordered/test/unordered/insert_tests.cpp | 102 ++++++++++++++++++--------------------
branches/unordered/dev/libs/unordered/test/unordered/load_factor_tests.cpp | 31 ++++++----
branches/unordered/dev/libs/unordered/test/unordered/rehash_tests.cpp | 21 +++++--
branches/unordered/dev/libs/unordered/test/unordered/simple_tests.cpp | 27 +++++----
branches/unordered/dev/libs/unordered/test/unordered/swap_tests.cpp | 38 ++++++--------
branches/unordered/dev/libs/unordered/test/unordered/unnecessary_copy_tests.cpp | 32 ++++++-----
branches/unordered/dev/project-root.jam | 9 --
47 files changed, 636 insertions(+), 576 deletions(-)
Deleted: branches/unordered/dev/Jamfile.v2
==============================================================================
--- branches/unordered/dev/Jamfile.v2 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
+++ (empty file)
@@ -1,14 +0,0 @@
-# (C) Copyright Daniel James 2005-2006.
-# 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)
-
-project /unordered
- : requirements
- <include>.
- <include>$(BOOST_ROOT)
- : usage-requirements
- <include>.
- <include>$(BOOST_ROOT)
- ;
-
-#use-project /boost/test : $(BOOST_ROOT)/libs/test/build ;
Modified: branches/unordered/dev/boost/functional/hash.hpp
==============================================================================
--- branches/unordered/dev/boost/functional/hash.hpp (original)
+++ branches/unordered/dev/boost/functional/hash.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -9,6 +9,3 @@
#include <boost/functional/hash/hash.hpp>
-#if !defined(BOOST_HASH_NO_EXTENSIONS)
-#include <boost/functional/hash/extensions.hpp>
-#endif
Modified: branches/unordered/dev/boost/functional/hash/hash.hpp
==============================================================================
--- branches/unordered/dev/boost/functional/hash/hash.hpp (original)
+++ branches/unordered/dev/boost/functional/hash/hash.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -10,10 +10,6 @@
#if !defined(BOOST_FUNCTIONAL_HASH_HASH_HPP)
#define BOOST_FUNCTIONAL_HASH_HASH_HPP
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
#include <boost/functional/hash_fwd.hpp>
#include <functional>
#include <boost/functional/detail/hash_float.hpp>
@@ -50,8 +46,8 @@
#endif
#if defined(BOOST_HAS_LONG_LONG)
- std::size_t hash_value(long long);
- std::size_t hash_value(unsigned long long);
+ std::size_t hash_value(boost::long_long_type);
+ std::size_t hash_value(boost::ulong_long_type);
#endif
#if !BOOST_WORKAROUND(__DMC__, <= 0x848)
@@ -199,12 +195,12 @@
#endif
#if defined(BOOST_HAS_LONG_LONG)
- inline std::size_t hash_value(long long v)
+ inline std::size_t hash_value(boost::long_long_type v)
{
return hash_detail::hash_value_signed(v);
}
- inline std::size_t hash_value(unsigned long long v)
+ inline std::size_t hash_value(boost::ulong_long_type v)
{
return hash_detail::hash_value_unsigned(v);
}
@@ -522,3 +518,12 @@
}
#endif // BOOST_FUNCTIONAL_HASH_HASH_HPP
+
+// Include this outside of the include guards in case the file is included
+// twice - once with BOOST_HASH_NO_EXTENSIONS defined, and then with it
+// undefined.
+
+#if !defined(BOOST_HASH_NO_EXTENSIONS) \
+ && !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP)
+#include <boost/functional/hash/extensions.hpp>
+#endif
Modified: branches/unordered/dev/boost/unordered/detail/hash_table.hpp
==============================================================================
--- branches/unordered/dev/boost/unordered/detail/hash_table.hpp (original)
+++ branches/unordered/dev/boost/unordered/detail/hash_table.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -109,6 +109,18 @@
{
return std::pair<Dst1, Dst2>(Dst1(x.first), Dst2(x.second));
}
+
+#if !defined(BOOST_NO_STD_DISTANCE)
+ using ::std::distance;
+#else
+ template <class ForwardIterator>
+ inline std::size_t distance(ForwardIterator i, ForwardIterator j) {
+ std::size_t x;
+ std::distance(i, j, x);
+ return x;
+ }
+#endif
+
}
}
Modified: branches/unordered/dev/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- branches/unordered/dev/boost/unordered/detail/hash_table_impl.hpp (original)
+++ branches/unordered/dev/boost/unordered/detail/hash_table_impl.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -1045,7 +1045,7 @@
boost::forward_traversal_tag)
{
// max load factor isn't set yet, but when it is, it'll be 1.0.
- return (std::max)(static_cast<size_type>(std::distance(i, j)) + 1, n);
+ return (std::max)(static_cast<size_type>(unordered_detail::distance(i, j)) + 1, n);
}
template <typename I>
@@ -1312,7 +1312,7 @@
// throws - basic:
if (need_to_reserve) {
rehash_impl(double_to_size_t(floor(
- n / (double) mlf_ * 1.25)) + 1);
+ n / (double) mlf_ * 1.25)) + 1);
}
BOOST_ASSERT(n < max_load_ || n > max_size());
return need_to_reserve;
@@ -1545,7 +1545,7 @@
template <typename I>
void insert_for_range(I i, I j, forward_traversal_tag)
{
- size_type distance = std::distance(i, j);
+ size_type distance = unordered_detail::distance(i, j);
if(distance == 1) {
insert(*i);
}
@@ -1687,7 +1687,7 @@
template <typename I>
size_type insert_size(I i, I j, boost::forward_traversal_tag)
{
- return std::distance(i, j);
+ return unordered_detail::distance(i, j);
}
template <typename I>
Modified: branches/unordered/dev/doc/Jamfile.v2
==============================================================================
--- branches/unordered/dev/doc/Jamfile.v2 (original)
+++ branches/unordered/dev/doc/Jamfile.v2 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -12,4 +12,14 @@
<implicit-dependency>../libs/functional/hash/doc//hash
<xsl:param>boost.libraries=../../libs/libraries.htm
+
+ <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 ;
Modified: branches/unordered/dev/libs/functional/hash/doc/Jamfile.v2
==============================================================================
--- branches/unordered/dev/libs/functional/hash/doc/Jamfile.v2 (original)
+++ branches/unordered/dev/libs/functional/hash/doc/Jamfile.v2 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -3,8 +3,6 @@
# 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)
-using quickbook ;
-
xml hash : hash.qbk ;
boostbook standalone : hash :
<xsl:param>boost.root=../../../../..
@@ -14,4 +12,15 @@
<xsl:param>chunk.section.depth=2
<xsl:param>generate.section.toc.level=2
<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 ;
Modified: branches/unordered/dev/libs/functional/hash/doc/intro.qbk
==============================================================================
--- branches/unordered/dev/libs/functional/hash/doc/intro.qbk (original)
+++ branches/unordered/dev/libs/functional/hash/doc/intro.qbk 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -17,8 +17,7 @@
Boost Multi-Index Containers Library]]
[def __multi-index-short__ [@../../libs/multi_index/doc/index.html
Boost.MultiIndex]]
-[def __bimap__ [@../../libs/bimap/doc/index.html
- Boost.Bimap]]
+[def __bimap__ [@../../libs/bimap/index.html Boost.Bimap]]
[def __issues__
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1837.pdf
Library Extension Technical Report Issues List]]
Modified: branches/unordered/dev/libs/functional/hash/test/hash_number_test.cpp
==============================================================================
--- branches/unordered/dev/libs/functional/hash/test/hash_number_test.cpp (original)
+++ branches/unordered/dev/libs/functional/hash/test/hash_number_test.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -150,8 +150,8 @@
NUMERIC_TEST(unsigned long, ulong)
#if defined(BOOST_HAS_LONG_LONG)
- NUMERIC_TEST_NO_LIMITS(long long, hash_longlong)
- NUMERIC_TEST_NO_LIMITS(unsigned long long, ulonglong)
+ NUMERIC_TEST_NO_LIMITS(boost::long_long_type, long_long)
+ NUMERIC_TEST_NO_LIMITS(boost::ulong_long_type, ulong_long)
#endif
NUMERIC_TEST(float, float)
Modified: branches/unordered/dev/libs/unordered/doc/Jamfile.v2
==============================================================================
--- branches/unordered/dev/libs/unordered/doc/Jamfile.v2 (original)
+++ branches/unordered/dev/libs/unordered/doc/Jamfile.v2 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -3,8 +3,6 @@
# 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)
-using quickbook ;
-
xml unordered : unordered.qbk ;
boostbook standalone : unordered :
<xsl:param>boost.root=../../../..
@@ -14,4 +12,15 @@
<xsl:param>chunk.section.depth=2
<xsl:param>generate.section.toc.level=2
<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 ;
Modified: branches/unordered/dev/libs/unordered/doc/comparison.qbk
==============================================================================
--- branches/unordered/dev/libs/unordered/doc/comparison.qbk (original)
+++ branches/unordered/dev/libs/unordered/doc/comparison.qbk 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -83,7 +83,7 @@
]
[
[`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`]
]
]
Modified: branches/unordered/dev/libs/unordered/doc/hash_equality.qbk
==============================================================================
--- branches/unordered/dev/libs/unordered/doc/hash_equality.qbk (original)
+++ branches/unordered/dev/libs/unordered/doc/hash_equality.qbk 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -6,32 +6,35 @@
While the associative containers use an ordering relation to specify how the
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:
- template<typename Value,
- typename Hash = ``[classref boost::hash]``<Value>,
- typename Pred = std::equal_to<Value>,
- typename Alloc = std::allocator<Value> >
- class ``[classref boost::unordered_set unordered_set]``;
+ template <
+ class Key, class Mapped,
+ class Hash = ``[classref boost::hash]``<Key>,
+ class Pred = std::equal_to<Key>,
+ 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
-but not the equality predicate, while if you were to change the behavior
-of the equality predicate you would have to change the hash function to match
-it. So, if you wanted to use the
+but not the equality predicate. For example, if you wanted to use the
[@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
in the examples directory.
-Alternatively, you might wish to use a different equality function. If you do
-this you will need to use a hash function that matches it. So to implement a
-case-insensitive dictionary:
+If you wish to use a different equality function,
+you will also need to use a matching hash function. For
+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]
+
+Which you can then use in a case insensitive dictionary:
+
[case_insensitive_dictionary]
This is a simplified version of the example at
@@ -45,8 +48,9 @@
[import src_code/point1.cpp]
[point_example1]
-Although, [link hash.custom extending boost::hash to support the type] is
-probably a better solution:
+Since the default hash function is [link hash Boost.Hash],
+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]
[point_example2]
Modified: branches/unordered/dev/libs/unordered/doc/intro.qbk
==============================================================================
--- branches/unordered/dev/libs/unordered/doc/intro.qbk (original)
+++ branches/unordered/dev/libs/unordered/doc/intro.qbk 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -84,32 +84,18 @@
The containers are used in a similar manner to the normal associative
containers:
- #include <``[headerref boost/unordered_map.hpp]``>
- #include <cassert>
-
- 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);
- }
+[import src_code/intro.cpp]
+[intro_example1_2]
But since the elements aren't ordered, the output of:
- BOOST_FOREACH(map::value_type i, x) {
- std::cout<<i.first<<","<<i.second<<"\n";
- }
+[intro_example1_3]
can be in any order. For example, it might be:
two,2
one,1
three,3
- missing,0
To store an object in an unordered associative container requires both an
key equality function and a hash function. The default function objects in
Modified: branches/unordered/dev/libs/unordered/doc/rationale.qbk
==============================================================================
--- branches/unordered/dev/libs/unordered/doc/rationale.qbk (original)
+++ branches/unordered/dev/libs/unordered/doc/rationale.qbk 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -10,7 +10,7 @@
N2345, 'Placement Insert for Containers']]
[def __n2369__
[@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]
Added: branches/unordered/dev/libs/unordered/doc/src_code/dictionary.cpp
==============================================================================
--- (empty file)
+++ branches/unordered/dev/libs/unordered/doc/src_code/dictionary.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -0,0 +1,103 @@
+
+// Copyright 2006-2007 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)
+
+#include <boost/unordered_map.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+#include "../../examples/hash_functions/fnv-1.hpp"
+
+//[case_insensitive_functions
+ struct iequal_to
+ : std::binary_function<std::string, std::string, bool>
+ {
+ bool operator()(std::string const& x,
+ std::string const& y) const
+ {
+ return boost::algorithm::iequals(x, y, std::locale());
+ }
+ };
+
+ struct ihash
+ : std::unary_function<std::string, std::size_t>
+ {
+ std::size_t operator()(std::string const& x) const
+ {
+ std::size_t seed = 0;
+ std::locale locale;
+
+ for(std::string::const_iterator it = x.begin();
+ it != x.end(); ++it)
+ {
+ boost::hash_combine(seed, std::toupper(*it, locale));
+ }
+
+ return seed;
+ }
+ };
+//]
+
+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
+ boost::unordered_map<std::string, int, ihash, iequal_to>
+ idictionary;
+//]
+
+ BOOST_TEST(idictionary.empty());
+
+ idictionary["one"] = 1;
+ BOOST_TEST(idictionary.size() == 1);
+ BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
+ idictionary.find("ONE") == idictionary.find("one"));
+
+ idictionary.insert(std::make_pair("ONE", 2));
+ BOOST_TEST(idictionary.size() == 1);
+ BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
+ idictionary.find("ONE")->first == "one" &&
+ idictionary.find("ONE")->second == 1);
+
+ idictionary["One"] = 3;
+ BOOST_TEST(idictionary.size() == 1);
+ BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
+ idictionary.find("ONE")->first == "one" &&
+ idictionary.find("ONE")->second == 3);
+
+ idictionary["two"] = 4;
+ BOOST_TEST(idictionary.size() == 2);
+ BOOST_TEST(idictionary.find("two") != idictionary.end() &&
+ idictionary.find("TWO")->first == "two" &&
+ idictionary.find("Two")->second == 4);
+
+ return boost::report_errors();
+}
Deleted: branches/unordered/dev/libs/unordered/doc/src_code/insensitive.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/doc/src_code/insensitive.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
+++ (empty file)
@@ -1,79 +0,0 @@
-
-// Copyright 2006-2007 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)
-
-#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/algorithm/string/predicate.hpp>
-
-//[case_insensitive_functions
- struct iequal_to
- : std::binary_function<std::string, std::string, bool>
- {
- bool operator()(std::string const& x,
- std::string const& y) const
- {
- return boost::algorithm::iequals(x, y, std::locale());
- }
- };
-
- struct ihash
- : std::unary_function<std::string, std::size_t>
- {
- std::size_t operator()(std::string const& x) const
- {
- std::size_t seed = 0;
- std::locale locale;
-
- for(std::string::const_iterator it = x.begin();
- it != x.end(); ++it)
- {
- boost::hash_combine(seed, std::toupper(*it, locale));
- }
-
- return seed;
- }
- };
-
- struct word_info;
-//]
-
- struct word_info {
- int tag;
- explicit word_info(int t = 0) : tag(t) {}
- };
-
-int main() {
-//[case_insensitive_dictionary
- boost::unordered_map<std::string, word_info, ihash, iequal_to>
- idictionary;
-//]
-
- BOOST_TEST(idictionary.empty());
-
- idictionary["one"] = word_info(1);
- BOOST_TEST(idictionary.size() == 1);
- BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
- idictionary.find("ONE") == idictionary.find("one"));
-
- idictionary.insert(std::make_pair("ONE", word_info(2)));
- BOOST_TEST(idictionary.size() == 1);
- BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
- idictionary.find("ONE")->first == "one" &&
- idictionary.find("ONE")->second.tag == 1);
-
- idictionary["One"] = word_info(3);
- BOOST_TEST(idictionary.size() == 1);
- BOOST_TEST(idictionary.find("ONE") != idictionary.end() &&
- idictionary.find("ONE")->first == "one" &&
- idictionary.find("ONE")->second.tag == 3);
-
- idictionary["two"] = word_info(4);
- BOOST_TEST(idictionary.size() == 2);
- BOOST_TEST(idictionary.find("two") != idictionary.end() &&
- idictionary.find("TWO")->first == "two" &&
- idictionary.find("Two")->second.tag == 4);
-
- return boost::report_errors();
-}
Added: branches/unordered/dev/libs/unordered/doc/src_code/intro.cpp
==============================================================================
--- (empty file)
+++ branches/unordered/dev/libs/unordered/doc/src_code/intro.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -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";
+ }
+//]
+}
Modified: branches/unordered/dev/libs/unordered/doc/src_code/point1.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/doc/src_code/point1.cpp (original)
+++ branches/unordered/dev/libs/unordered/doc/src_code/point1.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -29,8 +29,7 @@
}
};
- boost::unordered_multiset<point, point_hash, std::equal_to<point> >
- points;
+ boost::unordered_multiset<point, point_hash> points;
//]
int main() {
Modified: branches/unordered/dev/libs/unordered/doc/unordered.qbk
==============================================================================
--- branches/unordered/dev/libs/unordered/doc/unordered.qbk (original)
+++ branches/unordered/dev/libs/unordered/doc/unordered.qbk 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -2,7 +2,7 @@
/ 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) ]
-[library Unordered Associative Containers
+[library Boost.Unordered
[quickbook 1.4]
[authors [James, Daniel]]
[copyright 2003 2004 Jeremy B. Maitin-Shepard]
Modified: branches/unordered/dev/libs/unordered/examples/hash_functions/fnv-1.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/examples/hash_functions/fnv-1.hpp (original)
+++ branches/unordered/dev/libs/unordered/examples/hash_functions/fnv-1.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -7,7 +7,7 @@
template <std::size_t FnvPrime, std::size_t OffsetBias>
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;
for(std::string::const_iterator it = text.begin(), end = text.end();
@@ -24,7 +24,7 @@
template <std::size_t FnvPrime, std::size_t OffsetBias>
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;
for(std::string::const_iterator it = text.begin(), end = text.end();
Modified: branches/unordered/dev/libs/unordered/test/exception/assign_exception_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/exception/assign_exception_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/exception/assign_exception_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -36,10 +36,14 @@
const test::random_values<T> x_values, y_values;
const T x,y;
+ typedef BOOST_DEDUCED_TYPENAME T::hasher hasher;
+ typedef BOOST_DEDUCED_TYPENAME T::key_equal key_equal;
+ typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
+
assign_base(unsigned int count1, unsigned int count2, int tag1, int tag2)
: x_values(count1), y_values(count2),
- x(x_values.begin(), x_values.end(), 0, BOOST_DEDUCED_TYPENAME T::hasher(tag1), BOOST_DEDUCED_TYPENAME T::key_equal(tag1), BOOST_DEDUCED_TYPENAME T::allocator_type(tag1)),
- y(y_values.begin(), y_values.end(), 0, BOOST_DEDUCED_TYPENAME T::hasher(tag2), BOOST_DEDUCED_TYPENAME T::key_equal(tag2), BOOST_DEDUCED_TYPENAME T::allocator_type(tag2)) {}
+ x(x_values.begin(), x_values.end(), 0, hasher(tag1), key_equal(tag1), allocator_type(tag1)),
+ y(y_values.begin(), y_values.end(), 0, hasher(tag2), key_equal(tag2), allocator_type(tag2)) {}
typedef T data_type;
T init() const { return T(x); }
Modified: branches/unordered/dev/libs/unordered/test/exception/swap_exception_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/exception/swap_exception_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/exception/swap_exception_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -48,12 +48,16 @@
const test::random_values<T> x_values, y_values;
const T initial_x, initial_y;
+ typedef BOOST_DEDUCED_TYPENAME T::hasher hasher;
+ typedef BOOST_DEDUCED_TYPENAME T::key_equal key_equal;
+ typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
+
swap_base(unsigned int count1, unsigned int count2, int tag1, int tag2)
: x_values(count1), y_values(count2),
- initial_x(x_values.begin(), x_values.end(), 0, BOOST_DEDUCED_TYPENAME T::hasher(tag1),
- BOOST_DEDUCED_TYPENAME T::key_equal(tag1), BOOST_DEDUCED_TYPENAME T::allocator_type(tag1)),
- initial_y(y_values.begin(), y_values.end(), 0, BOOST_DEDUCED_TYPENAME T::hasher(tag2),
- BOOST_DEDUCED_TYPENAME T::key_equal(tag2), BOOST_DEDUCED_TYPENAME T::allocator_type(tag2))
+ initial_x(x_values.begin(), x_values.end(), 0, hasher(tag1),
+ key_equal(tag1), allocator_type(tag1)),
+ initial_y(y_values.begin(), y_values.end(), 0, hasher(tag2),
+ key_equal(tag2), allocator_type(tag2))
{}
struct data_type {
Modified: branches/unordered/dev/libs/unordered/test/helpers/allocator.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/helpers/allocator.hpp (original)
+++ branches/unordered/dev/libs/unordered/test/helpers/allocator.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -9,6 +9,7 @@
#include <cstddef>
#include <cstdlib>
#include <boost/limits.hpp>
+#include <new>
#if defined(BOOST_MSVC)
#pragma warning(push)
@@ -39,16 +40,12 @@
pointer allocate(size_type n) {
using namespace std;
- return static_cast<T*>(malloc(n * sizeof(T)));
+ T* ptr = static_cast<T*>(malloc(n * sizeof(T)));
+ if(!ptr) throw std::bad_alloc();
+ return ptr;
}
- pointer allocate(size_type n, const_pointer u) { return allocate(n); }
-
-#if defined(__IBMCPP__)
- // Workaround for IBM Visual Age which seems to use a void pointer
- // for the second argument.
pointer allocate(size_type n, void const* u) { return allocate(n); }
-#endif
void deallocate(pointer p, size_type) {
using namespace std;
@@ -71,7 +68,9 @@
}
char* _Charalloc(size_type n) {
using namespace std;
- return static_cast<char*>(malloc(n * sizeof(char)));
+ T* ptr = static_cast<T*>(malloc(n * sizeof(char)));
+ if(!ptr) throw std::bad_alloc();
+ return ptr;
}
#endif
};
Modified: branches/unordered/dev/libs/unordered/test/helpers/exception_test.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/helpers/exception_test.hpp (original)
+++ branches/unordered/dev/libs/unordered/test/helpers/exception_test.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -19,30 +19,28 @@
#include <boost/preprocessor/cat.hpp>
#if defined(BOOST_UNORDERED_USE_TEST)
-# define UNORDERED_EXCEPTION_TEST_PREFIX
# define UNORDERED_EXCEPTION_TEST_CASE(name, test_func, type) \
- BOOST_AUTO_TEST_CASE(name) \
+ UNORDERED_AUTO_TEST(name) \
{ \
test_func< type > fixture; \
::test::exception_safety(fixture, BOOST_STRINGIZE(test_func<type>)); \
}
-# define UNORDERED_EXCEPTION_TEST_POSTFIX
# define UNORDERED_EPOINT_IMPL BOOST_ITEST_EPOINT
#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::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
#endif
+#define UNORDERED_EXCEPTION_TEST_POSTFIX RUN_TESTS()
+
#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)) \
- UNORDERED_EXCEPTION_TEST_POSTFIX
+ RUN_TESTS()
#define RUN_EXCEPTION_TESTS_OP(r, product) \
UNORDERED_EXCEPTION_TEST_CASE( \
Modified: branches/unordered/dev/libs/unordered/test/helpers/fwd.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/helpers/fwd.hpp (original)
+++ branches/unordered/dev/libs/unordered/test/helpers/fwd.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -15,8 +15,6 @@
signed char generate(signed char const*);
std::string generate(std::string*);
float generate(float const*);
- template <class T1, class T2>
- std::pair<T1, T2> generate(std::pair<T1, T2>*);
struct base_type {} base;
struct derived_type : base_type {} derived;
Modified: branches/unordered/dev/libs/unordered/test/helpers/generators.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/helpers/generators.hpp (original)
+++ branches/unordered/dev/libs/unordered/test/helpers/generators.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -16,7 +16,6 @@
#include <stdexcept>
#include <cstdlib>
#include <boost/type_traits/add_const.hpp>
-
#include "./fwd.hpp"
namespace test
@@ -27,29 +26,6 @@
srand(x);
}
};
-
- template <class T>
- struct generator;
-
- template <class T1, class T2> std::pair<T1, T2> generate(
- std::pair<T1, T2> const*)
- {
- static generator<T1> g1;
- static generator<T2> g2;
-
- return std::pair<T1, T2>(g1(), g2());
- }
-
- template <class T>
- struct generator
- {
- typedef T value_type;
- typedef BOOST_DEDUCED_TYPENAME boost::add_const<T>::type const_value_type;
- value_type operator()() const
- {
- return generate((const_value_type*) 0);
- }
- };
inline int generate(int const*)
{
@@ -73,13 +49,13 @@
{
using namespace std;
- static test::generator<char> char_gen;
+ char* char_ptr = 0;
std::string result;
int length = rand() % 10;
for(int i = 0; i < length; ++i)
- result += char_gen();
+ result += generate(char_ptr);
return result;
}
Modified: branches/unordered/dev/libs/unordered/test/helpers/random_values.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/helpers/random_values.hpp (original)
+++ branches/unordered/dev/libs/unordered/test/helpers/random_values.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -8,18 +8,102 @@
#include <list>
#include <algorithm>
+#include <boost/mpl/if.hpp>
#include "./generators.hpp"
+#include "./metafunctions.hpp"
namespace test
{
+ typedef enum {
+ default_generator,
+ generate_collisions
+ } random_generator;
+
+ template <class X>
+ struct unordered_generator_set
+ {
+ typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
+
+ random_generator type_;
+
+ unordered_generator_set(random_generator type)
+ : type_(type) {}
+
+ template <class T>
+ void fill(T& x, std::size_t len) {
+ value_type* value_ptr = 0;
+ int* int_ptr = 0;
+
+ for(std::size_t i = 0; i < len; ++i) {
+ value_type value = generate(value_ptr);
+
+ for(int count =
+ type_ == generate_collisions ?
+ generate(int_ptr) % 10 : 1;
+ count; --count) {
+ x.push_back(value);
+ }
+ }
+ }
+ };
+
+ template <class X>
+ struct unordered_generator_map
+ {
+ typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
+ typedef BOOST_DEDUCED_TYPENAME X::mapped_type mapped_type;
+
+ random_generator type_;
+
+ unordered_generator_map(random_generator type)
+ : type_(type) {}
+
+ template <class T>
+ void fill(T& x, std::size_t len) {
+ key_type* key_ptr = 0;
+ mapped_type* mapped_ptr = 0;
+ int* int_ptr = 0;
+
+ for(std::size_t i = 0; i < len; ++i) {
+ key_type key = generate(key_ptr);
+
+ for(int count =
+ type_ == generate_collisions ?
+ generate(int_ptr) % 10 : 1;
+ count; --count) {
+ x.push_back(std::pair<key_type const, mapped_type>(key, generate(mapped_ptr)));
+ }
+ }
+ }
+ };
+
+ template <class X>
+ struct unordered_generator_base
+ : public boost::mpl::if_<
+ test::is_set<X>,
+ test::unordered_generator_set<X>,
+ test::unordered_generator_map<X> >
+ {
+ };
+
+ template <class X>
+ struct unordered_generator : public unordered_generator_base<X>::type
+ {
+ typedef BOOST_DEDUCED_TYPENAME unordered_generator_base<X>::type base;
+
+ unordered_generator(random_generator const& type = default_generator)
+ : base(type) {}
+ };
+
template <class X>
struct random_values
: public std::list<BOOST_DEDUCED_TYPENAME X::value_type>
{
- random_values(int count) {
- typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
- static test::generator<value_type> gen;
- std::generate_n(std::back_inserter(*this), count, gen);
+ random_values(int count, test::random_generator const& generator =
+ test::default_generator)
+ {
+ static test::unordered_generator<X> gen(generator);
+ gen.fill(*this, count);
}
};
}
Modified: branches/unordered/dev/libs/unordered/test/helpers/test.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/helpers/test.hpp (original)
+++ branches/unordered/dev/libs/unordered/test/helpers/test.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -7,13 +7,90 @@
#define BOOST_UNORDERED_TEST_TEST_HEADER
#if defined(BOOST_UNORDERED_USE_TEST)
+
#include <boost/test/test_tools.hpp>
#define UNORDERED_CHECK(x) BOOST_CHECK(x)
#define UNORDERED_REQUIRE(x) BOOST_REQUIRE(x)
+#define UNORDERED_AUTO_TEST(x) BOOST_AUTO_TEST_CASE(x)
+#define RUN_TESTS()
+
#else
+
#include <boost/detail/lightweight_test.hpp>
+#include <boost/preprocessor/cat.hpp>
+
#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(); }
+#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
Modified: branches/unordered/dev/libs/unordered/test/objects/exception.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/objects/exception.hpp (original)
+++ branches/unordered/dev/libs/unordered/test/objects/exception.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -11,6 +11,7 @@
#include <cstddef>
#include <iostream>
#include <boost/limits.hpp>
+#include <new>
#include "../helpers/fwd.hpp"
#include "../helpers/allocator.hpp"
#include "./memory.hpp"
@@ -21,15 +22,9 @@
{
namespace detail
{
- struct malloc_allocator_holder {
- template <class T> struct apply {
- typedef test::malloc_allocator<T> type;
- };
- };
-
namespace
{
- test::detail::memory_tracker<malloc_allocator_holder> tracker;
+ test::detail::memory_tracker<test::malloc_allocator<int> > tracker;
}
}
@@ -37,6 +32,7 @@
class hash;
class equal_to;
template <class T> class allocator;
+ object generate(object const*);
class object
{
@@ -317,7 +313,7 @@
//return pointer(static_cast<T*>(::operator new(n * sizeof(T))));
}
- pointer allocate(size_type n, const_pointer u)
+ pointer allocate(size_type n, void const* u)
{
T* ptr = 0;
UNORDERED_SCOPE(allocator::allocate(size_type, const_pointer)) {
Modified: branches/unordered/dev/libs/unordered/test/objects/memory.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/objects/memory.hpp (original)
+++ branches/unordered/dev/libs/unordered/test/objects/memory.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -10,6 +10,8 @@
#include <map>
#include <boost/mpl/apply.hpp>
#include <boost/assert.hpp>
+#include <boost/unordered/detail/allocator.hpp>
+#include <boost/mpl/aux_/config/eti.hpp>
#include "../helpers/test.hpp"
namespace test
@@ -56,14 +58,28 @@
}
};
- struct default_allocator_holder { template <class T> struct apply {
- typedef std::allocator<T> type; }; };
+ template <class Alloc>
+ struct allocator_memory_type_gen {
+ typedef std::map<memory_area, memory_track, memory_area_compare,
+ Alloc> type;
+ };
- template <class AllocatorHolder = default_allocator_holder>
+#if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
+ template <>
+ struct allocator_memory_type_gen<int> {
+ typedef std::map<memory_area, memory_track, memory_area_compare> type;
+ };
+#endif
+
+ template <class Alloc = std::allocator<int> >
struct memory_tracker {
- typedef std::map<memory_area, memory_track, memory_area_compare,
- BOOST_DEDUCED_TYPENAME boost::mpl::apply1<AllocatorHolder, std::pair<memory_area const, memory_track> >::type
- > allocated_memory_type;
+ typedef BOOST_DEDUCED_TYPENAME
+ boost::unordered_detail::rebind_wrap<Alloc,
+ std::pair<memory_area const, memory_track> >::type
+ allocator_type;
+
+ typedef BOOST_DEDUCED_TYPENAME allocator_memory_type_gen<allocator_type>::type
+ allocated_memory_type;
allocated_memory_type allocated_memory;
unsigned int count_allocators;
Modified: branches/unordered/dev/libs/unordered/test/objects/minimal.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/objects/minimal.hpp (original)
+++ branches/unordered/dev/libs/unordered/test/objects/minimal.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -219,7 +219,8 @@
return pointer(static_cast<T*>(::operator new(n * sizeof(T))));
}
- pointer allocate(size_type n, const_pointer u)
+ template <class Y>
+ pointer allocate(size_type n, const_ptr<Y> u)
{
return pointer(static_cast<T*>(::operator new(n * sizeof(T))));
}
Modified: branches/unordered/dev/libs/unordered/test/objects/test.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/objects/test.hpp (original)
+++ branches/unordered/dev/libs/unordered/test/objects/test.hpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -23,6 +23,7 @@
class less;
class equal_to;
template <class T> class allocator;
+ object generate(object const*);
class object
{
@@ -62,44 +63,6 @@
}
};
- // This object is usd to test how well the containers cope with equivalent keys.
- class equivalent_object
- {
- friend class hash;
- friend class equal_to;
- friend class less;
- int tag1_, tag2_;
- public:
- explicit equivalent_object(int t1 = 0, int t2 = 0) : tag1_(t1), tag2_(t2) {}
-
- ~equivalent_object() {
- tag1_ = -1;
- tag2_ = -1;
- }
-
- friend bool operator==(equivalent_object const& x1, equivalent_object const& x2) {
- return x1.tag1_ == x2.tag1_;
- }
-
- friend bool operator!=(equivalent_object const& x1, equivalent_object const& x2) {
- return x1.tag1_ != x2.tag1_;
- }
-
- friend bool operator<(equivalent_object const& x1, equivalent_object const& x2) {
- return x1.tag1_ < x2.tag1_;
- }
-
- friend equivalent_object generate(equivalent_object const*) {
- signed char* x = 0;
- return equivalent_object(generate(x), generate(x));
- }
-
- friend std::ostream& operator<<(std::ostream& out, equivalent_object const& o)
- {
- return out<<"("<<o.tag1_<<","<<o.tag2_<<")";
- }
- };
-
class hash
{
int type_;
@@ -117,10 +80,6 @@
}
}
- std::size_t operator()(equivalent_object const& x) const {
- return x.tag1_;
- }
-
std::size_t operator()(int x) const {
return x;
}
@@ -151,10 +110,6 @@
}
}
- bool operator()(equivalent_object const& x1, equivalent_object const& x2) const {
- return x1 < x2;
- }
-
std::size_t operator()(int x1, int x2) const {
return x1 < x2;
}
@@ -181,10 +136,6 @@
}
}
- bool operator()(equivalent_object const& x1, equivalent_object const& x2) const {
- return x1 == x2;
- }
-
std::size_t operator()(int x1, int x2) const {
return x1 == x2;
}
@@ -205,7 +156,7 @@
namespace detail
{
namespace {
- test::detail::memory_tracker<test::detail::default_allocator_holder> tracker;
+ test::detail::memory_tracker<std::allocator<int> > tracker;
}
}
@@ -243,7 +194,7 @@
return ptr;
}
- pointer allocate(size_type n, const_pointer u)
+ pointer allocate(size_type n, void const* u)
{
pointer ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*) ptr, n, sizeof(T), tag_);
@@ -294,13 +245,6 @@
y = tmp;
}
- void swap(test::equivalent_object& x, test::equivalent_object& y) {
- test::equivalent_object tmp;
- tmp = x;
- x = y;
- y = tmp;
- }
-
void swap(test::hash& x, test::hash& y) {
test::hash tmp;
tmp = x;
Modified: branches/unordered/dev/libs/unordered/test/unordered/assign_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/assign_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/assign_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,7 +5,7 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include "../objects/test.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp"
@@ -13,10 +13,12 @@
#include <iostream>
+namespace assign_tests {
+
test::seed_t seed(96785);
template <class T>
-void assign_tests1(T* = 0)
+void assign_tests1(T*, test::random_generator generator = test::default_generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf;
BOOST_DEDUCED_TYPENAME T::key_equal eq;
@@ -32,7 +34,7 @@
std::cerr<<"assign_tests1.2\n";
{
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
T x(v.begin(), v.end());
test::ordered<T> tracker = test::create_ordered(x);
@@ -50,7 +52,7 @@
}
template <class T>
-void assign_tests2(T* = 0)
+void assign_tests2(T*, test::random_generator generator = test::default_generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf1(1);
BOOST_DEDUCED_TYPENAME T::hasher hf2(2);
@@ -61,7 +63,7 @@
std::cerr<<"assign_tests2.1\n";
{
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
T x1(v.begin(), v.end(), 0, hf1, eq1);
T x2(0, hf2, eq2);
x2 = x1;
@@ -72,7 +74,7 @@
std::cerr<<"assign_tests2.2\n";
{
- test::random_values<T> v1(100), v2(100);
+ test::random_values<T> v1(100, generator), v2(100, generator);
T x1(v1.begin(), v1.end(), 0, hf1, eq1, al1);
T x2(v2.begin(), v2.end(), 0, hf2, eq2, al2);
x2 = x1;
@@ -83,27 +85,24 @@
}
}
-int main()
-{
- assign_tests1((boost::unordered_set<int>*) 0);
- assign_tests1((boost::unordered_multiset<int>*) 0);
- assign_tests1((boost::unordered_map<int, int>*) 0);
- assign_tests1((boost::unordered_multimap<int, int>*) 0);
-
- assign_tests1((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- assign_tests1((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- assign_tests1((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- assign_tests1((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
-
- assign_tests1((boost::unordered_set<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- assign_tests1((boost::unordered_multiset<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- assign_tests1((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- assign_tests1((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
-
- assign_tests2((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- assign_tests2((boost::unordered_multiset<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- assign_tests2((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- assign_tests2((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
+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_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;
+
+using test::default_generator;
+using test::generate_collisions;
+
+UNORDERED_TEST(assign_tests1,
+ ((test_set)(test_multiset)(test_map)(test_multimap))
+ ((default_generator)(generate_collisions))
+)
+
+UNORDERED_TEST(assign_tests2,
+ ((test_set)(test_multiset)(test_map)(test_multimap))
+ ((default_generator)(generate_collisions))
+)
- return boost::report_errors();
}
+
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/at_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/at_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/at_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -4,10 +4,12 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include <string>
-int main() {
+namespace at_tests {
+
+UNORDERED_AUTO_TEST(at_tests) {
boost::unordered_map<std::string, int> x;
typedef boost::unordered_map<std::string, int>::iterator iterator;
@@ -23,6 +25,8 @@
}
catch(std::out_of_range) {
}
+}
- return boost::report_errors();
}
+
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/bucket_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/bucket_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/bucket_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,12 +5,14 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include <algorithm>
#include "../objects/test.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/helpers.hpp"
+namespace bucket_tests {
+
test::seed_t seed(54635);
template <class X>
@@ -48,17 +50,13 @@
}
}
-int main()
-{
- bucket_tests((boost::unordered_set<int>*) 0);
- bucket_tests((boost::unordered_multiset<int>*) 0);
- bucket_tests((boost::unordered_map<int, int>*) 0);
- bucket_tests((boost::unordered_multimap<int, int>*) 0);
-
- bucket_tests((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- bucket_tests((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- 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);
+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_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;
+
+UNORDERED_TEST(bucket_tests, ((test_set)(test_multiset)(test_map)(test_multimap)))
- return boost::report_errors();
}
+
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/compile_map.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/compile_map.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/compile_map.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -9,11 +9,11 @@
#include <boost/unordered_map.hpp>
#include <iostream>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include "../objects/minimal.hpp"
#include "./compile_tests.hpp"
-void test0()
+UNORDERED_AUTO_TEST(test0)
{
typedef std::pair<test::minimal::assignable const,
test::minimal::copy_constructible> value_type;
@@ -42,7 +42,7 @@
container_test(multimap, value);
}
-void equality_tests() {
+UNORDERED_AUTO_TEST(equality_tests) {
typedef std::pair<test::minimal::assignable const,
test::minimal::copy_constructible_equality_comparable> value_type;
value_type value(
@@ -68,8 +68,7 @@
equality_test(multimap, value);
}
-void test1()
-{
+UNORDERED_AUTO_TEST(test1) {
boost::hash<int> hash;
std::equal_to<int> equal_to;
int value = 0;
@@ -93,7 +92,7 @@
unordered_test(multimap, value, map_value, hash, equal_to);
}
-void test2()
+UNORDERED_AUTO_TEST(test2)
{
test::minimal::assignable assignable
= test::minimal::assignable::create();
@@ -147,12 +146,4 @@
unordered_test(multimap, assignable, map_value, hash, equal_to);
}
-int main()
-{
- test0();
- equality_tests();
- test1();
- test2();
-
- return boost::report_errors();
-}
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/compile_set.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/compile_set.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/compile_set.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -9,11 +9,11 @@
#include <boost/unordered_set.hpp>
#include <iostream>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include "../objects/minimal.hpp"
#include "./compile_tests.hpp"
-void test0()
+UNORDERED_AUTO_TEST(test0)
{
test::minimal::assignable assignable = test::minimal::assignable::create();
@@ -38,7 +38,7 @@
equality_test(multiset, assignable);
}
-void test1()
+UNORDERED_AUTO_TEST(test1)
{
boost::hash<int> hash;
std::equal_to<int> equal_to;
@@ -61,7 +61,7 @@
unordered_test(multiset, value, value, hash, equal_to);
}
-void test2()
+UNORDERED_AUTO_TEST(test2)
{
test::minimal::assignable assignable
= test::minimal::assignable::create();
@@ -97,10 +97,4 @@
unordered_test(multiset, assignable, assignable, hash, equal_to);
}
-int main() {
- test0();
- test1();
- test2();
-
- return boost::report_errors();
-}
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/constructor_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/constructor_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/constructor_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,7 +5,7 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include "../objects/test.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp"
@@ -15,10 +15,12 @@
#include <iostream>
+namespace constructor_tests {
+
test::seed_t seed(356730);
template <class T>
-void constructor_tests1(T* = 0)
+void constructor_tests1(T*, test::random_generator generator = test::default_generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf;
BOOST_DEDUCED_TYPENAME T::key_equal eq;
@@ -68,7 +70,7 @@
std::cerr<<"Construct 5\n";
{
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
T x(v.begin(), v.end(), 10000, hf, eq);
BOOST_TEST(x.bucket_count() >= 10000);
BOOST_TEST(test::equivalent(x.hash_function(), hf));
@@ -80,7 +82,7 @@
std::cerr<<"Construct 6\n";
{
- test::random_values<T> v(10);
+ test::random_values<T> v(10, generator);
T x(v.begin(), v.end(), 10000, hf);
BOOST_TEST(x.bucket_count() >= 10000);
BOOST_TEST(test::equivalent(x.hash_function(), hf));
@@ -92,7 +94,7 @@
std::cerr<<"Construct 7\n";
{
- test::random_values<T> v(100);
+ test::random_values<T> v(100, generator);
T x(v.begin(), v.end(), 100);
BOOST_TEST(x.bucket_count() >= 100);
BOOST_TEST(test::equivalent(x.hash_function(), hf));
@@ -104,7 +106,7 @@
std::cerr<<"Construct 8\n";
{
- test::random_values<T> v(1);
+ test::random_values<T> v(1, generator);
T x(v.begin(), v.end());
BOOST_TEST(test::equivalent(x.hash_function(), hf));
BOOST_TEST(test::equivalent(x.key_eq(), eq));
@@ -125,7 +127,7 @@
std::cerr<<"Construct 10\n";
{
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
T x(v.begin(), v.end(), 10000, hf, eq, al);
BOOST_TEST(x.bucket_count() >= 10000);
BOOST_TEST(test::equivalent(x.hash_function(), hf));
@@ -137,7 +139,7 @@
}
template <class T>
-void constructor_tests2(T* = 0)
+void constructor_tests2(T*, test::random_generator const& generator = test::default_generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf;
BOOST_DEDUCED_TYPENAME T::hasher hf1(1);
@@ -172,7 +174,7 @@
std::cerr<<"Construct 3\n";
{
- test::random_values<T> v(100);
+ test::random_values<T> v(100, generator);
T x(v.begin(), v.end(), 0, hf1, eq1);
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
BOOST_TEST(test::equivalent(x.key_eq(), eq1));
@@ -183,7 +185,7 @@
std::cerr<<"Construct 4\n";
{
- test::random_values<T> v(5);
+ test::random_values<T> v(5, generator);
T x(v.begin(), v.end(), 1000, hf1);
BOOST_TEST(x.bucket_count() >= 1000);
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
@@ -196,7 +198,7 @@
std::cerr<<"Construct 5\n";
{
- test::random_values<T> v(100);
+ test::random_values<T> v(100, generator);
T x(v.begin(), v.end(), 0, hf, eq, al1);
T y(x.begin(), x.end(), 0, hf1, eq1, al2);
test::check_container(x, v);
@@ -207,7 +209,7 @@
std::cerr<<"Construct 6\n";
{
- test::random_values<T> v(100);
+ test::random_values<T> v(100, generator);
T x(v.begin(), v.end(), 0, hf1, eq1);
T y(x.begin(), x.end(), 0, hf, eq);
test::check_container(x, v);
@@ -218,7 +220,7 @@
std::cerr<<"Construct 7\n";
{
- test::random_values<T> v(100);
+ test::random_values<T> v(100, generator);
T x(v.begin(), v.end(), 0, hf1, eq1);
T y(x.begin(), x.end(), 0, hf2, eq2);
test::check_container(x, v);
@@ -229,7 +231,7 @@
std::cerr<<"Construct 8 - from input iterator\n";
{
- test::random_values<T> v(100);
+ test::random_values<T> v(100, generator);
T x(test::input_iterator(v.begin()), test::input_iterator(v.end()), 0, hf1, eq1);
T y(test::input_iterator(x.begin()), test::input_iterator(x.end()), 0, hf2, eq2);
test::check_container(x, v);
@@ -255,57 +257,28 @@
test::check_equivalent_keys(x);
}
-int main()
-{
- std::cerr<<"Test1 unordered_set<int>\n";
- constructor_tests1((boost::unordered_set<int>*) 0);
- std::cerr<<"Test1 unordered_multiset<int>\n";
- constructor_tests1((boost::unordered_multiset<int>*) 0);
- std::cerr<<"Test1 unordered_map<int, int>\n";
- constructor_tests1((boost::unordered_map<int, int>*) 0);
- std::cerr<<"Test1 unordered_multimap<int, int>\n";
- constructor_tests1((boost::unordered_multimap<int, int>*) 0);
-
- std::cerr<<"Test1 unordered_set<test::object>\n";
- constructor_tests1((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"Test1 unordered_multiset<test::object>\n";
- constructor_tests1((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"Test1 unordered_map<test::object, test::object>\n";
- constructor_tests1((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"Test1 unordered_multimap<test::object, test::object>\n";
- constructor_tests1((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
-
- std::cerr<<"Test1 unordered_set<test::equivalent_object>\n";
- constructor_tests1((boost::unordered_set<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- std::cerr<<"Test1 unordered_multiset<test::equivalent_object>\n";
- constructor_tests1((boost::unordered_multiset<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- std::cerr<<"Test1 unordered_map<test::equivalent_object, test::equivalent_object>\n";
- constructor_tests1((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- std::cerr<<"Test1 unordered_multimap<test::equivalent_object, test::equivalent_object>\n";
- constructor_tests1((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
-
- std::cerr<<"Test2 unordered_set<test::object>\n";
- constructor_tests2((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"Test2 unordered_multiset<test::object>\n";
- constructor_tests2((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"Test2 unordered_map<test::object, test::object>\n";
- constructor_tests2((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"Test2 unordered_multimap<test::object, test::object>\n";
- constructor_tests2((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
-
- std::cerr<<"Test2 unordered_set<test::equivalent_object>\n";
- constructor_tests2((boost::unordered_set<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- std::cerr<<"Test2 unordered_multiset<test::equivalent_object>\n";
- constructor_tests2((boost::unordered_multiset<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- std::cerr<<"Test2 unordered_map<test::equivalent_object, test::equivalent_object>\n";
- constructor_tests2((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- std::cerr<<"Test2 unordered_multimap<test::equivalent_object, test::equivalent_object>\n";
- constructor_tests2((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
-
- std::cerr<<"Map Test unordered_map<test::object, test::object>\n";
- map_constructor_test((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"Map Test unordered_multimap<test::object, test::object>\n";
- map_constructor_test((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
+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_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;
+
+using test::default_generator;
+using test::generate_collisions;
+
+UNORDERED_TEST(constructor_tests1,
+ ((test_set)(test_multiset)(test_map)(test_multimap))
+ ((default_generator)(generate_collisions))
+)
+
+UNORDERED_TEST(constructor_tests2,
+ ((test_set)(test_multiset)(test_map)(test_multimap))
+ ((default_generator)(generate_collisions))
+)
+
+UNORDERED_TEST(map_constructor_test,
+ ((test_map)(test_multimap))
+)
- return boost::report_errors();
}
+
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/copy_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/copy_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/copy_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,7 +5,7 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include "../objects/test.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp"
@@ -14,8 +14,11 @@
test::seed_t seed(9063);
+namespace copy_tests
+{
+
template <class T>
-void copy_construct_tests1(T* = 0)
+void copy_construct_tests1(T*, test::random_generator const& generator = test::default_generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf;
BOOST_DEDUCED_TYPENAME T::key_equal eq;
@@ -60,7 +63,7 @@
}
template <class T>
-void copy_construct_tests2(T* ptr = 0)
+void copy_construct_tests2(T* ptr, test::random_generator const& generator = test::default_generator)
{
copy_construct_tests1(ptr);
@@ -90,22 +93,23 @@
}
}
-int main()
-{
- copy_construct_tests1((boost::unordered_set<int>*) 0);
- copy_construct_tests1((boost::unordered_multiset<int>*) 0);
- copy_construct_tests1((boost::unordered_map<int, int>*) 0);
- copy_construct_tests1((boost::unordered_multimap<int, int>*) 0);
-
- copy_construct_tests2((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- copy_construct_tests2((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- copy_construct_tests2((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- copy_construct_tests2((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
-
- copy_construct_tests2((boost::unordered_set<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- copy_construct_tests2((boost::unordered_multiset<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- copy_construct_tests2((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- copy_construct_tests2((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
+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_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;
+
+using test::default_generator;
+using test::generate_collisions;
+
+UNORDERED_TEST(copy_construct_tests1,
+ ((test_set)(test_multiset)(test_map)(test_multimap))
+)
+
+UNORDERED_TEST(copy_construct_tests2,
+ ((test_set)(test_multiset)(test_map)(test_multimap))
+ ((default_generator)(generate_collisions))
+)
- return boost::report_errors();
}
+
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/equivalent_keys_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/equivalent_keys_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/equivalent_keys_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,10 +5,10 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include <algorithm>
#include <map>
-#include <deque>
+#include <list>
#include "../helpers/tracker.hpp"
#include "../helpers/invariants.hpp"
@@ -32,7 +32,7 @@
test::check_equivalent_keys(x1);
}
-void set_tests()
+UNORDERED_AUTO_TEST(set_tests)
{
int values[][5] = {
{1},
@@ -55,9 +55,9 @@
test_equal_insertion<boost::unordered_multiset<int> >(values[4], values[4] + 3);
}
-void map_tests()
+UNORDERED_AUTO_TEST(map_tests)
{
- typedef std::deque<std::pair<int const, int> > values_type;
+ typedef std::list<std::pair<int const, int> > values_type;
values_type v[5];
v[0].push_back(std::pair<int const, int>(1,1));
v[1].push_back(std::pair<int const, int>(28,34));
@@ -76,10 +76,4 @@
v[i2].begin(), v[i2].end());
}
-int main()
-{
- set_tests();
- map_tests();
-
- return boost::report_errors();
-}
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/erase_equiv_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/erase_equiv_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/erase_equiv_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -7,7 +7,7 @@
// hairy with several tricky edge cases - so explicitly test each one.
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include <list>
#include <set>
#include <iostream>
@@ -52,8 +52,7 @@
typedef collide_map::value_type collide_value;
typedef std::list<collide_value> collide_list;
-
-void empty_range_tests()
+UNORDERED_AUTO_TEST(empty_range_tests)
{
collide_map x;
x.erase(x.begin(), x.end());
@@ -61,7 +60,7 @@
x.erase(x.end(), x.end());
}
-void single_item_tests()
+UNORDERED_AUTO_TEST(single_item_tests)
{
collide_list init;
init.push_back(collide_value(1,1));
@@ -75,7 +74,7 @@
BOOST_TEST(x.count(1) == 0 && x.size() == 0);
}
-void two_equivalent_item_tests()
+UNORDERED_AUTO_TEST(two_equivalent_item_tests)
{
collide_list init;
init.push_back(collide_value(1,1));
@@ -172,7 +171,7 @@
}
}
-void exhaustive_collide_tests()
+UNORDERED_AUTO_TEST(exhaustive_collide_tests)
{
std::cout<<"exhaustive_collide_tests:\n";
collide_map m;
@@ -180,20 +179,11 @@
std::cout<<"\n";
}
-void exhaustive_collide2_tests()
+UNORDERED_AUTO_TEST(exhaustive_collide2_tests)
{
std::cout<<"exhaustive_collide2_tests:\n";
exhaustive_erase_tests((collide_map2*) 0, 8, 4);
std::cout<<"\n";
}
-int main()
-{
- empty_range_tests();
- single_item_tests();
- two_equivalent_item_tests();
- exhaustive_collide_tests();
- exhaustive_collide2_tests();
-
- return boost::report_errors();
-}
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/erase_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/erase_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/erase_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,7 +5,7 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include <boost/next_prior.hpp>
#include "../objects/test.hpp"
#include "../helpers/random_values.hpp"
@@ -15,14 +15,17 @@
#include <iostream>
+namespace erase_tests
+{
+
test::seed_t seed(85638);
template <class Container>
-void erase_tests1(Container* = 0)
+void erase_tests1(Container*, test::random_generator generator = test::default_generator)
{
std::cerr<<"Erase by key.\n";
{
- test::random_values<Container> v(1000);
+ test::random_values<Container> v(1000, generator);
Container x(v.begin(), v.end());
for(BOOST_DEDUCED_TYPENAME test::random_values<Container>::iterator it = v.begin();
it != v.end(); ++it)
@@ -38,7 +41,7 @@
std::cerr<<"erase(begin()).\n";
{
- test::random_values<Container> v(1000);
+ test::random_values<Container> v(1000, generator);
Container x(v.begin(), v.end());
std::size_t size = x.size();
while(size > 0 && !x.empty())
@@ -56,7 +59,7 @@
std::cerr<<"erase(random position).\n";
{
- test::random_values<Container> v(1000);
+ test::random_values<Container> v(1000, generator);
Container x(v.begin(), v.end());
std::size_t size = x.size();
while(size > 0 && !x.empty())
@@ -87,7 +90,7 @@
std::cerr<<"erase(ranges).\n";
{
- test::random_values<Container> v(500);
+ test::random_values<Container> v(500, generator);
Container x(v.begin(), v.end());
std::size_t size = x.size();
@@ -109,42 +112,29 @@
std::cerr<<"clear().\n";
{
- test::random_values<Container> v(500);
+ test::random_values<Container> v(500, generator);
Container x(v.begin(), v.end());
x.clear();
BOOST_TEST(x.empty());
BOOST_TEST(x.begin() == x.end());
}
+
+ std::cerr<<"\n";
}
-int main()
-{
- std::cerr<<"Erase unordered_set<int>.\n";
- erase_tests1((boost::unordered_set<int>*) 0);
- std::cerr<<"\nErase unordered_multiset<int>.\n";
- erase_tests1((boost::unordered_multiset<int>*) 0);
- std::cerr<<"\nErase unordered_map<int>.\n";
- erase_tests1((boost::unordered_map<int, int>*) 0);
- std::cerr<<"\nErase unordered_multimap<int>.\n";
- erase_tests1((boost::unordered_multimap<int, int>*) 0);
-
- std::cerr<<"\nErase unordered_set<test::object,..>.\n";
- erase_tests1((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"\nErase unordered_multiset<test::object,..>.\n";
- erase_tests1((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"\nErase unordered_map<test::object,..>.\n";
- erase_tests1((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"\nErase unordered_multimap<test::object,..>.\n";
- erase_tests1((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
-
- std::cerr<<"\nErase unordered_set<test::equivalent_object,..>.\n";
- erase_tests1((boost::unordered_set<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- std::cerr<<"\nErase unordered_multiset<test::equivalent_object,..>.\n";
- erase_tests1((boost::unordered_multiset<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- std::cerr<<"\nErase unordered_map<test::equivalent_object,..>.\n";
- erase_tests1((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- std::cerr<<"\nErase unordered_multimap<test::equivalent_object,..>.\n";
- erase_tests1((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
+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_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;
+
+using test::default_generator;
+using test::generate_collisions;
+
+UNORDERED_TEST(erase_tests1,
+ ((test_set)(test_multiset)(test_map)(test_multimap))
+ ((default_generator)(generate_collisions))
+)
- return boost::report_errors();
}
+
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/find_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/find_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/find_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,21 +5,24 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include "../objects/test.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp"
#include "../helpers/helpers.hpp"
+namespace find_tests
+{
+
test::seed_t seed(78937);
template <class X>
-void find_tests1(X*)
+void find_tests1(X*, test::random_generator generator = test::default_generator)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
{
- test::random_values<X> v(500);
+ test::random_values<X> v(500, generator);
X x(v.begin(), v.end());
X const& x_const = x;
test::ordered<X> tracker = test::create_ordered(x);
@@ -46,7 +49,7 @@
(BOOST_DEDUCED_TYPENAME test::non_const_value_type<X>::type*) 0);
}
- test::random_values<X> v2(500);
+ test::random_values<X> v2(500, generator);
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator it2 =
v2.begin(); it2 != v2.end(); ++it2)
{
@@ -65,7 +68,7 @@
{
X x;
- test::random_values<X> v2(5);
+ test::random_values<X> v2(5, generator);
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator it3 =
v2.begin(); it3 != v2.end(); ++it3)
{
@@ -78,22 +81,19 @@
}
}
-int main()
-{
- find_tests1((boost::unordered_set<int>*) 0);
- find_tests1((boost::unordered_multiset<int>*) 0);
- find_tests1((boost::unordered_map<int, int>*) 0);
- find_tests1((boost::unordered_multimap<int, int>*) 0);
-
- find_tests1((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- find_tests1((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- find_tests1((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- find_tests1((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
-
- find_tests1((boost::unordered_set<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- find_tests1((boost::unordered_multiset<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- find_tests1((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- find_tests1((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
+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_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;
+
+using test::default_generator;
+using test::generate_collisions;
+
+UNORDERED_TEST(find_tests1,
+ ((test_set)(test_multiset)(test_map)(test_multimap))
+ ((default_generator)(generate_collisions))
+)
- return 0;
}
+
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/insert_stable_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/insert_stable_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/insert_stable_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,7 +5,7 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include <iostream>
@@ -39,7 +39,7 @@
}
}
-void stable_insert_test1() {
+UNORDERED_AUTO_TEST(stable_insert_test1) {
boost::unordered_multiset<insert_stable::member> x;
x.insert(insert_stable::member(1,1));
@@ -56,7 +56,7 @@
BOOST_TEST(it == end);
}
-void stable_insert_test2() {
+UNORDERED_AUTO_TEST(stable_insert_test2) {
boost::unordered_multimap<insert_stable::member, int> x;
typedef boost::unordered_multimap<insert_stable::member, int>::const_iterator iterator;
@@ -75,10 +75,4 @@
BOOST_TEST(it == end);
}
-int main()
-{
- stable_insert_test1();
- stable_insert_test2();
-
- return boost::report_errors();
-}
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/insert_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/insert_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/insert_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,7 +5,7 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include <boost/next_prior.hpp>
#include "../objects/test.hpp"
#include "../helpers/random_values.hpp"
@@ -19,7 +19,7 @@
test::seed_t seed(243432);
template <class X>
-void unique_insert_tests1(X* = 0)
+void unique_insert_tests1(X*, test::random_generator generator = test::default_generator)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef test::ordered<X> ordered;
@@ -29,7 +29,7 @@
X x;
test::ordered<X> tracker = test::create_ordered(x);
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it)
@@ -54,14 +54,14 @@
}
template <class X>
-void equivalent_insert_tests1(X* = 0)
+void equivalent_insert_tests1(X*, test::random_generator generator = test::default_generator)
{
std::cerr<<"insert(value) tests for containers with equivalent keys.\n";
X x;
test::ordered<X> tracker = test::create_ordered(x);
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it)
{
@@ -83,7 +83,7 @@
}
template <class X>
-void insert_tests2(X* = 0)
+void insert_tests2(X*, test::random_generator generator = test::default_generator)
{
typedef BOOST_DEDUCED_TYPENAME test::ordered<X> tracker_type;
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
@@ -96,7 +96,7 @@
X x;
tracker_type tracker = test::create_ordered(x);
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it)
{
@@ -122,7 +122,7 @@
X const& x_const = x;
tracker_type tracker = test::create_ordered(x);
- test::random_values<X> v(100);
+ test::random_values<X> v(100, generator);
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it)
{
@@ -148,7 +148,7 @@
const_iterator pos = x.begin();
tracker_type tracker = test::create_ordered(x);
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it)
{
@@ -173,7 +173,7 @@
X x;
tracker_type tracker = test::create_ordered(x);
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it)
{
@@ -196,7 +196,7 @@
{
X x;
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
x.insert(v.begin(), v.end());
test::check_container(x, v);
@@ -208,7 +208,7 @@
{
X x;
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
x.insert(test::input_iterator(v.begin()), test::input_iterator(v.end()));
test::check_container(x, v);
@@ -217,14 +217,14 @@
}
template <class X>
-void map_tests(X* = 0)
+void map_tests(X*, test::random_generator generator = test::default_generator)
{
std::cerr<<"map tests.\n";
X x;
test::ordered<X> tracker = test::create_ordered(x);
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it)
{
@@ -244,12 +244,12 @@
}
template <class X>
-void associative_insert_range_test(X* = 0)
+void associative_insert_range_test(X*, test::random_generator generator = test::default_generator)
{
std::cerr<<"associative_insert_range_test\n";
typedef std::list<std::pair<BOOST_DEDUCED_TYPENAME X::key_type, BOOST_DEDUCED_TYPENAME X::mapped_type> > list;
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
list l;
std::copy(v.begin(), v.end(), std::back_inserter(l));
@@ -260,42 +260,38 @@
int main()
{
- unique_insert_tests1((boost::unordered_set<int>*) 0);
- equivalent_insert_tests1((boost::unordered_multiset<int>*) 0);
- unique_insert_tests1((boost::unordered_map<int, int>*) 0);
- equivalent_insert_tests1((boost::unordered_multimap<int, int>*) 0);
-
- unique_insert_tests1((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- equivalent_insert_tests1((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- unique_insert_tests1((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- equivalent_insert_tests1((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
-
- unique_insert_tests1((boost::unordered_set<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- equivalent_insert_tests1((boost::unordered_multiset<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- unique_insert_tests1((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- equivalent_insert_tests1((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
-
- insert_tests2((boost::unordered_set<int>*) 0);
- insert_tests2((boost::unordered_multiset<int>*) 0);
- insert_tests2((boost::unordered_map<int, int>*) 0);
- insert_tests2((boost::unordered_multimap<int, int>*) 0);
-
- insert_tests2((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- insert_tests2((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- insert_tests2((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- insert_tests2((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
-
- insert_tests2((boost::unordered_set<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- insert_tests2((boost::unordered_multiset<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- insert_tests2((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
- insert_tests2((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
-
- map_tests((boost::unordered_map<int, int>*) 0);
- map_tests((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- map_tests((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
-
- associative_insert_range_test((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- associative_insert_range_test((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- associative_insert_range_test((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
+ 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_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;
+
+ unique_insert_tests1(test_set);
+ equivalent_insert_tests1(test_multiset);
+ unique_insert_tests1(test_map);
+ equivalent_insert_tests1(test_multimap);
+
+ unique_insert_tests1(test_set, test::generate_collisions);
+ equivalent_insert_tests1(test_multiset, test::generate_collisions);
+ unique_insert_tests1(test_map, test::generate_collisions);
+ equivalent_insert_tests1(test_multimap, test::generate_collisions);
+
+ insert_tests2(test_set);
+ insert_tests2(test_multiset);
+ insert_tests2(test_map);
+ insert_tests2(test_multimap);
+
+ insert_tests2(test_set, test::generate_collisions);
+ insert_tests2(test_multiset, test::generate_collisions);
+ insert_tests2(test_map, test::generate_collisions);
+ insert_tests2(test_multimap, test::generate_collisions);
+
+ map_tests(test_map);
+ map_tests(test_map, test::generate_collisions);
+
+ associative_insert_range_test(test_map);
+ associative_insert_range_test(test_map, test::generate_collisions);
+ associative_insert_range_test(test_multimap);
+ associative_insert_range_test(test_multimap, test::generate_collisions);
+
return boost::report_errors();
}
Modified: branches/unordered/dev/libs/unordered/test/unordered/load_factor_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/load_factor_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/load_factor_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,7 +5,7 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include <boost/limits.hpp>
#include "../helpers/random_values.hpp"
@@ -14,6 +14,9 @@
#pragma warning(disable:4127) // conditional expression is constant
#endif
+namespace load_factor_tests
+{
+
test::seed_t seed(783656);
template <class X>
@@ -63,21 +66,23 @@
insert_test(ptr, std::numeric_limits<float>::infinity());
}
-int main()
-{
- load_factor_tests((boost::unordered_set<int>*) 0);
- load_factor_tests((boost::unordered_multiset<int>*) 0);
- 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);
- load_factor_insert_tests((boost::unordered_multiset<int>*) 0);
- load_factor_insert_tests((boost::unordered_map<int, int>*) 0);
- load_factor_insert_tests((boost::unordered_multimap<int, int>*) 0);
+boost::unordered_set<int>* int_set_ptr;
+boost::unordered_multiset<int>* int_multiset_ptr;
+boost::unordered_map<int, int>* int_map_ptr;
+boost::unordered_multimap<int, int>* int_multimap_ptr;
+
+UNORDERED_TEST(load_factor_tests,
+ ((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr))
+)
+
+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)
#pragma warning(pop)
#pragma warning(disable:4127) // conditional expression is constant
Modified: branches/unordered/dev/libs/unordered/test/unordered/rehash_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/rehash_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/rehash_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,10 +5,13 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp"
+namespace rehash_tests
+{
+
test::seed_t seed(2974);
template <class X>
@@ -59,11 +62,15 @@
rehash_test1(ptr);
}
-int main() {
- rehash_tests((boost::unordered_set<int>*) 0);
- rehash_tests((boost::unordered_multiset<int>*) 0);
- rehash_tests((boost::unordered_map<int, int>*) 0);
- rehash_tests((boost::unordered_multimap<int, int>*) 0);
+boost::unordered_set<int>* int_set_ptr;
+boost::unordered_multiset<int>* int_multiset_ptr;
+boost::unordered_map<int, int>* int_map_ptr;
+boost::unordered_multimap<int, int>* int_multimap_ptr;
+
+UNORDERED_TEST(rehash_tests,
+ ((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr))
+)
- return boost::report_errors();
}
+
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/simple_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/simple_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/simple_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -7,7 +7,8 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
+#include <cstdlib>
#include <algorithm>
#include "../helpers/equivalent.hpp"
@@ -82,10 +83,10 @@
}
}
-int main()
+UNORDERED_AUTO_TEST(simple_tests)
{
- using namespace std;
- srand(14878);
+ using namespace std;
+ srand(14878);
std::cout<<"Test unordered_set.\n";
boost::unordered_set<int> set;
@@ -99,9 +100,9 @@
simple_test(multiset);
for(int i1 = 0; i1 < 1000; ++i1) {
- int count = rand() % 10, index = rand();
- for(int j = 0; j < count; ++j)
- multiset.insert(index);
+ int count = rand() % 10, index = rand();
+ for(int j = 0; j < count; ++j)
+ multiset.insert(index);
}
simple_test(multiset);
@@ -109,7 +110,7 @@
boost::unordered_map<int, int> map;
for(int i2 = 0; i2 < 1000; ++i2) {
- map.insert(std::pair<const int, int>(rand(), rand()));
+ map.insert(std::pair<const int, int>(rand(), rand()));
}
simple_test(map);
@@ -117,11 +118,11 @@
boost::unordered_multimap<int, int> multimap;
for(int i3 = 0; i3 < 1000; ++i3) {
- int count = rand() % 10, index = rand();
- for(int j = 0; j < count; ++j)
- multimap.insert(std::pair<const int, int>(index, rand()));
+ int count = rand() % 10, index = rand();
+ for(int j = 0; j < count; ++j)
+ multimap.insert(std::pair<const int, int>(index, rand()));
}
simple_test(multimap);
-
- return boost::report_errors();
}
+
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/swap_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/swap_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/swap_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -8,12 +8,15 @@
#include <iterator>
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
-#include <boost/detail/lightweight_test.hpp>
+#include "../helpers/test.hpp"
#include "../objects/test.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp"
#include "../helpers/invariants.hpp"
+namespace swap_tests
+{
+
test::seed_t seed(783472);
template <class X>
@@ -114,25 +117,18 @@
#endif
}
-int main()
-{
- std::cerr<<"Erase unordered_set<int>.\n";
- swap_tests1((boost::unordered_set<int>*) 0);
- std::cerr<<"\nErase unordered_multiset<int>.\n";
- swap_tests1((boost::unordered_multiset<int>*) 0);
- std::cerr<<"\nErase unordered_map<int>.\n";
- swap_tests1((boost::unordered_map<int, int>*) 0);
- std::cerr<<"\nErase unordered_multimap<int>.\n";
- swap_tests1((boost::unordered_multimap<int, int>*) 0);
-
- std::cerr<<"\nErase unordered_set<test::object,..>.\n";
- swap_tests2((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"\nErase unordered_multiset<test::object,..>.\n";
- swap_tests2((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"\nErase unordered_map<test::object,..>.\n";
- swap_tests2((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
- std::cerr<<"\nErase unordered_multimap<test::object,..>.\n";
- swap_tests2((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
+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_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;
+
+UNORDERED_TEST(swap_tests1,
+ ((test_set)(test_multiset)(test_map)(test_multimap))
+)
+
+UNORDERED_TEST(swap_tests2,
+ ((test_set)(test_multiset)(test_map)(test_multimap))
+)
- return boost::report_errors();
}
+RUN_TESTS()
Modified: branches/unordered/dev/libs/unordered/test/unordered/unnecessary_copy_tests.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/unnecessary_copy_tests.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/unnecessary_copy_tests.cpp 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -5,9 +5,10 @@
#include <boost/unordered_set.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
{
static int count;
@@ -17,22 +18,24 @@
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;
}
}
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
-namespace boost {
+namespace boost
#else
-namespace test {
+namespace unnecessary_copy_tests
#endif
- std::size_t hash_value(test::count_copies const&) {
+{
+ std::size_t hash_value(unnecessary_copy_tests::count_copies const&) {
return 0;
}
}
-namespace test {
+namespace unnecessary_copy_tests
+{
int count_copies::count;
template <class T>
@@ -45,14 +48,13 @@
x.insert(a);
BOOST_TEST(count_copies::count == 2);
}
-}
-int main()
-{
- 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);
+ 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;
- return boost::report_errors();
+ UNORDERED_TEST(unnecessary_copy_test, ((set)(multiset)(map)(multimap)))
}
+
+RUN_TESTS()
Modified: branches/unordered/dev/project-root.jam
==============================================================================
--- branches/unordered/dev/project-root.jam (original)
+++ branches/unordered/dev/project-root.jam 2008-03-24 13:22:22 EDT (Mon, 24 Mar 2008)
@@ -44,15 +44,10 @@
project unordered
: requirements
+ <include>.
<include>$(boost-root)
: # build everything in ./bin.v2
build-dir bin.v2
;
-
-
-
-
-
-
-
+path-constant BOOST_ROOT : $(boost-root) ;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk