From 1d2dc015a9d0ba9329764d1ae21746bd72a16429 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 12 Jun 2008 00:27:13 +0000 Subject: [PATCH] Merge all hash changes from trunk. [SVN r46343] --- hash/doc/Jamfile.v2 | 27 ++- hash/doc/changes.qbk | 46 ++++- hash/doc/disable.qbk | 2 +- hash/doc/hash.qbk | 2 +- hash/doc/intro.qbk | 10 +- hash/doc/links.qbk | 2 +- hash/doc/portability.qbk | 2 +- hash/doc/ref.xml | 9 +- hash/doc/thanks.qbk | 2 +- hash/doc/tutorial.qbk | 2 +- hash/examples/books.cpp | 2 +- hash/examples/books.hpp | 2 +- hash/examples/portable.cpp | 2 +- hash/test/Jamfile.v2 | 2 +- hash/test/compile_time.hpp | 2 +- hash/test/config.hpp | 2 +- hash/test/container_fwd_test.cpp | 4 +- hash/test/hash_built_in_array_test.cpp | 18 +- hash/test/hash_complex_test.cpp | 12 +- hash/test/hash_custom_test.cpp | 18 +- hash/test/hash_deprecated_headers.cpp | 4 +- hash/test/hash_deque_test.cpp | 8 +- hash/test/hash_float_test.cpp | 6 +- hash/test/hash_float_test.hpp | 146 +++++++------- hash/test/hash_friend_test.cpp | 18 +- hash/test/hash_function_pointer_test.cpp | 34 ++-- hash/test/hash_fwd_test.hpp | 2 +- hash/test/hash_fwd_test_1.cpp | 20 +- hash/test/hash_fwd_test_2.cpp | 8 +- hash/test/hash_global_namespace_test.cpp | 18 +- hash/test/hash_list_test.cpp | 8 +- hash/test/hash_long_double_test.cpp | 6 +- hash/test/hash_map_test.cpp | 8 +- hash/test/hash_map_test.hpp | 10 +- hash/test/hash_no_ext_fail_test.cpp | 4 +- hash/test/hash_no_ext_macro_1.cpp | 10 +- hash/test/hash_no_ext_macro_2.cpp | 10 +- hash/test/hash_number_test.cpp | 76 ++++---- hash/test/hash_pointer_test.cpp | 20 +- hash/test/hash_range_test.cpp | 30 +-- hash/test/hash_sequence_test.hpp | 10 +- hash/test/hash_set_test.cpp | 8 +- hash/test/hash_set_test.hpp | 10 +- hash/test/hash_string_test.cpp | 32 +-- hash/test/hash_value_array_test.cpp | 16 +- hash/test/hash_vector_test.cpp | 8 +- hash/test/link_ext_test.cpp | 6 +- hash/test/link_no_ext_test.cpp | 11 +- hash/test/link_test.cpp | 4 +- hash/test/link_test_2.cpp | 2 +- .../boost/functional/detail/container_fwd.hpp | 2 +- .../functional/detail/float_functions.hpp | 2 +- .../boost/functional/detail/hash_float.hpp | 81 ++++---- include/boost/functional/hash.hpp | 3 +- include/boost/functional/hash/deque.hpp | 2 +- include/boost/functional/hash/extensions.hpp | 182 +++++++++++++++++ include/boost/functional/hash/hash.hpp | 184 +----------------- include/boost/functional/hash/list.hpp | 2 +- include/boost/functional/hash/map.hpp | 2 +- include/boost/functional/hash/pair.hpp | 2 +- include/boost/functional/hash/set.hpp | 2 +- include/boost/functional/hash/vector.hpp | 2 +- include/boost/functional/hash_fwd.hpp | 2 +- 63 files changed, 637 insertions(+), 552 deletions(-) create mode 100644 include/boost/functional/hash/extensions.hpp diff --git a/hash/doc/Jamfile.v2 b/hash/doc/Jamfile.v2 index 9b7bdb7..731a228 100644 --- a/hash/doc/Jamfile.v2 +++ b/hash/doc/Jamfile.v2 @@ -1,9 +1,28 @@ -# Copyright 2005 Daniel James. +# Copyright 2005-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) -using quickbook ; - xml hash : hash.qbk ; -boostbook standalone : hash ; +boostbook standalone : hash : + admon.graphics.path=images/ + navig.graphics.path=images/ + html.stylesheet=boostbook.css + boost.root=../../../../.. + boost.libraries=../../../../libraries.htm + chunk.first.sections=1 + chunk.section.depth=2 + generate.section.toc.level=2 + toc.section.depth=1 + toc.max.depth=1 + + css + images + ; + +install css : [ glob $(BOOST_ROOT)/doc/src/*.css ] + : html ; +install images : [ glob $(BOOST_ROOT)/doc/src/images/*.png ] + : html/images ; +explicit css ; +explicit images ; diff --git a/hash/doc/changes.qbk b/hash/doc/changes.qbk index 4a15288..0288804 100644 --- a/hash/doc/changes.qbk +++ b/hash/doc/changes.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2007 Daniel James. +[/ Copyright 2005-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) ] @@ -9,24 +9,54 @@ * Initial Release -[h2 Changes in Boost 1.33.1] +[h2 Boost 1.33.1] * Fixed the points example, as pointed out by 沈慧峰. -[h2 Changes in Boost 1.34.0] +[h2 Boost 1.34.0] * Use declarations for standard classes, so that the library doesn't need to include all of their headers * Deprecated the `` headers. Now a single header, <[headerref boost/functional/hash.hpp]> is used. * Add support for the `BOOST_HASH_NO_EXTENSIONS` macro, which - disables the extensions to TR1 + disables the extensions to TR1. + * Minor improvements to the hash functions for floating point numbers. +* Update the portable example to hopefully be more generally portable. -[h2 Future Developments] +[h2 Boost 1.34.1] -* A more portable hash function, as described by Daniel Krügler in - [@http://lists.boost.org/boost-users/2005/08/13418.php a post to the boost users list]. -* Implement `hash_value` for more classes, including `std::complex`. +* [@http://svn.boost.org/trac/boost/ticket/952 Ticket 952]: + Suppress incorrect 64-bit warning on Visual C++. + +[h2 Boost 1.35.0] + +* Support for `long long`, `std::complex`. +* Improved algorithm for hashing floating point numbers: + * Improved portablity, as described by Daniel Krügler in + [@http://lists.boost.org/boost-users/2005/08/13418.php + a post to the boost users list]. + * Fits more information into each combine loop, which can reduce the + the number of times combine is called and hopefully give a better + quality hash function. + * Improved the algorithm for hashing floating point numbers. + * On Cygwin use a binary hash function for floating point numbers, as + Cygwin doesn't have decent floating point functions for `long double`. + * Never uses `fpclass` which doesn't support `long double`. + * [@http://svn.boost.org/trac/boost/ticket/1064 Ticket 1064]: + Removed unnecessary use of `errno`. +* Explicitly overload for more built in types. +* Minor improvements to the documentation. +* A few bug and warning fixes: + * [@http://svn.boost.org/trac/boost/ticket/1509 Ticket 1509]: + Suppress another Visual C++ warning. + * Some workarounds for the Sun compilers. + +[h2 Boost 1.36.0] + +* Stop using OpenBSD's dodgy `std::numeric_limits`. +* Using the boost typedefs for `long long` and `unsigned long long`. +* Move the extensions into their own header. [endsect] diff --git a/hash/doc/disable.qbk b/hash/doc/disable.qbk index 3d69431..27dec6b 100644 --- a/hash/doc/disable.qbk +++ b/hash/doc/disable.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2007 Daniel James. +[/ Copyright 2005-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) ] diff --git a/hash/doc/hash.qbk b/hash/doc/hash.qbk index 5bb200a..39d6d97 100644 --- a/hash/doc/hash.qbk +++ b/hash/doc/hash.qbk @@ -1,7 +1,7 @@ [library Boost.Functional/Hash [quickbook 1.4] [authors [James, Daniel]] - [copyright 2005 2006 2007 Daniel James] + [copyright 2005 2006 2007 2008 Daniel James] [purpose A TR1 hash function object that can be extended to hash user defined types] [category higher-order] diff --git a/hash/doc/intro.qbk b/hash/doc/intro.qbk index b6dac9e..bba5de3 100644 --- a/hash/doc/intro.qbk +++ b/hash/doc/intro.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2007 Daniel James. +[/ Copyright 2005-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) ] @@ -11,10 +11,13 @@ [def __tr1__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf TR1]] +[def __unordered__ [link unordered Boost.Unordered]] +[def __intrusive__ [link intrusive.unordered_set_unordered_multiset Boost.Intrusive]] [def __multi-index__ [@../../libs/multi_index/doc/index.html Boost Multi-Index Containers Library]] [def __multi-index-short__ [@../../libs/multi_index/doc/index.html Boost.MultiIndex]] +[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]] @@ -22,8 +25,9 @@ [def __hash-table__ [@http://en.wikipedia.org/wiki/Hash_table hash table]] [classref boost::hash] is an implementation of the __hash-function__ object -specified by the __tr1-full__ (TR1). It is intended for use as the default hash function -for unordered associative containers, and the __multi-index__'s hash indexes. +specified by the __tr1-full__ (TR1). It is the default hash function for +__unordered__, __intrusive__'s unordered associative containers, and +__multi-index-short__'s hash indicies and __bimap__'s `unordered_set_of`. As it is compliant with __tr1__, it will work with: diff --git a/hash/doc/links.qbk b/hash/doc/links.qbk index 5d9a269..405536e 100644 --- a/hash/doc/links.qbk +++ b/hash/doc/links.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2007 Daniel James. +[/ Copyright 2005-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) ] diff --git a/hash/doc/portability.qbk b/hash/doc/portability.qbk index 0e89196..e9100ce 100644 --- a/hash/doc/portability.qbk +++ b/hash/doc/portability.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2007 Daniel James. +[/ Copyright 2005-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) ] diff --git a/hash/doc/ref.xml b/hash/doc/ref.xml index 21acd4a..6bb32ce 100644 --- a/hash/doc/ref.xml +++ b/hash/doc/ref.xml @@ -1,6 +1,6 @@ @@ -406,6 +406,8 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + @@ -500,6 +502,10 @@ for(; first != last; ++first) + + + + @@ -797,6 +803,7 @@ return seed; + diff --git a/hash/doc/thanks.qbk b/hash/doc/thanks.qbk index 27bffc1..fcc5108 100644 --- a/hash/doc/thanks.qbk +++ b/hash/doc/thanks.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2007 Daniel James. +[/ Copyright 2005-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) ] diff --git a/hash/doc/tutorial.qbk b/hash/doc/tutorial.qbk index e30a181..eaf9a95 100644 --- a/hash/doc/tutorial.qbk +++ b/hash/doc/tutorial.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2007 Daniel James. +[/ Copyright 2005-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) ] diff --git a/hash/examples/books.cpp b/hash/examples/books.cpp index 466ff44..2615564 100644 --- a/hash/examples/books.cpp +++ b/hash/examples/books.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/hash/examples/books.hpp b/hash/examples/books.hpp index 4acdd86..c0cf414 100644 --- a/hash/examples/books.hpp +++ b/hash/examples/books.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/hash/examples/portable.cpp b/hash/examples/portable.cpp index 962dca2..98026c1 100644 --- a/hash/examples/portable.cpp +++ b/hash/examples/portable.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/hash/test/Jamfile.v2 b/hash/test/Jamfile.v2 index b0ac974..da8a0f9 100644 --- a/hash/test/Jamfile.v2 +++ b/hash/test/Jamfile.v2 @@ -1,5 +1,5 @@ -# Copyright 2005-2007 Daniel James. +# Copyright 2005-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) diff --git a/hash/test/compile_time.hpp b/hash/test/compile_time.hpp index 99589d1..873df13 100644 --- a/hash/test/compile_time.hpp +++ b/hash/test/compile_time.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/hash/test/config.hpp b/hash/test/config.hpp index 12d9aca..9ef55b7 100644 --- a/hash/test/config.hpp +++ b/hash/test/config.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/hash/test/container_fwd_test.cpp b/hash/test/container_fwd_test.cpp index 232c357..5c3c5e1 100644 --- a/hash/test/container_fwd_test.cpp +++ b/hash/test/container_fwd_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -77,7 +77,7 @@ static void test(std::pair const&) #include #include -int main() +int main(int, char**) { std::deque x1; std::list x2; diff --git a/hash/test/hash_built_in_array_test.cpp b/hash/test/hash_built_in_array_test.cpp index 5904615..127d388 100644 --- a/hash/test/hash_built_in_array_test.cpp +++ b/hash/test/hash_built_in_array_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -13,7 +13,7 @@ # endif #endif -#include +#include #ifdef TEST_EXTENSIONS @@ -37,11 +37,11 @@ void array_int_test() int array3[2] = {2, 3}; HASH_NAMESPACE::hash hasher3; - BOOST_TEST(hasher1(array1) + BOOST_CHECK(hasher1(array1) == HASH_NAMESPACE::hash_range(array1, array1 + length1)); - BOOST_TEST(hasher2(array2) + BOOST_CHECK(hasher2(array2) == HASH_NAMESPACE::hash_range(array2, array2 + length2)); - BOOST_TEST(hasher3(array3) + BOOST_CHECK(hasher3(array3) == HASH_NAMESPACE::hash_range(array3, array3 + length3)); } @@ -59,17 +59,17 @@ void two_dimensional_array_test() HASH_NAMESPACE::hash_combine(seed1, seed2); } - BOOST_TEST(hasher(array) == seed1); - BOOST_TEST(hasher(array) == HASH_NAMESPACE::hash_range(array, array + 3)); + BOOST_CHECK(hasher(array) == seed1); + BOOST_CHECK(hasher(array) == HASH_NAMESPACE::hash_range(array, array + 3)); } #endif // TEST_EXTENSIONS -int main() +int test_main(int, char**) { #ifdef TEST_EXTENSIONS array_int_test(); two_dimensional_array_test(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_complex_test.cpp b/hash/test/hash_complex_test.cpp index a0707b5..890dc0a 100644 --- a/hash/test/hash_complex_test.cpp +++ b/hash/test/hash_complex_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -13,7 +13,7 @@ # endif #endif -#include +#include #ifdef TEST_EXTENSIONS @@ -41,13 +41,13 @@ void generic_complex_tests(std::complex v) { HASH_NAMESPACE::hash > complex_hasher; - BOOST_TEST(complex_hasher(v) == complex_hasher(v)); + BOOST_CHECK(complex_hasher(v) == complex_hasher(v)); HASH_NAMESPACE::hash real_hasher; T real = v.real(); T imag = v.imag(); - BOOST_TEST(real_hasher(real) == complex_hasher(std::complex(real))); + BOOST_CHECK(real_hasher(real) == complex_hasher(std::complex(real))); if(imag != 0 && real_hasher(real) == complex_hasher(v)) { std::ostringstream os; @@ -90,7 +90,7 @@ void complex_integral_tests(Integer*) } } -int main() +int test_main(int, char**) { complex_float_tests((float*) 0); complex_float_tests((double*) 0); @@ -102,7 +102,7 @@ int main() complex_integral_tests((unsigned int*) 0); complex_integral_tests((unsigned long*) 0); - return boost::report_errors(); + return 0; } #endif diff --git a/hash/test/hash_custom_test.cpp b/hash/test/hash_custom_test.cpp index 8df3e83..ccd59df 100644 --- a/hash/test/hash_custom_test.cpp +++ b/hash/test/hash_custom_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -48,7 +48,7 @@ namespace boost # endif #endif -#include +#include #ifdef TEST_EXTENSIONS @@ -59,13 +59,13 @@ namespace boost void custom_tests() { HASH_NAMESPACE::hash custom_hasher; - BOOST_TEST(custom_hasher(10) == 100u); + BOOST_CHECK(custom_hasher(10) == 100u); test::custom x(55); - BOOST_TEST(custom_hasher(x) == 550u); + BOOST_CHECK(custom_hasher(x) == 550u); { using namespace HASH_NAMESPACE; - BOOST_TEST(custom_hasher(x) == hash_value(x)); + BOOST_CHECK(custom_hasher(x) == hash_value(x)); } std::vector custom_vector; @@ -83,17 +83,17 @@ void custom_tests() HASH_NAMESPACE::hash_combine(seed2, 250u); HASH_NAMESPACE::hash_combine(seed2, 350u); - BOOST_TEST(seed == + BOOST_CHECK(seed == HASH_NAMESPACE::hash_range(custom_vector.begin(), custom_vector.end())); - BOOST_TEST(seed == seed2); + BOOST_CHECK(seed == seed2); } #endif // TEST_EXTENSIONS -int main() +int test_main(int, char**) { #ifdef TEST_EXTENSIONS custom_tests(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_deprecated_headers.cpp b/hash/test/hash_deprecated_headers.cpp index 3257d9b..5ebab8f 100644 --- a/hash/test/hash_deprecated_headers.cpp +++ b/hash/test/hash_deprecated_headers.cpp @@ -1,5 +1,5 @@ -// Copyright 2007 Daniel James. +// Copyright 2007-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) @@ -19,7 +19,7 @@ #include -int main() { +int main(int, char**) { std::vector v; boost::hash > x; x(v); diff --git a/hash/test/hash_deque_test.cpp b/hash/test/hash_deque_test.cpp index 7238319..5348a03 100644 --- a/hash/test/hash_deque_test.cpp +++ b/hash/test/hash_deque_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -13,7 +13,7 @@ # endif #endif -#include +#include #ifdef TEST_EXTENSIONS @@ -25,11 +25,11 @@ using std::deque; #endif // TEST_EXTENSIONS -int main() +int test_main(int, char**) { #ifdef TEST_EXTENSIONS deque_tests::deque_hash_integer_tests(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_float_test.cpp b/hash/test/hash_float_test.cpp index 6ceda4b..7c5d59c 100644 --- a/hash/test/hash_float_test.cpp +++ b/hash/test/hash_float_test.cpp @@ -1,11 +1,11 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) #include "hash_float_test.hpp" -int main() +int test_main(int, char**) { std::cerr<<"Compiler: "< #endif -#include +#include #include #include @@ -29,12 +29,12 @@ void float_tests(char const* name, T* = 0) std::cerr<<"\n" <<"Testing " BOOST_STRINGIZE(HASH_NAMESPACE) "::hash<"<\n" <<"\n" - <<"std::numeric_limits::digits = " - <::digits<<"\n" - <<"std::numeric_limits::digits = " - <::digits<<"\n" - <<"std::numeric_limits::digits = " - <::digits<<"\n" + <<"boost::hash_detail::limits::digits = " + <::digits<<"\n" + <<"boost::hash_detail::limits::digits = " + <::digits<<"\n" + <<"boost::hash_detail::limits::digits = " + <::digits<<"\n" <<"\n" ; @@ -43,11 +43,11 @@ void float_tests(char const* name, T* = 0) T zero = 0; T minus_zero = (T) -1 * zero; - BOOST_TEST(zero == minus_zero); - BOOST_TEST(x1(zero) == x1(minus_zero)); + BOOST_CHECK(zero == minus_zero); + BOOST_CHECK(x1(zero) == x1(minus_zero)); - BOOST_TEST(x1(zero) == HASH_NAMESPACE::hash_value(zero)); - BOOST_TEST(x1(minus_zero) == HASH_NAMESPACE::hash_value(minus_zero)); + BOOST_CHECK(x1(zero) == HASH_NAMESPACE::hash_value(zero)); + BOOST_CHECK(x1(minus_zero) == HASH_NAMESPACE::hash_value(minus_zero)); using namespace std; @@ -55,33 +55,33 @@ void float_tests(char const* name, T* = 0) #if defined(__BORLANDC__) std::cerr<<"Not running infinity checks on Borland, as it causes it to crash.\n"; #else - if(std::numeric_limits::has_infinity) { + if(boost::hash_detail::limits::has_infinity) { T infinity = -log(zero); T infinity2 = (T) 1. / zero; T infinity3 = (T) -1. / minus_zero; - T infinity4 = std::numeric_limits::infinity(); + T infinity4 = boost::hash_detail::limits::infinity(); T minus_infinity = log(zero); T minus_infinity2 = (T) -1. / zero; T minus_infinity3 = (T) 1. / minus_zero; - BOOST_TEST(x1(infinity) == HASH_NAMESPACE::hash_value(infinity)); - BOOST_TEST(x1(minus_infinity) + BOOST_CHECK(x1(infinity) == HASH_NAMESPACE::hash_value(infinity)); + BOOST_CHECK(x1(minus_infinity) == HASH_NAMESPACE::hash_value(minus_infinity)); if(infinity == infinity2) - BOOST_TEST(x1(infinity) == x1(infinity2)); + BOOST_CHECK(x1(infinity) == x1(infinity2)); if(infinity == infinity3) - BOOST_TEST(x1(infinity) == x1(infinity3)); + BOOST_CHECK(x1(infinity) == x1(infinity3)); if(infinity == infinity4) - BOOST_TEST(x1(infinity) == x1(infinity4)); + BOOST_CHECK(x1(infinity) == x1(infinity4)); if(minus_infinity == minus_infinity2) - BOOST_TEST(x1(minus_infinity) == x1(minus_infinity2)); + BOOST_CHECK(x1(minus_infinity) == x1(minus_infinity2)); if(minus_infinity == minus_infinity3) - BOOST_TEST(x1(minus_infinity) == x1(minus_infinity3)); + BOOST_CHECK(x1(minus_infinity) == x1(minus_infinity3)); - BOOST_TEST(infinity != minus_infinity); + BOOST_CHECK(infinity != minus_infinity); if(x1(infinity) == x1(minus_infinity)) { std::cerr<<"x1(infinity) == x1(-infinity) == "<::has_denorm) { - if(x1(std::numeric_limits::denorm_min()) == x1(infinity)) { + if(boost::hash_detail::limits::has_denorm) { + if(x1(boost::hash_detail::limits::denorm_min()) == x1(infinity)) { std::cerr<<"x1(denorm_min) == x1(infinity) == "<::denorm_min()) == x1(minus_infinity)) { + if(x1(boost::hash_detail::limits::denorm_min()) == x1(minus_infinity)) { std::cerr<<"x1(denorm_min) == x1(-infinity) == "<::has_quiet_NaN) { - if(x1(std::numeric_limits::quiet_NaN()) == x1(infinity)) { + if(boost::hash_detail::limits::has_quiet_NaN) { + if(x1(boost::hash_detail::limits::quiet_NaN()) == x1(infinity)) { std::cerr<<"x1(quiet_NaN) == x1(infinity) == "<::quiet_NaN()) == x1(minus_infinity)) { + if(x1(boost::hash_detail::limits::quiet_NaN()) == x1(minus_infinity)) { std::cerr<<"x1(quiet_NaN) == x1(-infinity) == "<::max)(); + T max = (boost::hash_detail::limits::max)(); T half_max = max / 2; T quarter_max = max / 4; T three_quarter_max = max - quarter_max; - BOOST_TEST(x1(max) == HASH_NAMESPACE::hash_value(max)); - BOOST_TEST(x1(half_max) == HASH_NAMESPACE::hash_value(half_max)); - BOOST_TEST(x1(quarter_max) == HASH_NAMESPACE::hash_value(quarter_max)); - BOOST_TEST(x1(three_quarter_max) == HASH_NAMESPACE::hash_value(three_quarter_max)); + BOOST_CHECK(x1(max) == HASH_NAMESPACE::hash_value(max)); + BOOST_CHECK(x1(half_max) == HASH_NAMESPACE::hash_value(half_max)); + BOOST_CHECK(x1(quarter_max) == HASH_NAMESPACE::hash_value(quarter_max)); + BOOST_CHECK(x1(three_quarter_max) == HASH_NAMESPACE::hash_value(three_quarter_max)); // The '!=' tests could legitimately fail, but with my hash it indicates a bug. - BOOST_TEST(x1(max) == x1(max)); - BOOST_TEST(x1(max) != x1(quarter_max)); - BOOST_TEST(x1(max) != x1(half_max)); - BOOST_TEST(x1(max) != x1(three_quarter_max)); - BOOST_TEST(x1(quarter_max) == x1(quarter_max)); - BOOST_TEST(x1(quarter_max) != x1(half_max)); - BOOST_TEST(x1(quarter_max) != x1(three_quarter_max)); - BOOST_TEST(x1(half_max) == x1(half_max)); - BOOST_TEST(x1(half_max) != x1(three_quarter_max)); - BOOST_TEST(x1(three_quarter_max) == x1(three_quarter_max)); + BOOST_CHECK(x1(max) == x1(max)); + BOOST_CHECK(x1(max) != x1(quarter_max)); + BOOST_CHECK(x1(max) != x1(half_max)); + BOOST_CHECK(x1(max) != x1(three_quarter_max)); + BOOST_CHECK(x1(quarter_max) == x1(quarter_max)); + BOOST_CHECK(x1(quarter_max) != x1(half_max)); + BOOST_CHECK(x1(quarter_max) != x1(three_quarter_max)); + BOOST_CHECK(x1(half_max) == x1(half_max)); + BOOST_CHECK(x1(half_max) != x1(three_quarter_max)); + BOOST_CHECK(x1(three_quarter_max) == x1(three_quarter_max)); // Intel with gcc stdlib sometimes segfaults on calls to asin and acos. #if !((defined(__INTEL_COMPILER) || defined(__ICL) || \ @@ -137,55 +137,55 @@ void float_tests(char const* name, T* = 0) T v1 = asin((T) 1); T v2 = acos((T) 0); if(v1 == v2) - BOOST_TEST(x1(v1) == x1(v2)); - BOOST_TEST(x1(v1) == HASH_NAMESPACE::hash_value(v1)); - BOOST_TEST(x1(v2) == HASH_NAMESPACE::hash_value(v2)); + BOOST_CHECK(x1(v1) == x1(v2)); + BOOST_CHECK(x1(v1) == HASH_NAMESPACE::hash_value(v1)); + BOOST_CHECK(x1(v2) == HASH_NAMESPACE::hash_value(v2)); #endif - BOOST_TEST(x1(std::numeric_limits::epsilon()) == - HASH_NAMESPACE::hash_value(std::numeric_limits::epsilon())); + BOOST_CHECK(x1(boost::hash_detail::limits::epsilon()) == + HASH_NAMESPACE::hash_value(boost::hash_detail::limits::epsilon())); - BOOST_TEST(std::numeric_limits::epsilon() != (T) 0); - if(x1(std::numeric_limits::epsilon()) == x1((T) 0)) + BOOST_CHECK(boost::hash_detail::limits::epsilon() != (T) 0); + if(x1(boost::hash_detail::limits::epsilon()) == x1((T) 0)) std::cerr<<"x1(epsilon) == x1(0) == "<::epsilon() != (T) 0); - if(x1(-std::numeric_limits::epsilon()) == x1((T) 0)) + BOOST_CHECK(-boost::hash_detail::limits::epsilon() != (T) 0); + if(x1(-boost::hash_detail::limits::epsilon()) == x1((T) 0)) std::cerr<<"x1(-epsilon) == x1(0) == "<::epsilon() != (T) 1); - if(x1((T) 1 + std::numeric_limits::epsilon()) == x1((T) 1)) + BOOST_CHECK((T) 1 + boost::hash_detail::limits::epsilon() != (T) 1); + if(x1((T) 1 + boost::hash_detail::limits::epsilon()) == x1((T) 1)) std::cerr<<"x1(1 + epsilon) == x1(1) == "<::epsilon() != (T) 1); - if(x1((T) 1 - std::numeric_limits::epsilon()) == x1((T) 1)) + BOOST_CHECK((T) 1 - boost::hash_detail::limits::epsilon() != (T) 1); + if(x1((T) 1 - boost::hash_detail::limits::epsilon()) == x1((T) 1)) std::cerr<<"x1(1 - epsilon) == x1(1) == "<::epsilon() != (T) -1); - if(x1((T) -1 + std::numeric_limits::epsilon()) == x1((T) -1)) + BOOST_CHECK((T) -1 + boost::hash_detail::limits::epsilon() != (T) -1); + if(x1((T) -1 + boost::hash_detail::limits::epsilon()) == x1((T) -1)) std::cerr<<"x1(-1 + epsilon) == x1(-1) == "<::epsilon() != (T) -1); - if(x1((T) -1 - std::numeric_limits::epsilon()) == x1((T) -1)) + BOOST_CHECK((T) -1 - boost::hash_detail::limits::epsilon() != (T) -1); + if(x1((T) -1 - boost::hash_detail::limits::epsilon()) == x1((T) -1)) std::cerr<<"x1(-1 - epsilon) == x1(-1) == "<::has_denorm) { - if(x1(std::numeric_limits::denorm_min()) == x1(zero)) { + if(boost::hash_detail::limits::has_denorm) { + if(x1(boost::hash_detail::limits::denorm_min()) == x1(zero)) { std::cerr<<"x1(denorm_min) == x1(zero) == "<::denorm_min()) != - HASH_NAMESPACE::hash_value(std::numeric_limits::denorm_min())) + if(x1(boost::hash_detail::limits::denorm_min()) != + HASH_NAMESPACE::hash_value(boost::hash_detail::limits::denorm_min())) { - std::cerr<<"x1(std::numeric_limits::denorm_min()) = " - << x1(std::numeric_limits::denorm_min()) - << "\nhash_value(std::numeric_limits::denorm_min()) = " + std::cerr<<"x1(boost::hash_detail::limits::denorm_min()) = " + << x1(boost::hash_detail::limits::denorm_min()) + << "\nhash_value(boost::hash_detail::limits::denorm_min()) = " << HASH_NAMESPACE::hash_value( - std::numeric_limits::denorm_min()) + boost::hash_detail::limits::denorm_min()) << "\nx1(0) = "<::has_quiet_NaN) { - if(x1(std::numeric_limits::quiet_NaN()) == x1(1.0)) { + if(boost::hash_detail::limits::has_quiet_NaN) { + if(x1(boost::hash_detail::limits::quiet_NaN()) == x1(1.0)) { std::cerr<<"x1(quiet_NaN) == x1(1.0) == "<::quiet_NaN()) == - HASH_NAMESPACE::hash_value(std::numeric_limits::quiet_NaN())); + BOOST_CHECK(x1(boost::hash_detail::limits::quiet_NaN()) == + HASH_NAMESPACE::hash_value(boost::hash_detail::limits::quiet_NaN())); } #endif } diff --git a/hash/test/hash_friend_test.cpp b/hash/test/hash_friend_test.cpp index 6c6596e..4253f03 100644 --- a/hash/test/hash_friend_test.cpp +++ b/hash/test/hash_friend_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2006-2007 Daniel James. +// 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) @@ -50,7 +50,7 @@ namespace boost # endif #endif -#include +#include #ifdef TEST_EXTENSIONS @@ -61,13 +61,13 @@ namespace boost void custom_tests() { HASH_NAMESPACE::hash > custom_hasher; - BOOST_TEST(custom_hasher(10) == 100u); + BOOST_CHECK(custom_hasher(10) == 100u); test::custom x(55); - BOOST_TEST(custom_hasher(x) == 550u); + BOOST_CHECK(custom_hasher(x) == 550u); { using namespace HASH_NAMESPACE; - BOOST_TEST(custom_hasher(x) == hash_value(x)); + BOOST_CHECK(custom_hasher(x) == hash_value(x)); } std::vector > custom_vector; @@ -85,17 +85,17 @@ void custom_tests() HASH_NAMESPACE::hash_combine(seed2, 250u); HASH_NAMESPACE::hash_combine(seed2, 350u); - BOOST_TEST(seed == + BOOST_CHECK(seed == HASH_NAMESPACE::hash_range(custom_vector.begin(), custom_vector.end())); - BOOST_TEST(seed == seed2); + BOOST_CHECK(seed == seed2); } #endif // TEST_EXTENSIONS -int main() +int test_main(int, char**) { #ifdef TEST_EXTENSIONS custom_tests(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_function_pointer_test.cpp b/hash/test/hash_function_pointer_test.cpp index 07a0300..f3b8111 100644 --- a/hash/test/hash_function_pointer_test.cpp +++ b/hash/test/hash_function_pointer_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -11,7 +11,7 @@ # include #endif -#include +#include #include #include @@ -32,31 +32,31 @@ void function_pointer_tests() HASH_NAMESPACE::hash hasher_void; HASH_NAMESPACE::hash hasher_int; - BOOST_TEST(&void_func1 != &void_func2); - BOOST_TEST(&int_func1 != &int_func2); + BOOST_CHECK(&void_func1 != &void_func2); + BOOST_CHECK(&int_func1 != &int_func2); - BOOST_TEST(hasher_void(0) == hasher_void(0)); - BOOST_TEST(hasher_void(&void_func1) == hasher_void(&void_func1)); - BOOST_TEST(hasher_void(&void_func1) != hasher_void(&void_func2)); - BOOST_TEST(hasher_void(&void_func1) != hasher_void(0)); - BOOST_TEST(hasher_int(0) == hasher_int(0)); - BOOST_TEST(hasher_int(&int_func1) == hasher_int(&int_func1)); - BOOST_TEST(hasher_int(&int_func1) != hasher_int(&int_func2)); - BOOST_TEST(hasher_int(&int_func1) != hasher_int(0)); + BOOST_CHECK(hasher_void(0) == hasher_void(0)); + BOOST_CHECK(hasher_void(&void_func1) == hasher_void(&void_func1)); + BOOST_CHECK(hasher_void(&void_func1) != hasher_void(&void_func2)); + BOOST_CHECK(hasher_void(&void_func1) != hasher_void(0)); + BOOST_CHECK(hasher_int(0) == hasher_int(0)); + BOOST_CHECK(hasher_int(&int_func1) == hasher_int(&int_func1)); + BOOST_CHECK(hasher_int(&int_func1) != hasher_int(&int_func2)); + BOOST_CHECK(hasher_int(&int_func1) != hasher_int(0)); #if defined(TEST_EXTENSIONS) - BOOST_TEST(hasher_void(&void_func1) + BOOST_CHECK(hasher_void(&void_func1) == HASH_NAMESPACE::hash_value(&void_func1)); - BOOST_TEST(hasher_int(&int_func1) + BOOST_CHECK(hasher_int(&int_func1) == HASH_NAMESPACE::hash_value(&int_func1)); // This isn't specified in Peter's proposal: - BOOST_TEST(hasher_void(0) == 0); + BOOST_CHECK(hasher_void(0) == 0); #endif } -int main() +int test_main(int, char**) { function_pointer_tests(); - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_fwd_test.hpp b/hash/test/hash_fwd_test.hpp index 30ad609..4822510 100644 --- a/hash/test/hash_fwd_test.hpp +++ b/hash/test/hash_fwd_test.hpp @@ -1,5 +1,5 @@ -// Copyright 2006-2007 Daniel James. +// 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) diff --git a/hash/test/hash_fwd_test_1.cpp b/hash/test/hash_fwd_test_1.cpp index e5106a3..b73c9ce 100644 --- a/hash/test/hash_fwd_test_1.cpp +++ b/hash/test/hash_fwd_test_1.cpp @@ -1,5 +1,5 @@ -// Copyright 2006-2007 Daniel James. +// 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) @@ -7,7 +7,7 @@ #include "./hash_fwd_test.hpp" -#include +#include #if defined(TEST_EXTENSIONS) && !defined(TEST_STD_INCLUDES) @@ -24,8 +24,8 @@ void fwd_test1() HASH_NAMESPACE::hash > hasher_test_int; HASH_NAMESPACE::hash > hasher_test_string; - BOOST_TEST(hasher_int(5) == hasher_test_int(x)); - BOOST_TEST(hasher_string("Test") == hasher_test_string(y)); + BOOST_CHECK(hasher_int(5) == hasher_test_int(x)); + BOOST_CHECK(hasher_string("Test") == hasher_test_string(y)); } void fwd_test2() @@ -44,8 +44,8 @@ void fwd_test2() HASH_NAMESPACE::hash > hasher_test_int; HASH_NAMESPACE::hash > hasher_test_string; - BOOST_TEST(seed1 == hasher_test_int(x)); - BOOST_TEST(seed2 == hasher_test_string(y)); + BOOST_CHECK(seed1 == hasher_test_int(x)); + BOOST_CHECK(seed2 == hasher_test_string(y)); } void fwd_test3() @@ -75,19 +75,19 @@ void fwd_test3() HASH_NAMESPACE::hash > hasher_test_int; HASH_NAMESPACE::hash > hasher_test_string; - BOOST_TEST(seed1 == hasher_test_int(x)); - BOOST_TEST(seed2 == hasher_test_string(y)); + BOOST_CHECK(seed1 == hasher_test_int(x)); + BOOST_CHECK(seed2 == hasher_test_string(y)); } #endif -int main() +int test_main(int, char**) { #ifdef TEST_EXTENSIONS fwd_test1(); fwd_test2(); fwd_test3(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_fwd_test_2.cpp b/hash/test/hash_fwd_test_2.cpp index e334194..e5dcbae 100644 --- a/hash/test/hash_fwd_test_2.cpp +++ b/hash/test/hash_fwd_test_2.cpp @@ -1,5 +1,5 @@ -// Copyright 2006-2007 Daniel James. +// 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) @@ -8,7 +8,7 @@ #include "./hash_fwd_test.hpp" -#include +#include template void unused(T const&) {} @@ -31,9 +31,9 @@ void fwd_test() } -int main() +int test_main(int, char**) { fwd_test(); - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_global_namespace_test.cpp b/hash/test/hash_global_namespace_test.cpp index a64f5eb..588e95a 100644 --- a/hash/test/hash_global_namespace_test.cpp +++ b/hash/test/hash_global_namespace_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2006-2007 Daniel James. +// 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) @@ -48,7 +48,7 @@ namespace boost # endif #endif -#include +#include #ifdef TEST_EXTENSIONS @@ -59,13 +59,13 @@ namespace boost void custom_tests() { HASH_NAMESPACE::hash custom_hasher; - BOOST_TEST(custom_hasher(10) == 100u); + BOOST_CHECK(custom_hasher(10) == 100u); custom x(55); - BOOST_TEST(custom_hasher(x) == 550u); + BOOST_CHECK(custom_hasher(x) == 550u); { using namespace HASH_NAMESPACE; - BOOST_TEST(custom_hasher(x) == hash_value(x)); + BOOST_CHECK(custom_hasher(x) == hash_value(x)); } std::vector custom_vector; @@ -83,19 +83,19 @@ void custom_tests() HASH_NAMESPACE::hash_combine(seed2, 250u); HASH_NAMESPACE::hash_combine(seed2, 350u); - BOOST_TEST(seed == + BOOST_CHECK(seed == HASH_NAMESPACE::hash_range(custom_vector.begin(), custom_vector.end())); - BOOST_TEST(seed == seed2); + BOOST_CHECK(seed == seed2); } #endif // TEST_EXTENSIONS -int main() +int test_main(int, char**) { #ifdef TEST_EXTENSIONS custom_tests(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_list_test.cpp b/hash/test/hash_list_test.cpp index f61b6c4..ca99c67 100644 --- a/hash/test/hash_list_test.cpp +++ b/hash/test/hash_list_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -13,7 +13,7 @@ # endif #endif -#include +#include #ifdef TEST_EXTENSIONS @@ -25,11 +25,11 @@ using std::list; #endif // TEST_EXTENSIONS -int main() +int test_main(int, char**) { #ifdef TEST_EXTENSIONS list_tests::list_hash_integer_tests(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_long_double_test.cpp b/hash/test/hash_long_double_test.cpp index 1c3aa74..03c22c4 100644 --- a/hash/test/hash_long_double_test.cpp +++ b/hash/test/hash_long_double_test.cpp @@ -1,11 +1,11 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) #include "hash_float_test.hpp" -int main() +int test_main(int, char**) { std::cerr<<"Compiler: "< +#include #include @@ -29,12 +29,12 @@ using std::multimap; #endif // TEST_EXTENSTIONS -int main() +int test_main(int, char**) { #ifdef TEST_EXTENSIONS map_tests::map_hash_integer_tests(); multimap_tests::multimap_hash_integer_tests(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_map_test.hpp b/hash/test/hash_map_test.hpp index 1a56282..8b7846d 100644 --- a/hash/test/hash_map_test.hpp +++ b/hash/test/hash_map_test.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -38,17 +38,17 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) HASH_NAMESPACE::hash hasher; for(int i2 = 0; i2 < number_of_containers; ++i2) { - BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2])); + BOOST_CHECK(hasher(containers[i2]) == hasher(containers[i2])); - BOOST_TEST(hasher(containers[i2]) == + BOOST_CHECK(hasher(containers[i2]) == HASH_NAMESPACE::hash_value(containers[i2])); - BOOST_TEST(hasher(containers[i2]) + BOOST_CHECK(hasher(containers[i2]) == HASH_NAMESPACE::hash_range( containers[i2].begin(), containers[i2].end())); for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) { - BOOST_TEST( + BOOST_CHECK( (containers[i2] == containers[j2]) == (hasher(containers[i2]) == hasher(containers[j2])) ); diff --git a/hash/test/hash_no_ext_fail_test.cpp b/hash/test/hash_no_ext_fail_test.cpp index bd123a9..c5ddc14 100644 --- a/hash/test/hash_no_ext_fail_test.cpp +++ b/hash/test/hash_no_ext_fail_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2006-2007 Daniel James. +// 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) @@ -12,7 +12,7 @@ #include #include -int main() +int test_main(int, char**) { HASH_NAMESPACE::hash< int[10] > hasher; return 0; diff --git a/hash/test/hash_no_ext_macro_1.cpp b/hash/test/hash_no_ext_macro_1.cpp index c0f84ae..20a74e6 100644 --- a/hash/test/hash_no_ext_macro_1.cpp +++ b/hash/test/hash_no_ext_macro_1.cpp @@ -1,5 +1,5 @@ -// Copyright 2006-2007 Daniel James. +// 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) @@ -7,11 +7,11 @@ #include #define BOOST_HASH_NO_EXTENSIONS #include -#include +#include #include #include -int main() +int test_main(int, char**) { std::deque x; @@ -19,7 +19,7 @@ int main() x.push_back(2); HASH_NAMESPACE::hash > hasher; - BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x)); + BOOST_CHECK(hasher(x) == HASH_NAMESPACE::hash_value(x)); - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_no_ext_macro_2.cpp b/hash/test/hash_no_ext_macro_2.cpp index 75b05d7..8c80667 100644 --- a/hash/test/hash_no_ext_macro_2.cpp +++ b/hash/test/hash_no_ext_macro_2.cpp @@ -1,5 +1,5 @@ -// Copyright 2006-2007 Daniel James. +// 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) @@ -8,10 +8,10 @@ #include #undef BOOST_HASH_NO_EXTENSIONS #include -#include +#include #include -int main() +int test_main(int, char**) { std::map x; @@ -19,7 +19,7 @@ int main() x.insert(std::map::value_type(14, -75)); HASH_NAMESPACE::hash > hasher; - BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x)); + BOOST_CHECK(hasher(x) == HASH_NAMESPACE::hash_value(x)); - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_number_test.cpp b/hash/test/hash_number_test.cpp index 89910a2..e21674f 100644 --- a/hash/test/hash_number_test.cpp +++ b/hash/test/hash_number_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -12,7 +12,7 @@ #endif #include -#include +#include #include #include @@ -31,7 +31,7 @@ template void numeric_test(T*) { - typedef std::numeric_limits limits; + typedef boost::hash_detail::limits limits; compile_time_tests((T*) 0); @@ -39,27 +39,27 @@ void numeric_test(T*) HASH_NAMESPACE::hash x2; T v1 = (T) -5; - BOOST_TEST(x1(v1) == x2(v1)); - BOOST_TEST(x1(T(-5)) == x2(T(-5))); - BOOST_TEST(x1(T(0)) == x2(T(0))); - BOOST_TEST(x1(T(10)) == x2(T(10))); - BOOST_TEST(x1(T(25)) == x2(T(25))); - BOOST_TEST(x1(T(5) - T(5)) == x2(T(0))); - BOOST_TEST(x1(T(6) + T(4)) == x2(T(10))); + BOOST_CHECK(x1(v1) == x2(v1)); + BOOST_CHECK(x1(T(-5)) == x2(T(-5))); + BOOST_CHECK(x1(T(0)) == x2(T(0))); + BOOST_CHECK(x1(T(10)) == x2(T(10))); + BOOST_CHECK(x1(T(25)) == x2(T(25))); + BOOST_CHECK(x1(T(5) - T(5)) == x2(T(0))); + BOOST_CHECK(x1(T(6) + T(4)) == x2(T(10))); #if defined(TEST_EXTENSIONS) - BOOST_TEST(x1(T(-5)) == HASH_NAMESPACE::hash_value(T(-5))); - BOOST_TEST(x1(T(0)) == HASH_NAMESPACE::hash_value(T(0))); - BOOST_TEST(x1(T(10)) == HASH_NAMESPACE::hash_value(T(10))); - BOOST_TEST(x1(T(25)) == HASH_NAMESPACE::hash_value(T(25))); + BOOST_CHECK(x1(T(-5)) == HASH_NAMESPACE::hash_value(T(-5))); + BOOST_CHECK(x1(T(0)) == HASH_NAMESPACE::hash_value(T(0))); + BOOST_CHECK(x1(T(10)) == HASH_NAMESPACE::hash_value(T(10))); + BOOST_CHECK(x1(T(25)) == HASH_NAMESPACE::hash_value(T(25))); if (limits::is_integer) { - if(limits::is_signed || limits::digits <= std::numeric_limits::digits) - BOOST_TEST(HASH_NAMESPACE::hash_value(T(-5)) == (std::size_t)T(-5)); - BOOST_TEST(HASH_NAMESPACE::hash_value(T(0)) == (std::size_t)T(0u)); - BOOST_TEST(HASH_NAMESPACE::hash_value(T(10)) == (std::size_t)T(10u)); - BOOST_TEST(HASH_NAMESPACE::hash_value(T(25)) == (std::size_t)T(25u)); + if(limits::is_signed || limits::digits <= boost::hash_detail::limits::digits) + BOOST_CHECK(HASH_NAMESPACE::hash_value(T(-5)) == (std::size_t)T(-5)); + BOOST_CHECK(HASH_NAMESPACE::hash_value(T(0)) == (std::size_t)T(0u)); + BOOST_CHECK(HASH_NAMESPACE::hash_value(T(10)) == (std::size_t)T(10u)); + BOOST_CHECK(HASH_NAMESPACE::hash_value(T(25)) == (std::size_t)T(25u)); } #endif } @@ -67,7 +67,7 @@ void numeric_test(T*) template void limits_test(T*) { - typedef std::numeric_limits limits; + typedef boost::hash_detail::limits limits; if(limits::is_specialized) { @@ -77,18 +77,18 @@ void limits_test(T*) T min_value = (limits::min)(); T max_value = (limits::max)(); - BOOST_TEST(x1(min_value) == x2((limits::min)())); - BOOST_TEST(x1(max_value) == x2((limits::max)())); + BOOST_CHECK(x1(min_value) == x2((limits::min)())); + BOOST_CHECK(x1(max_value) == x2((limits::max)())); #if defined(TEST_EXTENSIONS) - BOOST_TEST(x1(min_value) == HASH_NAMESPACE::hash_value(min_value)); - BOOST_TEST(x1(max_value) == HASH_NAMESPACE::hash_value(max_value)); + BOOST_CHECK(x1(min_value) == HASH_NAMESPACE::hash_value(min_value)); + BOOST_CHECK(x1(max_value) == HASH_NAMESPACE::hash_value(max_value)); if (limits::is_integer) { - BOOST_TEST(HASH_NAMESPACE::hash_value(min_value) + BOOST_CHECK(HASH_NAMESPACE::hash_value(min_value) == std::size_t(min_value)); - BOOST_TEST(HASH_NAMESPACE::hash_value(max_value) + BOOST_CHECK(HASH_NAMESPACE::hash_value(max_value) == std::size_t(max_value)); } #endif @@ -98,7 +98,7 @@ void limits_test(T*) template void poor_quality_tests(T*) { - typedef std::numeric_limits limits; + typedef boost::hash_detail::limits limits; HASH_NAMESPACE::hash x1; HASH_NAMESPACE::hash x2; @@ -106,11 +106,11 @@ void poor_quality_tests(T*) // A hash function can legally fail these tests, but it'll not be a good // sign. if(T(1) != T(-1)) - BOOST_TEST(x1(T(1)) != x2(T(-1))); + BOOST_CHECK(x1(T(1)) != x2(T(-1))); if(T(1) != T(2)) - BOOST_TEST(x1(T(1)) != x2(T(2))); + BOOST_CHECK(x1(T(1)) != x2(T(2))); if((limits::max)() != (limits::max)() - 1) - BOOST_TEST(x1((limits::max)()) != x2((limits::max)() - 1)); + BOOST_CHECK(x1((limits::max)()) != x2((limits::max)() - 1)); } void bool_test() @@ -118,10 +118,10 @@ void bool_test() HASH_NAMESPACE::hash x1; HASH_NAMESPACE::hash x2; - BOOST_TEST(x1(true) == x2(true)); - BOOST_TEST(x1(false) == x2(false)); - BOOST_TEST(x1(true) != x2(false)); - BOOST_TEST(x1(false) != x2(true)); + BOOST_CHECK(x1(true) == x2(true)); + BOOST_CHECK(x1(false) == x2(false)); + BOOST_CHECK(x1(true) != x2(false)); + BOOST_CHECK(x1(false) != x2(true)); } #define NUMERIC_TEST(type, name) \ @@ -134,7 +134,7 @@ void bool_test() numeric_test((type*) 0); \ poor_quality_tests((type*) 0); -int main() +int test_main(int, char**) { NUMERIC_TEST(char, char) NUMERIC_TEST(signed char, schar) @@ -150,8 +150,8 @@ int main() 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) @@ -159,7 +159,7 @@ int main() bool_test(); - return boost::report_errors(); + return 0; } #if defined(BOOST_MSVC) diff --git a/hash/test/hash_pointer_test.cpp b/hash/test/hash_pointer_test.cpp index 78d3416..ca893a6 100644 --- a/hash/test/hash_pointer_test.cpp +++ b/hash/test/hash_pointer_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -11,7 +11,7 @@ # include #endif -#include +#include #include #include @@ -30,20 +30,20 @@ void pointer_tests() int int1; int int2; - BOOST_TEST(x1(0) == x2(0)); - BOOST_TEST(x1(&int1) == x2(&int1)); - BOOST_TEST(x1(&int2) == x2(&int2)); + BOOST_CHECK(x1(0) == x2(0)); + BOOST_CHECK(x1(&int1) == x2(&int1)); + BOOST_CHECK(x1(&int2) == x2(&int2)); #if defined(TEST_EXTENSIONS) - BOOST_TEST(x1(&int1) == HASH_NAMESPACE::hash_value(&int1)); - BOOST_TEST(x1(&int2) == HASH_NAMESPACE::hash_value(&int2)); + BOOST_CHECK(x1(&int1) == HASH_NAMESPACE::hash_value(&int1)); + BOOST_CHECK(x1(&int2) == HASH_NAMESPACE::hash_value(&int2)); // This isn't specified in Peter's proposal: - BOOST_TEST(x1(0) == 0); + BOOST_CHECK(x1(0) == 0); #endif } -int main() +int test_main(int, char**) { pointer_tests(); - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_range_test.cpp b/hash/test/hash_range_test.cpp index 9e5ef09..94af3e6 100644 --- a/hash/test/hash_range_test.cpp +++ b/hash/test/hash_range_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -13,7 +13,7 @@ # endif #endif -#include +#include #ifdef TEST_EXTENSIONS @@ -41,45 +41,45 @@ void hash_range_tests() std::vector x; std::size_t x_seed = 0; - BOOST_TEST(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end())); + BOOST_CHECK(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(HASH_NAMESPACE::hash_range(empty.begin(), empty.end()) + BOOST_CHECK(HASH_NAMESPACE::hash_range(empty.begin(), empty.end()) == HASH_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(HASH_NAMESPACE::hash_range(empty.begin(), empty.end()) + BOOST_CHECK(HASH_NAMESPACE::hash_range(empty.begin(), empty.end()) != HASH_NAMESPACE::hash_range(values1.begin(), values1.end())); x.push_back(10); HASH_NAMESPACE::hash_combine(x_seed, 10); - BOOST_TEST(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end())); + BOOST_CHECK(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(HASH_NAMESPACE::hash_range(empty.begin(), empty.end()) + BOOST_CHECK(HASH_NAMESPACE::hash_range(empty.begin(), empty.end()) != HASH_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(HASH_NAMESPACE::hash_range(values2.begin(), values2.end()) + BOOST_CHECK(HASH_NAMESPACE::hash_range(values2.begin(), values2.end()) == HASH_NAMESPACE::hash_range(x.begin(), x.end())); x.push_back(20); HASH_NAMESPACE::hash_combine(x_seed, 20); - BOOST_TEST(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end())); + BOOST_CHECK(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(HASH_NAMESPACE::hash_range(empty.begin(), empty.end()) + BOOST_CHECK(HASH_NAMESPACE::hash_range(empty.begin(), empty.end()) != HASH_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(HASH_NAMESPACE::hash_range(values2.begin(), values2.end()) + BOOST_CHECK(HASH_NAMESPACE::hash_range(values2.begin(), values2.end()) != HASH_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(HASH_NAMESPACE::hash_range(values3.begin(), values3.end()) + BOOST_CHECK(HASH_NAMESPACE::hash_range(values3.begin(), values3.end()) == HASH_NAMESPACE::hash_range(x.begin(), x.end())); std::size_t seed = HASH_NAMESPACE::hash_range(values3.begin(), values3.end()); HASH_NAMESPACE::hash_range(seed, values4.begin(), values4.end()); HASH_NAMESPACE::hash_range(seed, x.begin(), x.end()); - BOOST_TEST(seed == HASH_NAMESPACE::hash_range(values5.begin(), values5.end())); + BOOST_CHECK(seed == HASH_NAMESPACE::hash_range(values5.begin(), values5.end())); } #endif -int main() +int test_main(int, char**) { hash_range_tests(); - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_sequence_test.hpp b/hash/test/hash_sequence_test.hpp index eb3295c..e2920ba 100644 --- a/hash/test/hash_sequence_test.hpp +++ b/hash/test/hash_sequence_test.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -41,17 +41,17 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) HASH_NAMESPACE::hash hasher; for(int i2 = 0; i2 < number_of_containers; ++i2) { - BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2])); + BOOST_CHECK(hasher(containers[i2]) == hasher(containers[i2])); - BOOST_TEST(hasher(containers[i2]) == + BOOST_CHECK(hasher(containers[i2]) == HASH_NAMESPACE::hash_value(containers[i2])); - BOOST_TEST(hasher(containers[i2]) + BOOST_CHECK(hasher(containers[i2]) == HASH_NAMESPACE::hash_range( containers[i2].begin(), containers[i2].end())); for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) { - BOOST_TEST( + BOOST_CHECK( (containers[i2] == containers[j2]) == (hasher(containers[i2]) == hasher(containers[j2])) ); diff --git a/hash/test/hash_set_test.cpp b/hash/test/hash_set_test.cpp index 442291c..40f5dc3 100644 --- a/hash/test/hash_set_test.cpp +++ b/hash/test/hash_set_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -13,7 +13,7 @@ # endif #endif -#include +#include #ifdef TEST_EXTENSIONS @@ -29,12 +29,12 @@ using std::multiset; #endif -int main() +int test_main(int, char**) { #ifdef TEST_EXTENSIONS set_tests::set_hash_integer_tests(); multiset_tests::multiset_hash_integer_tests(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_set_test.hpp b/hash/test/hash_set_test.hpp index 50791a6..18aa654 100644 --- a/hash/test/hash_set_test.hpp +++ b/hash/test/hash_set_test.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -44,17 +44,17 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) HASH_NAMESPACE::hash hasher; for(int i2 = 0; i2 < number_of_containers; ++i2) { - BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2])); + BOOST_CHECK(hasher(containers[i2]) == hasher(containers[i2])); - BOOST_TEST(hasher(containers[i2]) == + BOOST_CHECK(hasher(containers[i2]) == HASH_NAMESPACE::hash_value(containers[i2])); - BOOST_TEST(hasher(containers[i2]) + BOOST_CHECK(hasher(containers[i2]) == HASH_NAMESPACE::hash_range( containers[i2].begin(), containers[i2].end())); for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) { - BOOST_TEST( + BOOST_CHECK( (containers[i2] == containers[j2]) == (hasher(containers[i2]) == hasher(containers[j2])) ); diff --git a/hash/test/hash_string_test.cpp b/hash/test/hash_string_test.cpp index 42ca0b7..34654ee 100644 --- a/hash/test/hash_string_test.cpp +++ b/hash/test/hash_string_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -11,7 +11,7 @@ # include #endif -#include +#include #include #include @@ -27,18 +27,18 @@ void string_tests() HASH_NAMESPACE::hash x1; HASH_NAMESPACE::hash x2; - BOOST_TEST(x1("Hello") == x2(std::string("Hel") + "lo")); - BOOST_TEST(x1("") == x2(std::string())); + BOOST_CHECK(x1("Hello") == x2(std::string("Hel") + "lo")); + BOOST_CHECK(x1("") == x2(std::string())); #if defined(TEST_EXTENSIONS) std::string value1; std::string value2("Hello"); - BOOST_TEST(x1(value1) == HASH_NAMESPACE::hash_value(value1)); - BOOST_TEST(x1(value2) == HASH_NAMESPACE::hash_value(value2)); - BOOST_TEST(HASH_NAMESPACE::hash_value(value1) == + BOOST_CHECK(x1(value1) == HASH_NAMESPACE::hash_value(value1)); + BOOST_CHECK(x1(value2) == HASH_NAMESPACE::hash_value(value2)); + BOOST_CHECK(HASH_NAMESPACE::hash_value(value1) == HASH_NAMESPACE::hash_range(value1.begin(), value1.end())); - BOOST_TEST(HASH_NAMESPACE::hash_value(value2) == + BOOST_CHECK(HASH_NAMESPACE::hash_value(value2) == HASH_NAMESPACE::hash_range(value2.begin(), value2.end())); #endif } @@ -51,28 +51,28 @@ void wstring_tests() HASH_NAMESPACE::hash x1; HASH_NAMESPACE::hash x2; - BOOST_TEST(x1(L"Hello") == x2(std::wstring(L"Hel") + L"lo")); - BOOST_TEST(x1(L"") == x2(std::wstring())); + BOOST_CHECK(x1(L"Hello") == x2(std::wstring(L"Hel") + L"lo")); + BOOST_CHECK(x1(L"") == x2(std::wstring())); #if defined(TEST_EXTENSIONS) std::wstring value1; std::wstring value2(L"Hello"); - BOOST_TEST(x1(value1) == HASH_NAMESPACE::hash_value(value1)); - BOOST_TEST(x1(value2) == HASH_NAMESPACE::hash_value(value2)); - BOOST_TEST(HASH_NAMESPACE::hash_value(value1) == + BOOST_CHECK(x1(value1) == HASH_NAMESPACE::hash_value(value1)); + BOOST_CHECK(x1(value2) == HASH_NAMESPACE::hash_value(value2)); + BOOST_CHECK(HASH_NAMESPACE::hash_value(value1) == HASH_NAMESPACE::hash_range(value1.begin(), value1.end())); - BOOST_TEST(HASH_NAMESPACE::hash_value(value2) == + BOOST_CHECK(HASH_NAMESPACE::hash_value(value2) == HASH_NAMESPACE::hash_range(value2.begin(), value2.end())); #endif } #endif -int main() +int test_main(int, char**) { string_tests(); #if !defined(BOOST_NO_STD_WSTRING) wstring_tests(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_value_array_test.cpp b/hash/test/hash_value_array_test.cpp index 7080665..240f0f0 100644 --- a/hash/test/hash_value_array_test.cpp +++ b/hash/test/hash_value_array_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -16,7 +16,7 @@ # endif #endif -#include +#include #ifdef TEST_EXTENSIONS @@ -37,9 +37,9 @@ void array_int_test() int array3[2] = {2, 3}; HASH_NAMESPACE::hash hasher3; - BOOST_TEST(hasher1(array1) == HASH_NAMESPACE::hash_value(array1)); - BOOST_TEST(hasher2(array2) == HASH_NAMESPACE::hash_value(array2)); - BOOST_TEST(hasher3(array3) == HASH_NAMESPACE::hash_value(array3)); + BOOST_CHECK(hasher1(array1) == HASH_NAMESPACE::hash_value(array1)); + BOOST_CHECK(hasher2(array2) == HASH_NAMESPACE::hash_value(array2)); + BOOST_CHECK(hasher3(array3) == HASH_NAMESPACE::hash_value(array3)); } void two_dimensional_array_test() @@ -47,18 +47,18 @@ void two_dimensional_array_test() int array[3][2] = {{-5, 6}, {7, -3}, {26, 1}}; HASH_NAMESPACE::hash hasher; - BOOST_TEST(hasher(array) == HASH_NAMESPACE::hash_value(array)); + BOOST_CHECK(hasher(array) == HASH_NAMESPACE::hash_value(array)); } #endif -int main() +int test_main(int, char**) { #ifdef TEST_EXTENSIONS array_int_test(); two_dimensional_array_test(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/hash_vector_test.cpp b/hash/test/hash_vector_test.cpp index bcc9c51..d5c25e2 100644 --- a/hash/test/hash_vector_test.cpp +++ b/hash/test/hash_vector_test.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -13,7 +13,7 @@ # endif #endif -#include +#include #ifdef TEST_EXTENSIONS @@ -25,11 +25,11 @@ using std::vector; #endif // TEST_EXTENSIONS -int main() +int test_main(int, char**) { #ifdef TEST_EXTENSIONS vector_tests::vector_hash_integer_tests(); #endif - return boost::report_errors(); + return 0; } diff --git a/hash/test/link_ext_test.cpp b/hash/test/link_ext_test.cpp index 19a7299..d65c3bb 100644 --- a/hash/test/link_ext_test.cpp +++ b/hash/test/link_ext_test.cpp @@ -1,17 +1,17 @@ -// Copyright 2006-2007 Daniel James. +// 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) #define HASH_NAMESPACE boost #include -#include +#include #include int f(std::size_t hash1, int* x1) { // Check that HASH_NAMESPACE::hash works in both files. HASH_NAMESPACE::hash ptr_hasher; - BOOST_TEST(hash1 == ptr_hasher(x1)); + BOOST_CHECK(hash1 == ptr_hasher(x1)); // Check that std::vector is avaiable in this file. std::vector x; diff --git a/hash/test/link_no_ext_test.cpp b/hash/test/link_no_ext_test.cpp index a3db5b1..102d8fd 100644 --- a/hash/test/link_no_ext_test.cpp +++ b/hash/test/link_no_ext_test.cpp @@ -1,18 +1,19 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) #define HASH_NAMESPACE boost #define BOOST_HASH_NO_EXTENSIONS #include -#include +#include extern int f(std::size_t, int*); -int main() { +int test_main(int, char**) { HASH_NAMESPACE::hash ptr_hasher; int x = 55; - BOOST_TEST(!f(ptr_hasher(&x), &x)); - return boost::report_errors(); + + BOOST_ASSERT(!f(ptr_hasher(&x), &x)); + return 0; } diff --git a/hash/test/link_test.cpp b/hash/test/link_test.cpp index eb8e51f..756d6c8 100644 --- a/hash/test/link_test.cpp +++ b/hash/test/link_test.cpp @@ -1,9 +1,9 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) #include extern int f(); -int main() { return f(); } +int main(int, char**) { return f(); } diff --git a/hash/test/link_test_2.cpp b/hash/test/link_test_2.cpp index d40f1db..8be1635 100644 --- a/hash/test/link_test_2.cpp +++ b/hash/test/link_test_2.cpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/include/boost/functional/detail/container_fwd.hpp b/include/boost/functional/detail/container_fwd.hpp index f3f82f2..8685905 100644 --- a/include/boost/functional/detail/container_fwd.hpp +++ b/include/boost/functional/detail/container_fwd.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/include/boost/functional/detail/float_functions.hpp b/include/boost/functional/detail/float_functions.hpp index 9aac5a2..72386ad 100644 --- a/include/boost/functional/detail/float_functions.hpp +++ b/include/boost/functional/detail/float_functions.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/include/boost/functional/detail/hash_float.hpp b/include/boost/functional/detail/hash_float.hpp index 298d0c0..dc35afb 100644 --- a/include/boost/functional/detail/hash_float.hpp +++ b/include/boost/functional/detail/hash_float.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -38,7 +38,7 @@ // STLport #elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) -// _fpclass and fpclassify aren't good enough on STLport. +// fpclassify aren't good enough on STLport. // GNU libstdc++ 3 #elif defined(__GLIBCPP__) || defined(__GLIBCXX__) @@ -50,19 +50,47 @@ // Dinkumware Library, on Visual C++ #elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER) -// Not using _fpclass because it causes a warning about a conversion -// from 'long double' to 'double'. Pity. -// -//# if defined(BOOST_MSVC) -//# define BOOST_HASH_USE_FPCLASS -//# endif +// Not using _fpclass because it is only available for double. #endif +// On OpenBSD, numeric_limits is not reliable for long doubles, but +// the macros defined in are. + +#if defined(__OpenBSD__) +#include +#endif + namespace boost { namespace hash_detail { + template + struct limits : std::numeric_limits {}; + +#if defined(__OpenBSD__) + template <> + struct limits + : std::numeric_limits + { + static long double epsilon() { + return LDBL_EPSILON; + } + + static long double (max)() { + return LDBL_MAX; + } + + static long double (min)() { + return LDBL_MIN; + } + + BOOST_STATIC_CONSTANT(int, digits = LDBL_MANT_DIG); + BOOST_STATIC_CONSTANT(int, max_exponent = LDBL_MAX_EXP); + BOOST_STATIC_CONSTANT(int, min_exponent = LDBL_MIN_EXP); + }; +#endif // __OpenBSD__ + inline void hash_float_combine(std::size_t& seed, std::size_t value) { seed ^= value + (seed<<6) + (seed>>2); @@ -107,29 +135,28 @@ namespace boost // sign with the exponent. if(v < 0) { v = -v; - exp += std::numeric_limits::max_exponent - - std::numeric_limits::min_exponent; + exp += limits::max_exponent - + limits::min_exponent; } // The result of frexp is always between 0.5 and 1, so its // top bit will always be 1. Subtract by 0.5 to remove that. v -= T(0.5); v = boost::hash_detail::call_ldexp(v, - std::numeric_limits::digits + 1); + limits::digits + 1); std::size_t seed = static_cast(v); v -= seed; // ceiling(digits(T) * log2(radix(T))/ digits(size_t)) - 1; std::size_t const length - = (std::numeric_limits::digits * - boost::static_log2::radix>::value - - 1) - / std::numeric_limits::digits; + = (limits::digits * + boost::static_log2::radix>::value - 1) + / limits::digits; for(std::size_t i = 0; i != length; ++i) { v = boost::hash_detail::call_ldexp(v, - std::numeric_limits::digits); + limits::digits); std::size_t part = static_cast(v); v -= part; hash_float_combine(seed, part); @@ -160,28 +187,6 @@ namespace boost BOOST_ASSERT(0); return 0; } -#elif defined(BOOST_HASH_USE_FPCLASS) - switch(_fpclass(v)) { - case _FPCLASS_NZ: - case _FPCLASS_PZ: - return 0; - case _FPCLASS_PINF: - return (std::size_t)(-1); - case _FPCLASS_NINF: - return (std::size_t)(-2); - case _FPCLASS_SNAN: - case _FPCLASS_QNAN: - return (std::size_t)(-3); - case _FPCLASS_NN: - case _FPCLASS_ND: - return float_hash_impl(v); - case _FPCLASS_PD: - case _FPCLASS_PN: - return float_hash_impl(v); - default: - BOOST_ASSERT(0); - return 0; - } #else return v == 0 ? 0 : float_hash_impl(v); #endif diff --git a/include/boost/functional/hash.hpp b/include/boost/functional/hash.hpp index 60b2608..46b611b 100644 --- a/include/boost/functional/hash.hpp +++ b/include/boost/functional/hash.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -8,3 +8,4 @@ // issue 6.18. #include + diff --git a/include/boost/functional/hash/deque.hpp b/include/boost/functional/hash/deque.hpp index 8e92727..06d23c2 100644 --- a/include/boost/functional/hash/deque.hpp +++ b/include/boost/functional/hash/deque.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/include/boost/functional/hash/extensions.hpp b/include/boost/functional/hash/extensions.hpp new file mode 100644 index 0000000..b9d868e --- /dev/null +++ b/include/boost/functional/hash/extensions.hpp @@ -0,0 +1,182 @@ + +// Copyright 2005-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) + +// Based on Peter Dimov's proposal +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf +// issue 6.18. + +#if !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP) +#define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +namespace boost +{ + +#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + namespace hash_detail + { + template + struct call_hash_impl + { + template + struct inner + { + static std::size_t call(T const& v) + { + using namespace boost; + return hash_value(v); + } + }; + }; + + template <> + struct call_hash_impl + { + template + struct inner + { +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + static std::size_t call(Array const& v) +#else + static std::size_t call(Array& v) +#endif + { + const int size = sizeof(v) / sizeof(*v); + return boost::hash_range(v, v + size); + } + }; + }; + + template + struct call_hash + : public call_hash_impl::value> + ::BOOST_NESTED_TEMPLATE inner + { + }; + } +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + + template struct hash + : std::unary_function + { +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + std::size_t operator()(T const& val) const + { + return hash_value(val); + } +#else + std::size_t operator()(T const& val) const + { + return hash_detail::call_hash::call(val); + } +#endif + }; + +#if BOOST_WORKAROUND(__DMC__, <= 0x848) + template struct hash + : std::unary_function + { + std::size_t operator()(const T* val) const + { + return boost::hash_range(val, val+n); + } + }; +#endif + +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // On compilers without partial specialization, boost::hash + // has already been declared to deal with pointers, so just + // need to supply the non-pointer version. + + namespace hash_detail + { + template + struct hash_impl; + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + + template <> + struct hash_impl + { + template + struct inner + : std::unary_function + { +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + std::size_t operator()(T const& val) const + { + return hash_value(val); + } +#else + std::size_t operator()(T const& val) const + { + return hash_detail::call_hash::call(val); + } +#endif + }; + }; + +#else // Visual C++ 6.5 + + // There's probably a more elegant way to Visual C++ 6.5 to work + // but I don't know what it is. + + template + struct hash_impl_msvc + { + template + struct inner + : public std::unary_function + { + std::size_t operator()(T const& val) const + { + return hash_detail::call_hash::call(val); + } + + std::size_t operator()(T& val) const + { + return hash_detail::call_hash::call(val); + } + }; + }; + + template <> + struct hash_impl_msvc + { + template + struct inner + : public std::unary_function + { + std::size_t operator()(T& val) const + { + return hash_detail::call_hash::call(val); + } + }; + }; + + template + struct hash_impl_msvc2 + : public hash_impl_msvc::value> + ::BOOST_NESTED_TEMPLATE inner {}; + + template <> + struct hash_impl + { + template + struct inner : public hash_impl_msvc2 {}; + }; + +#endif // Visual C++ 6.5 + } +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +} + +#endif diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 5515efd..09ca567 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) @@ -46,8 +46,8 @@ namespace boost #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) @@ -195,12 +195,12 @@ namespace boost #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); } @@ -518,176 +518,12 @@ namespace boost } #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) -#define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP - -namespace boost -{ - -#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - namespace hash_detail - { - template - struct call_hash_impl - { - template - struct inner - { - static std::size_t call(T const& v) - { - using namespace boost; - return hash_value(v); - } - }; - }; - - template <> - struct call_hash_impl - { - template - struct inner - { -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - static std::size_t call(Array const& v) -#else - static std::size_t call(Array& v) +#include #endif - { - const int size = sizeof(v) / sizeof(*v); - return boost::hash_range(v, v + size); - } - }; - }; - - template - struct call_hash - : public call_hash_impl::value> - ::BOOST_NESTED_TEMPLATE inner - { - }; - } -#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING - -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - - template struct hash - : std::unary_function - { -#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - std::size_t operator()(T const& val) const - { - return hash_value(val); - } -#else - std::size_t operator()(T const& val) const - { - return hash_detail::call_hash::call(val); - } -#endif - }; - -#if BOOST_WORKAROUND(__DMC__, <= 0x848) - template struct hash - : std::unary_function - { - std::size_t operator()(const T* val) const - { - return boost::hash_range(val, val+n); - } - }; -#endif - -#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - - // On compilers without partial specialization, boost::hash - // has already been declared to deal with pointers, so just - // need to supply the non-pointer version. - - namespace hash_detail - { - template - struct hash_impl; - -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - - template <> - struct hash_impl - { - template - struct inner - : std::unary_function - { -#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - std::size_t operator()(T const& val) const - { - return hash_value(val); - } -#else - std::size_t operator()(T const& val) const - { - return hash_detail::call_hash::call(val); - } -#endif - }; - }; - -#else // Visual C++ 6.5 - - // There's probably a more elegant way to Visual C++ 6.5 to work - // but I don't know what it is. - - template - struct hash_impl_msvc - { - template - struct inner - : public std::unary_function - { - std::size_t operator()(T const& val) const - { - return hash_detail::call_hash::call(val); - } - - std::size_t operator()(T& val) const - { - return hash_detail::call_hash::call(val); - } - }; - }; - - template <> - struct hash_impl_msvc - { - template - struct inner - : public std::unary_function - { - std::size_t operator()(T& val) const - { - return hash_detail::call_hash::call(val); - } - }; - }; - - template - struct hash_impl_msvc2 - : public hash_impl_msvc::value> - ::BOOST_NESTED_TEMPLATE inner {}; - - template <> - struct hash_impl - { - template - struct inner : public hash_impl_msvc2 {}; - }; - -#endif // Visual C++ 6.5 - } -#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -} - -#endif - diff --git a/include/boost/functional/hash/list.hpp b/include/boost/functional/hash/list.hpp index 219394b..201f6d0 100644 --- a/include/boost/functional/hash/list.hpp +++ b/include/boost/functional/hash/list.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/include/boost/functional/hash/map.hpp b/include/boost/functional/hash/map.hpp index 59e259f..6713d85 100644 --- a/include/boost/functional/hash/map.hpp +++ b/include/boost/functional/hash/map.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/include/boost/functional/hash/pair.hpp b/include/boost/functional/hash/pair.hpp index 68f2233..bf076f1 100644 --- a/include/boost/functional/hash/pair.hpp +++ b/include/boost/functional/hash/pair.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/include/boost/functional/hash/set.hpp b/include/boost/functional/hash/set.hpp index 6e3ef71..0533e76 100644 --- a/include/boost/functional/hash/set.hpp +++ b/include/boost/functional/hash/set.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/include/boost/functional/hash/vector.hpp b/include/boost/functional/hash/vector.hpp index eeadf4e..8bab799 100644 --- a/include/boost/functional/hash/vector.hpp +++ b/include/boost/functional/hash/vector.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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) diff --git a/include/boost/functional/hash_fwd.hpp b/include/boost/functional/hash_fwd.hpp index 4d103f7..8b7d8e5 100644 --- a/include/boost/functional/hash_fwd.hpp +++ b/include/boost/functional/hash_fwd.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2007 Daniel James. +// Copyright 2005-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)