diff --git a/function_test.cpp b/function_test.cpp index ed7eb8d..318a750 100644 --- a/function_test.cpp +++ b/function_test.cpp @@ -12,9 +12,6 @@ // $Id$ // ------------------------------------------------------------------------------ // $Log$ -// Revision 1.2.24.1 2006/12/02 14:17:26 andreas_huber69 -// Merged L & C issue fixes from trunk to branch. -// // Revision 1.3 2006/12/02 13:57:32 andreas_huber69 // Fixed license & copyright issues. // diff --git a/hash/doc/Jamfile.v2 b/hash/doc/Jamfile.v2 index 7f55cd5..9b7bdb7 100644 --- a/hash/doc/Jamfile.v2 +++ b/hash/doc/Jamfile.v2 @@ -1,6 +1,6 @@ -# Copyright Daniel James 2005. Use, modification, and distribution are -# subject to the Boost Software License, Version 1.0. (See accompanying +# Copyright 2005 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 ; diff --git a/hash/doc/changes.qbk b/hash/doc/changes.qbk index c8f8046..4a15288 100644 --- a/hash/doc/changes.qbk +++ b/hash/doc/changes.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2006 Daniel James. +[/ Copyright 2005-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) ] diff --git a/hash/doc/disable.qbk b/hash/doc/disable.qbk index 62b4d31..3d69431 100644 --- a/hash/doc/disable.qbk +++ b/hash/doc/disable.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2006 Daniel James. +[/ Copyright 2005-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) ] diff --git a/hash/doc/hash.qbk b/hash/doc/hash.qbk index 3bab67a..5bb200a 100644 --- a/hash/doc/hash.qbk +++ b/hash/doc/hash.qbk @@ -1,7 +1,7 @@ [library Boost.Functional/Hash - [quickbook 1.3] + [quickbook 1.4] [authors [James, Daniel]] - [copyright 2005 2006 Daniel James] + [copyright 2005 2006 2007 Daniel James] [purpose A TR1 hash function object that can be extended to hash user defined types] [category higher-order] @@ -10,7 +10,7 @@ [license 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] + [@http://www.boost.org/LICENSE_1_0.txt]) ] ] diff --git a/hash/doc/intro.qbk b/hash/doc/intro.qbk index a4f3be3..b6dac9e 100644 --- a/hash/doc/intro.qbk +++ b/hash/doc/intro.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2006 Daniel James. +[/ Copyright 2005-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) ] diff --git a/hash/doc/links.qbk b/hash/doc/links.qbk index 4217f5f..5d9a269 100644 --- a/hash/doc/links.qbk +++ b/hash/doc/links.qbk @@ -1,26 +1,26 @@ -[/ Copyright 2005-2006 Daniel James. +[/ Copyright 2005-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) ] [section:links Links] -[*A Proposal to Add Hash Tables to the Standard Library]\n -[@http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2003/n1456.html]\n +[*A Proposal to Add Hash Tables to the Standard Library] +[@http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2003/n1456.html] The hash table proposal explains much of the design. The hash function object is discussed in Section D. -[*The C++ Standard Library Technical Report.]\n -[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf]\n +[*The C++ Standard Library Technical Report.] +[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf] Contains the hash function specification in section 6.3.2. -[*Library Extension Technical Report Issues List.]\n -[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1837.pdf]\n +[*Library Extension Technical Report Issues List.] +[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1837.pdf] The library implements the extension described in Issue 6.18, pages 63-67. -[*Methods for Identifying Versioned and Plagiarised Documents]\n -Timothy C. Hoad, Justin Zobel\n -[@http://www.cs.rmit.edu.au/~jz/fulltext/jasist-tch.pdf]\n +[*Methods for Identifying Versioned and Plagiarised Documents] +Timothy C. Hoad, Justin Zobel +[@http://www.cs.rmit.edu.au/~jz/fulltext/jasist-tch.pdf] Contains the hash function that [funcref boost::hash_combine] is based on. [endsect] diff --git a/hash/doc/portability.qbk b/hash/doc/portability.qbk index 6c20799..0e89196 100644 --- a/hash/doc/portability.qbk +++ b/hash/doc/portability.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2006 Daniel James. +[/ Copyright 2005-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) ] @@ -10,7 +10,7 @@ __boost_hash__ is written to be as portable as possible, but unfortunately, several older compilers don't support argument dependent lookup (ADL) - the mechanism used for customisation. On those compilers custom overloads for `hash_value` -need to be declared in the boost namespace. +needs to be declared in the boost namespace. On a strictly standards compliant compiler, an overload defined in the boost namespace won't be found when __boost_hash__ is instantiated, diff --git a/hash/doc/ref.xml b/hash/doc/ref.xml index 4c98870..21acd4a 100644 --- a/hash/doc/ref.xml +++ b/hash/doc/ref.xml @@ -1,5 +1,6 @@ + @@ -260,6 +261,42 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + + + long long + + + std::size_t + + long long + + + Unspecified in TR1, except that equal arguments yield the same result. + hash_value(val) in Boost. + + Doesn't throw + + + + + + + unsigned long long + + + std::size_t + + unsigned long long + + + Unspecified in TR1, except that equal arguments yield the same result. + hash_value(val) in Boost. + + Doesn't throw + + + @@ -472,6 +509,41 @@ for(; first != last; ++first) Implementation of the hash function. + + std::size_t + bool + + + + std::size_t + char + + + + std::size_t + signed char + + + + std::size_t + unsigned char + + + + std::size_t + wchar_t + + + + std::size_t + short + + + + std::size_t + unsigned short + + std::size_t int @@ -492,6 +564,16 @@ for(; first != last; ++first) unsigned long + + std::size_t + long long + + + + std::size_t + unsigned long long + + std::size_t float @@ -620,6 +702,14 @@ for(; first != last; ++first) std::multimap<K, T, C, A> const& + + + std::size_t + std::complex<T> const& + + Generally shouldn't be called directly by users, instead they should use boost::hash, boost::hash_range @@ -650,9 +740,17 @@ for(; first != last; ++first) - int, unsigned int, long, unsigned long + bool, + char, signed char, unsigned char, wchar_t, + short, unsigned short, + int, unsigned int, long, unsigned long + val + + long long, unsigned long long + val when abs(val) <= std::numeric_limits<std::size_t>::max(). + float, double, long double An unspecified value, except that equal arguments shall yield the same result. @@ -688,6 +786,12 @@ for(; first != last; ++first) hash_combine(seed, val.second); return seed; + + + std::complex<T> + + When T is a built in type and val.imag() == 0, the result is equal to hash_value(val.real()). Otherwise an unspecified value, except that equal arguments shall yield the same result. + diff --git a/hash/doc/thanks.qbk b/hash/doc/thanks.qbk index 1b67c71..27bffc1 100644 --- a/hash/doc/thanks.qbk +++ b/hash/doc/thanks.qbk @@ -1,20 +1,19 @@ -[/ Copyright 2005-2006 Daniel James. +[/ Copyright 2005-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) ] [section:acknowledgements Acknowledgements] -This library is based on the design by Peter Dimov's original design. - -During the initial development Joaquín M López Muñoz made many useful -suggestions, contributed fixes. +This library is based on the design by Peter Dimov. During the initial +development +Joaquín M López Muñoz made many useful suggestions and contributed fixes. The formal review was managed by Thorsten Ottosen, and the library reviewed by: David Abrahams, Alberto Barbati, Topher Cooper, Caleb Epstein, Dave Harris, -Chris Jefferson, Bronek Kozicki, John Maddock, Tobias Swinger, Jaap Suter, Rob -Stewart and Pavel Vozenilek. Since then, there have been further contributions -from Daniel Krügler, Alexander Nasonov, 沈慧峰 and John Maddock. +Chris Jefferson, Bronek Kozicki, John Maddock, Tobias Swinger, Jaap Suter, +Rob Stewart and Pavel Vozenilek. Since then, further constructive criticism has +been made by Daniel Krügler, Alexander Nasonov and 沈慧峰. The implementation of the hash function for pointers is based on suggestions made by Alberto Barbati and Dave Harris. Dave Harris also suggested an diff --git a/hash/doc/tutorial.qbk b/hash/doc/tutorial.qbk index cf17c7a..e30a181 100644 --- a/hash/doc/tutorial.qbk +++ b/hash/doc/tutorial.qbk @@ -1,5 +1,5 @@ -[/ Copyright 2005-2006 Daniel James. +[/ Copyright 2005-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) ] @@ -119,7 +119,7 @@ When writing a hash function, first look at how the equality function works. Objects that are equal must generate the same hash value. When objects are not equal they should generate different hash values. In this object equality was based just on the id so the hash function -only hash the id. If it was based on the objects name and author +only hashes the id. If it was based on the object's name and author then the hash function should take them into account (how to do this is discussed in the next section). ] diff --git a/hash/examples/books.cpp b/hash/examples/books.cpp index 4c31ff1..466ff44 100644 --- a/hash/examples/books.cpp +++ b/hash/examples/books.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./books.hpp" #include diff --git a/hash/examples/books.hpp b/hash/examples/books.hpp index 774dab2..4acdd86 100644 --- a/hash/examples/books.hpp +++ b/hash/examples/books.hpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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) // This example illustrates how to use boost::hash with a custom hash function. // The implementation is contained in books.cpp diff --git a/hash/examples/point.cpp b/hash/examples/point.cpp index 4beb93d..6943342 100644 --- a/hash/examples/point.cpp +++ b/hash/examples/point.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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) +// Copyright 2005 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 #include diff --git a/hash/examples/portable.cpp b/hash/examples/portable.cpp index ddb9220..962dca2 100644 --- a/hash/examples/portable.cpp +++ b/hash/examples/portable.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 #include diff --git a/hash/index.html b/hash/index.html index b76ca08..12b5757 100644 --- a/hash/index.html +++ b/hash/index.html @@ -1,6 +1,6 @@ diff --git a/hash/test/Jamfile.v2 b/hash/test/Jamfile.v2 index 45caa60..b0ac974 100644 --- a/hash/test/Jamfile.v2 +++ b/hash/test/Jamfile.v2 @@ -1,13 +1,15 @@ -# Copyright Daniel James 2005-2006. Use, modification, and distribution are -# subject to 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) +# Copyright 2005-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) import testing ; project hash-tests : requirements gcc:_GLIBCXX_DEBUG + gcc:-Wsign-promo + #gcc:-Wextra ; test-suite functional/hash @@ -18,6 +20,7 @@ test-suite functional/hash [ run hash_pointer_test.cpp ] [ run hash_function_pointer_test.cpp ] [ run hash_float_test.cpp : : : always_show_run_output ] + [ run hash_long_double_test.cpp : : : always_show_run_output ] [ run hash_string_test.cpp ] [ run hash_range_test.cpp ] [ run hash_custom_test.cpp ] @@ -30,12 +33,14 @@ test-suite functional/hash [ run hash_deque_test.cpp ] [ run hash_set_test.cpp ] [ run hash_map_test.cpp ] + [ run hash_complex_test.cpp ] [ run link_test.cpp link_test_2.cpp ] [ run link_ext_test.cpp link_no_ext_test.cpp ] [ run container_fwd_test.cpp ] [ compile-fail hash_no_ext_fail_test.cpp ] [ run hash_no_ext_macro_1.cpp ] [ run hash_no_ext_macro_2.cpp ] + [ run hash_deprecated_headers.cpp : : : always_show_run_output ] ; build-project ../examples ; diff --git a/hash/test/compile_time.hpp b/hash/test/compile_time.hpp index 25ba441..99589d1 100644 --- a/hash/test/compile_time.hpp +++ b/hash/test/compile_time.hpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 #include @@ -12,5 +12,5 @@ void compile_time_tests(T*) { BOOST_STATIC_ASSERT((boost::is_base_and_derived< std::unary_function, HASH_NAMESPACE::hash >::value)); -}; +} diff --git a/hash/test/config.hpp b/hash/test/config.hpp index 1f3739f..12d9aca 100644 --- a/hash/test/config.hpp +++ b/hash/test/config.hpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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) #if defined(TEST_STD) # define TEST_STD_INCLUDES diff --git a/hash/test/container_fwd_test.cpp b/hash/test/container_fwd_test.cpp index 684e16b..232c357 100644 --- a/hash/test/container_fwd_test.cpp +++ b/hash/test/container_fwd_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 diff --git a/hash/test/hash_built_in_array_test.cpp b/hash/test/hash_built_in_array_test.cpp index f7789d1..5904615 100644 --- a/hash/test/hash_built_in_array_test.cpp +++ b/hash/test/hash_built_in_array_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./config.hpp" diff --git a/hash/test/hash_complex_test.cpp b/hash/test/hash_complex_test.cpp new file mode 100644 index 0000000..a0707b5 --- /dev/null +++ b/hash/test/hash_complex_test.cpp @@ -0,0 +1,108 @@ + +// Copyright 2005-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 "./config.hpp" + +#ifdef TEST_EXTENSIONS +# ifdef TEST_STD_INCLUDES +# include +# else +# include +# endif +#endif + +#include + +#ifdef TEST_EXTENSIONS + +#include +#include +#include + +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4244) // conversion from 'unsigned long' to 'unsigned short', possible loss of data +#pragma warning(disable:4512) // assignment operator could not be generated +#endif + +#include +#include +#include +#include + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + +template +void generic_complex_tests(std::complex v) +{ + HASH_NAMESPACE::hash > complex_hasher; + + BOOST_TEST(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))); + + if(imag != 0 && real_hasher(real) == complex_hasher(v)) { + std::ostringstream os; + os<<"real_hasher("< +void complex_float_tests(Float*) +{ + boost::mt19937 rng; + boost::uniform_real uniform; + boost::variate_generator > + uniform_generator(rng, uniform); + + for(int i = 0; i < 100; ++i) + { + std::complex v(uniform_generator(), uniform_generator()); + generic_complex_tests(v); + } +} + +template +void complex_integral_tests(Integer*) +{ + boost::mt19937 rng; + boost::uniform_int uniform( + (std::numeric_limits::min)(), + (std::numeric_limits::max)()); + boost::variate_generator > + uniform_generator(rng, uniform); + + for(int i = 0; i < 100; ++i) + { + std::complexv(uniform_generator(), uniform_generator()); + generic_complex_tests(v); + } +} + +int main() +{ + complex_float_tests((float*) 0); + complex_float_tests((double*) 0); + complex_float_tests((long double*) 0); + complex_integral_tests((short*) 0); + complex_integral_tests((int*) 0); + complex_integral_tests((long*) 0); + complex_integral_tests((unsigned short*) 0); + complex_integral_tests((unsigned int*) 0); + complex_integral_tests((unsigned long*) 0); + + return boost::report_errors(); +} + +#endif diff --git a/hash/test/hash_custom_test.cpp b/hash/test/hash_custom_test.cpp index 1af95f8..8df3e83 100644 --- a/hash/test/hash_custom_test.cpp +++ b/hash/test/hash_custom_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 #include diff --git a/hash/test/hash_deprecated_headers.cpp b/hash/test/hash_deprecated_headers.cpp new file mode 100644 index 0000000..3257d9b --- /dev/null +++ b/hash/test/hash_deprecated_headers.cpp @@ -0,0 +1,26 @@ + +// Copyright 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) + +// All these headers are meant output a warning, but not cause the compilation +// to fail. + +#include +#include +#include +#include +#include +#include + +// And a quick check that the hash library was included. +// Strictly speaking I should do this once for each header +// but that would just be wasting the testing resources. + +#include + +int main() { + 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 9994a92..7238319 100644 --- a/hash/test/hash_deque_test.cpp +++ b/hash/test/hash_deque_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./config.hpp" diff --git a/hash/test/hash_float_test.cpp b/hash/test/hash_float_test.cpp index 0bfacbb..6ceda4b 100644 --- a/hash/test/hash_float_test.cpp +++ b/hash/test/hash_float_test.cpp @@ -1,228 +1,18 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./config.hpp" +#include "hash_float_test.hpp" -#ifdef TEST_STD_INCLUDES -# include -#else -# include -#endif - -#include - -#include -#include - -#include - -template -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" - <<"\n" - ; - - HASH_NAMESPACE::hash x1; - - T zero = 0; - T minus_zero = (T) -1 * zero; - - BOOST_TEST(zero == minus_zero); - BOOST_TEST(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)); - - using namespace std; - -// Doing anything with infinity causes borland to crash. -#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) { - T infinity = -log(zero); - T infinity2 = (T) 1. / zero; - T infinity3 = (T) -1. / minus_zero; - T infinity4 = std::numeric_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) - == HASH_NAMESPACE::hash_value(minus_infinity)); - - if(infinity == infinity2) - BOOST_TEST(x1(infinity) == x1(infinity2)); - if(infinity == infinity3); - BOOST_TEST(x1(infinity) == x1(infinity3)); - if(infinity == infinity4) - BOOST_TEST(x1(infinity) == x1(infinity4)); - - if(minus_infinity == minus_infinity2) - BOOST_TEST(x1(minus_infinity) == x1(minus_infinity2)); - if(minus_infinity == minus_infinity3) - BOOST_TEST(x1(minus_infinity) == x1(minus_infinity3)); - - BOOST_TEST(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)) { - std::cerr<<"x1(denorm_min) == x1(infinity) == "<::denorm_min()) == x1(minus_infinity)) { - std::cerr<<"x1(denorm_min) == x1(-infinity) == "<::has_quiet_NaN) { - if(x1(std::numeric_limits::quiet_NaN()) == x1(infinity)) { - std::cerr<<"x1(quiet_NaN) == x1(infinity) == "<::quiet_NaN()) == x1(minus_infinity)) { - std::cerr<<"x1(quiet_NaN) == x1(-infinity) == "<::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)); - - // 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)); - -// Intel with gcc stdlib sometimes segfaults on calls to asin and acos. -#if !((defined(__INTEL_COMPILER) || defined(__ICL) || \ - defined(__ICC) || defined(__ECC)) && \ - (defined(__GLIBCPP__) || defined(__GLIBCXX__))) - 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)); -#endif - - BOOST_TEST(x1(std::numeric_limits::epsilon()) == - HASH_NAMESPACE::hash_value(std::numeric_limits::epsilon())); - - BOOST_TEST(std::numeric_limits::epsilon() != (T) 0); - if(x1(std::numeric_limits::epsilon()) == x1((T) 0)) - std::cerr<<"x1(epsilon) == x1(0) == "<::epsilon() != (T) 0); - if(x1(-std::numeric_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)) - std::cerr<<"x1(1 + epsilon) == x1(1) == "<::epsilon() != (T) 1); - if(x1((T) 1 - std::numeric_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)) - std::cerr<<"x1(-1 + epsilon) == x1(-1) == "<::epsilon() != (T) -1); - if(x1((T) -1 - std::numeric_limits::epsilon()) == x1((T) -1)) - std::cerr<<"x1(-1 - epsilon) == x1(-1) == "<::has_denorm) { - if(x1(std::numeric_limits::denorm_min()) == x1(zero)) { - std::cerr<<"x1(denorm_min) == x1(zero) == "<::denorm_min()) != - HASH_NAMESPACE::hash_value(std::numeric_limits::denorm_min())) - { - std::cerr<<"x1(std::numeric_limits::denorm_min()) = " - << x1(std::numeric_limits::denorm_min()) - << "\nhash_value(std::numeric_limits::denorm_min()) = " - << HASH_NAMESPACE::hash_value( - std::numeric_limits::denorm_min()) - << "\nx1(0) = "<::has_quiet_NaN) { - if(x1(std::numeric_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())); - } -#endif -} - -void hash_float_tests() +int main() { std::cerr<<"Compiler: "< +#else +# include +#endif + +#include + +#include +#include + +#include + +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4127) // conditional expression is constant +#endif + +template +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" + <<"\n" + ; + + HASH_NAMESPACE::hash x1; + + T zero = 0; + T minus_zero = (T) -1 * zero; + + BOOST_TEST(zero == minus_zero); + BOOST_TEST(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)); + + using namespace std; + +// Doing anything with infinity causes borland to crash. +#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) { + T infinity = -log(zero); + T infinity2 = (T) 1. / zero; + T infinity3 = (T) -1. / minus_zero; + T infinity4 = std::numeric_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) + == HASH_NAMESPACE::hash_value(minus_infinity)); + + if(infinity == infinity2) + BOOST_TEST(x1(infinity) == x1(infinity2)); + if(infinity == infinity3) + BOOST_TEST(x1(infinity) == x1(infinity3)); + if(infinity == infinity4) + BOOST_TEST(x1(infinity) == x1(infinity4)); + + if(minus_infinity == minus_infinity2) + BOOST_TEST(x1(minus_infinity) == x1(minus_infinity2)); + if(minus_infinity == minus_infinity3) + BOOST_TEST(x1(minus_infinity) == x1(minus_infinity3)); + + BOOST_TEST(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)) { + std::cerr<<"x1(denorm_min) == x1(infinity) == "<::denorm_min()) == x1(minus_infinity)) { + std::cerr<<"x1(denorm_min) == x1(-infinity) == "<::has_quiet_NaN) { + if(x1(std::numeric_limits::quiet_NaN()) == x1(infinity)) { + std::cerr<<"x1(quiet_NaN) == x1(infinity) == "<::quiet_NaN()) == x1(minus_infinity)) { + std::cerr<<"x1(quiet_NaN) == x1(-infinity) == "<::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)); + + // 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)); + +// Intel with gcc stdlib sometimes segfaults on calls to asin and acos. +#if !((defined(__INTEL_COMPILER) || defined(__ICL) || \ + defined(__ICC) || defined(__ECC)) && \ + (defined(__GLIBCPP__) || defined(__GLIBCXX__))) + 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)); +#endif + + BOOST_TEST(x1(std::numeric_limits::epsilon()) == + HASH_NAMESPACE::hash_value(std::numeric_limits::epsilon())); + + BOOST_TEST(std::numeric_limits::epsilon() != (T) 0); + if(x1(std::numeric_limits::epsilon()) == x1((T) 0)) + std::cerr<<"x1(epsilon) == x1(0) == "<::epsilon() != (T) 0); + if(x1(-std::numeric_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)) + std::cerr<<"x1(1 + epsilon) == x1(1) == "<::epsilon() != (T) 1); + if(x1((T) 1 - std::numeric_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)) + std::cerr<<"x1(-1 + epsilon) == x1(-1) == "<::epsilon() != (T) -1); + if(x1((T) -1 - std::numeric_limits::epsilon()) == x1((T) -1)) + std::cerr<<"x1(-1 - epsilon) == x1(-1) == "<::has_denorm) { + if(x1(std::numeric_limits::denorm_min()) == x1(zero)) { + std::cerr<<"x1(denorm_min) == x1(zero) == "<::denorm_min()) != + HASH_NAMESPACE::hash_value(std::numeric_limits::denorm_min())) + { + std::cerr<<"x1(std::numeric_limits::denorm_min()) = " + << x1(std::numeric_limits::denorm_min()) + << "\nhash_value(std::numeric_limits::denorm_min()) = " + << HASH_NAMESPACE::hash_value( + std::numeric_limits::denorm_min()) + << "\nx1(0) = "<::has_quiet_NaN) { + if(x1(std::numeric_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())); + } +#endif +} + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif diff --git a/hash/test/hash_friend_test.cpp b/hash/test/hash_friend_test.cpp index 362a9cb..6c6596e 100644 --- a/hash/test/hash_friend_test.cpp +++ b/hash/test/hash_friend_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2006. Use, modification, and distribution are -// subject to 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) +// 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 #include diff --git a/hash/test/hash_function_pointer_test.cpp b/hash/test/hash_function_pointer_test.cpp index 92c8769..07a0300 100644 --- a/hash/test/hash_function_pointer_test.cpp +++ b/hash/test/hash_function_pointer_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./config.hpp" diff --git a/hash/test/hash_fwd_test.hpp b/hash/test/hash_fwd_test.hpp index 017b85d..30ad609 100644 --- a/hash/test/hash_fwd_test.hpp +++ b/hash/test/hash_fwd_test.hpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2006. Use, modification, and distribution are -// subject to 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) +// 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 "./config.hpp" diff --git a/hash/test/hash_fwd_test_1.cpp b/hash/test/hash_fwd_test_1.cpp index 9d401ec..e5106a3 100644 --- a/hash/test/hash_fwd_test_1.cpp +++ b/hash/test/hash_fwd_test_1.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2006. Use, modification, and distribution are -// subject to 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) +// 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) // This checks that template code implemented using hash_fwd will work. diff --git a/hash/test/hash_fwd_test_2.cpp b/hash/test/hash_fwd_test_2.cpp index d29569b..e334194 100644 --- a/hash/test/hash_fwd_test_2.cpp +++ b/hash/test/hash_fwd_test_2.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2006. Use, modification, and distribution are -// subject to 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) +// 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) // This test just makes sure a header which uses hash_fwd can compile without // the main hash headers. diff --git a/hash/test/hash_global_namespace_test.cpp b/hash/test/hash_global_namespace_test.cpp index fa84d49..a64f5eb 100644 --- a/hash/test/hash_global_namespace_test.cpp +++ b/hash/test/hash_global_namespace_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2006. Use, modification, and distribution are -// subject to 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) +// 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) // This test demonstrates an ADL bug in Borland 5.5 where ADL isn't performed // in the global namespace. @@ -44,7 +44,7 @@ namespace boost # ifdef TEST_STD_INCLUDES # include # else -# include +# include # endif #endif diff --git a/hash/test/hash_list_test.cpp b/hash/test/hash_list_test.cpp index f6df2ad..f61b6c4 100644 --- a/hash/test/hash_list_test.cpp +++ b/hash/test/hash_list_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./config.hpp" diff --git a/hash/test/hash_long_double_test.cpp b/hash/test/hash_long_double_test.cpp new file mode 100644 index 0000000..1c3aa74 --- /dev/null +++ b/hash/test/hash_long_double_test.cpp @@ -0,0 +1,17 @@ + +// Copyright 2005-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 "hash_float_test.hpp" + +int main() +{ + std::cerr<<"Compiler: "< +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4245) // signed/unsigned mismatch +#endif + namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) { template @@ -60,5 +65,9 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + #undef CONTAINER_TYPE #endif diff --git a/hash/test/hash_no_ext_fail_test.cpp b/hash/test/hash_no_ext_fail_test.cpp index 597473a..bd123a9 100644 --- a/hash/test/hash_no_ext_fail_test.cpp +++ b/hash/test/hash_no_ext_fail_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2006. Use, modification, and distribution are -// subject to 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) +// 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) #define HASH_NAMESPACE boost diff --git a/hash/test/hash_no_ext_macro_1.cpp b/hash/test/hash_no_ext_macro_1.cpp index 5924f4e..c0f84ae 100644 --- a/hash/test/hash_no_ext_macro_1.cpp +++ b/hash/test/hash_no_ext_macro_1.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2006. Use, modification, and distribution are -// subject to 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) +// 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) #define HASH_NAMESPACE boost #include diff --git a/hash/test/hash_no_ext_macro_2.cpp b/hash/test/hash_no_ext_macro_2.cpp index 53c6e8b..75b05d7 100644 --- a/hash/test/hash_no_ext_macro_2.cpp +++ b/hash/test/hash_no_ext_macro_2.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2006. Use, modification, and distribution are -// subject to 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) +// 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) #define HASH_NAMESPACE boost #define BOOST_HASH_NO_EXTENSIONS diff --git a/hash/test/hash_number_test.cpp b/hash/test/hash_number_test.cpp index 218442b..89910a2 100644 --- a/hash/test/hash_number_test.cpp +++ b/hash/test/hash_number_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./config.hpp" @@ -21,6 +21,13 @@ #include "./compile_time.hpp" +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4127) // conditional expression is constant +#pragma warning(disable:4309) // truncation of constant value +#pragma warning(disable:4310) // cast truncates constant value +#endif + template void numeric_test(T*) { @@ -31,7 +38,7 @@ void numeric_test(T*) HASH_NAMESPACE::hash x1; HASH_NAMESPACE::hash x2; - T v1 = -5; + 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))); @@ -48,7 +55,8 @@ void numeric_test(T*) if (limits::is_integer) { - BOOST_TEST(HASH_NAMESPACE::hash_value(T(-5)) == (std::size_t)T(-5)); + 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)); @@ -105,16 +113,29 @@ void poor_quality_tests(T*) BOOST_TEST(x1((limits::max)()) != x2((limits::max)() - 1)); } +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)); +} #define NUMERIC_TEST(type, name) \ std::cerr<<"Testing: " BOOST_STRINGIZE(name) "\n"; \ numeric_test((type*) 0); \ limits_test((type*) 0); \ poor_quality_tests((type*) 0); +#define NUMERIC_TEST_NO_LIMITS(type, name) \ + std::cerr<<"Testing: " BOOST_STRINGIZE(name) "\n"; \ + numeric_test((type*) 0); \ + poor_quality_tests((type*) 0); int main() { - NUMERIC_TEST(bool, bool) NUMERIC_TEST(char, char) NUMERIC_TEST(signed char, schar) NUMERIC_TEST(unsigned char, uchar) @@ -128,11 +149,19 @@ int main() NUMERIC_TEST(long, hash_long) 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) +#endif + NUMERIC_TEST(float, float) NUMERIC_TEST(double, double) - NUMERIC_TEST(long double, ldouble) + + bool_test(); return boost::report_errors(); } - +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif diff --git a/hash/test/hash_pointer_test.cpp b/hash/test/hash_pointer_test.cpp index e38c31d..78d3416 100644 --- a/hash/test/hash_pointer_test.cpp +++ b/hash/test/hash_pointer_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./config.hpp" diff --git a/hash/test/hash_range_test.cpp b/hash/test/hash_range_test.cpp index fc56ced..9e5ef09 100644 --- a/hash/test/hash_range_test.cpp +++ b/hash/test/hash_range_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./config.hpp" diff --git a/hash/test/hash_sequence_test.hpp b/hash/test/hash_sequence_test.hpp index 7668125..eb3295c 100644 --- a/hash/test/hash_sequence_test.hpp +++ b/hash/test/hash_sequence_test.hpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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) #if !defined(CONTAINER_TYPE) #error "CONTAINER_TYPE not defined" @@ -9,6 +9,11 @@ #include +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4245) // signed/unsigned mismatch +#endif + namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) { template @@ -63,5 +68,9 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + #undef CONTAINER_TYPE #endif diff --git a/hash/test/hash_set_test.cpp b/hash/test/hash_set_test.cpp index e29334c..442291c 100644 --- a/hash/test/hash_set_test.cpp +++ b/hash/test/hash_set_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./config.hpp" diff --git a/hash/test/hash_set_test.hpp b/hash/test/hash_set_test.hpp index 26ea1af..50791a6 100644 --- a/hash/test/hash_set_test.hpp +++ b/hash/test/hash_set_test.hpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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) #if !defined(CONTAINER_TYPE) #error "CONTAINER_TYPE not defined" @@ -9,12 +9,17 @@ #include +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4245) // signed/unsigned mismatch +#endif + namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) { template void integer_tests(T* = 0) { - const int number_of_containers = 11; + const int number_of_containers = 12; T containers[number_of_containers]; for(int i = 0; i < 5; ++i) { @@ -30,6 +35,11 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) containers[9].insert(-1); containers[10].insert(-1); containers[10].insert(1); + containers[11].insert(1); + containers[11].insert(2); + containers[11].insert(3); + containers[11].insert(4); + containers[11].insert(5); HASH_NAMESPACE::hash hasher; @@ -61,5 +71,9 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + #undef CONTAINER_TYPE #endif diff --git a/hash/test/hash_string_test.cpp b/hash/test/hash_string_test.cpp index 85adacc..42ca0b7 100644 --- a/hash/test/hash_string_test.cpp +++ b/hash/test/hash_string_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./config.hpp" diff --git a/hash/test/hash_value_array_test.cpp b/hash/test/hash_value_array_test.cpp index 02444d8..7080665 100644 --- a/hash/test/hash_value_array_test.cpp +++ b/hash/test/hash_value_array_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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) // On some compilers hash_value isn't available for arrays, so I test it // separately from the main array tests. diff --git a/hash/test/hash_vector_test.cpp b/hash/test/hash_vector_test.cpp index 60bac31..bcc9c51 100644 --- a/hash/test/hash_vector_test.cpp +++ b/hash/test/hash_vector_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 "./config.hpp" diff --git a/hash/test/link_ext_test.cpp b/hash/test/link_ext_test.cpp index eeb1160..19a7299 100644 --- a/hash/test/link_ext_test.cpp +++ b/hash/test/link_ext_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2006. Use, modification, and distribution are -// subject to 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) +// 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) #define HASH_NAMESPACE boost #include diff --git a/hash/test/link_no_ext_test.cpp b/hash/test/link_no_ext_test.cpp index ab2701c..a3db5b1 100644 --- a/hash/test/link_no_ext_test.cpp +++ b/hash/test/link_no_ext_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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) #define HASH_NAMESPACE boost #define BOOST_HASH_NO_EXTENSIONS diff --git a/hash/test/link_test.cpp b/hash/test/link_test.cpp index fae30cd..eb8e51f 100644 --- a/hash/test/link_test.cpp +++ b/hash/test/link_test.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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 diff --git a/hash/test/link_test_2.cpp b/hash/test/link_test_2.cpp index 57d6528..d40f1db 100644 --- a/hash/test/link_test_2.cpp +++ b/hash/test/link_test_2.cpp @@ -1,7 +1,7 @@ -// Copyright Daniel James 2005-2006. Use, modification, and distribution are -// subject to 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) +// Copyright 2005-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