forked from boostorg/functional
Attempting to work round the dodgy std::numeric_limits<long double> on
some BSDs. [SVN r35345]
This commit is contained in:
@@ -24,12 +24,12 @@ void float_tests(char const* name, T* = 0)
|
||||
std::cerr<<"\n"
|
||||
<<"Testing " BOOST_STRINGIZE(HASH_NAMESPACE) "::hash<"<<name<<">\n"
|
||||
<<"\n"
|
||||
<<"std::numeric_limits<T>::digits = "
|
||||
<<std::numeric_limits<T>::digits<<"\n"
|
||||
<<"std::numeric_limits<int>::digits = "
|
||||
<<std::numeric_limits<int>::digits<<"\n"
|
||||
<<"std::numeric_limits<std::size_t>::digits = "
|
||||
<<std::numeric_limits<std::size_t>::digits<<"\n"
|
||||
<<"boost::hash_detail::float_limits<T>::digits = "
|
||||
<<boost::hash_detail::float_limits<T>::digits<<"\n"
|
||||
<<"boost::hash_detail::float_limits<int>::digits = "
|
||||
<<boost::hash_detail::float_limits<int>::digits<<"\n"
|
||||
<<"boost::hash_detail::float_limits<std::size_t>::digits = "
|
||||
<<boost::hash_detail::float_limits<std::size_t>::digits<<"\n"
|
||||
<<"\n"
|
||||
;
|
||||
|
||||
@@ -50,11 +50,11 @@ 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<T>::has_infinity) {
|
||||
if(boost::hash_detail::float_limits<T>::has_infinity) {
|
||||
T infinity = -log(zero);
|
||||
T infinity2 = (T) 1. / zero;
|
||||
T infinity3 = (T) -1. / minus_zero;
|
||||
T infinity4 = std::numeric_limits<T>::infinity();
|
||||
T infinity4 = boost::hash_detail::float_limits<T>::infinity();
|
||||
|
||||
T minus_infinity = log(zero);
|
||||
T minus_infinity2 = (T) -1. / zero;
|
||||
@@ -84,26 +84,26 @@ void float_tests(char const* name, T* = 0)
|
||||
|
||||
// This should really be 'has_denorm == denorm_present' but some
|
||||
// compilers don't have 'denorm_present'. See also a later use.
|
||||
if(std::numeric_limits<T>::has_denorm) {
|
||||
if(x1(std::numeric_limits<T>::denorm_min()) == x1(infinity)) {
|
||||
if(boost::hash_detail::float_limits<T>::has_denorm) {
|
||||
if(x1(boost::hash_detail::float_limits<T>::denorm_min()) == x1(infinity)) {
|
||||
std::cerr<<"x1(denorm_min) == x1(infinity) == "<<x1(infinity)<<"\n";
|
||||
}
|
||||
if(x1(std::numeric_limits<T>::denorm_min()) == x1(minus_infinity)) {
|
||||
if(x1(boost::hash_detail::float_limits<T>::denorm_min()) == x1(minus_infinity)) {
|
||||
std::cerr<<"x1(denorm_min) == x1(-infinity) == "<<x1(minus_infinity)<<"\n";
|
||||
}
|
||||
}
|
||||
if(std::numeric_limits<T>::has_quiet_NaN) {
|
||||
if(x1(std::numeric_limits<T>::quiet_NaN()) == x1(infinity)) {
|
||||
if(boost::hash_detail::float_limits<T>::has_quiet_NaN) {
|
||||
if(x1(boost::hash_detail::float_limits<T>::quiet_NaN()) == x1(infinity)) {
|
||||
std::cerr<<"x1(quiet_NaN) == x1(infinity) == "<<x1(infinity)<<"\n";
|
||||
}
|
||||
if(x1(std::numeric_limits<T>::quiet_NaN()) == x1(minus_infinity)) {
|
||||
if(x1(boost::hash_detail::float_limits<T>::quiet_NaN()) == x1(minus_infinity)) {
|
||||
std::cerr<<"x1(quiet_NaN) == x1(-infinity) == "<<x1(minus_infinity)<<"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
T max = (std::numeric_limits<T>::max)();
|
||||
T max = (boost::hash_detail::float_limits<T>::max)();
|
||||
T half_max = max / 2;
|
||||
T quarter_max = max / 4;
|
||||
T three_quarter_max = max - quarter_max;
|
||||
@@ -132,50 +132,50 @@ void float_tests(char const* name, T* = 0)
|
||||
BOOST_TEST(x1(v1) == HASH_NAMESPACE::hash_value(v1));
|
||||
BOOST_TEST(x1(v2) == HASH_NAMESPACE::hash_value(v2));
|
||||
|
||||
BOOST_TEST(x1(std::numeric_limits<T>::epsilon()) ==
|
||||
HASH_NAMESPACE::hash_value(std::numeric_limits<T>::epsilon()));
|
||||
BOOST_TEST(x1(boost::hash_detail::float_limits<T>::epsilon()) ==
|
||||
HASH_NAMESPACE::hash_value(boost::hash_detail::float_limits<T>::epsilon()));
|
||||
|
||||
BOOST_TEST(std::numeric_limits<T>::epsilon() != (T) 0);
|
||||
if(x1(std::numeric_limits<T>::epsilon()) == x1((T) 0))
|
||||
BOOST_TEST(boost::hash_detail::float_limits<T>::epsilon() != (T) 0);
|
||||
if(x1(boost::hash_detail::float_limits<T>::epsilon()) == x1((T) 0))
|
||||
std::cerr<<"x1(epsilon) == x1(0) == "<<x1((T) 0)<<"\n";
|
||||
|
||||
BOOST_TEST(-std::numeric_limits<T>::epsilon() != (T) 0);
|
||||
if(x1(-std::numeric_limits<T>::epsilon()) == x1((T) 0))
|
||||
BOOST_TEST(-boost::hash_detail::float_limits<T>::epsilon() != (T) 0);
|
||||
if(x1(-boost::hash_detail::float_limits<T>::epsilon()) == x1((T) 0))
|
||||
std::cerr<<"x1(-epsilon) == x1(0) == "<<x1((T) 0)<<"\n";
|
||||
|
||||
BOOST_TEST((T) 1 + std::numeric_limits<T>::epsilon() != (T) 1);
|
||||
if(x1((T) 1 + std::numeric_limits<T>::epsilon()) == x1((T) 1))
|
||||
BOOST_TEST((T) 1 + boost::hash_detail::float_limits<T>::epsilon() != (T) 1);
|
||||
if(x1((T) 1 + boost::hash_detail::float_limits<T>::epsilon()) == x1((T) 1))
|
||||
std::cerr<<"x1(1 + epsilon) == x1(1) == "<<x1((T) 1)<<"\n";
|
||||
|
||||
BOOST_TEST((T) 1 - std::numeric_limits<T>::epsilon() != (T) 1);
|
||||
if(x1((T) 1 - std::numeric_limits<T>::epsilon()) == x1((T) 1))
|
||||
BOOST_TEST((T) 1 - boost::hash_detail::float_limits<T>::epsilon() != (T) 1);
|
||||
if(x1((T) 1 - boost::hash_detail::float_limits<T>::epsilon()) == x1((T) 1))
|
||||
std::cerr<<"x1(1 - epsilon) == x1(1) == "<<x1((T) 1)<<"\n";
|
||||
|
||||
BOOST_TEST((T) -1 + std::numeric_limits<T>::epsilon() != (T) -1);
|
||||
if(x1((T) -1 + std::numeric_limits<T>::epsilon()) == x1((T) -1))
|
||||
BOOST_TEST((T) -1 + boost::hash_detail::float_limits<T>::epsilon() != (T) -1);
|
||||
if(x1((T) -1 + boost::hash_detail::float_limits<T>::epsilon()) == x1((T) -1))
|
||||
std::cerr<<"x1(-1 + epsilon) == x1(-1) == "<<x1((T) -1)<<"\n";
|
||||
|
||||
BOOST_TEST((T) -1 - std::numeric_limits<T>::epsilon() != (T) -1);
|
||||
if(x1((T) -1 - std::numeric_limits<T>::epsilon()) == x1((T) -1))
|
||||
BOOST_TEST((T) -1 - boost::hash_detail::float_limits<T>::epsilon() != (T) -1);
|
||||
if(x1((T) -1 - boost::hash_detail::float_limits<T>::epsilon()) == x1((T) -1))
|
||||
std::cerr<<"x1(-1 - epsilon) == x1(-1) == "<<x1((T) -1)<<"\n";
|
||||
|
||||
// As before.
|
||||
if(std::numeric_limits<T>::has_denorm) {
|
||||
if(x1(std::numeric_limits<T>::denorm_min()) == x1(zero)) {
|
||||
if(boost::hash_detail::float_limits<T>::has_denorm) {
|
||||
if(x1(boost::hash_detail::float_limits<T>::denorm_min()) == x1(zero)) {
|
||||
std::cerr<<"x1(denorm_min) == x1(zero) == "<<x1(zero)<<"\n";
|
||||
}
|
||||
#if !BOOST_WORKAROUND(__DECCXX_VER,<70190006)
|
||||
// The Tru64/CXX standard library prior to 7.1 contains a bug in the
|
||||
// specialization of std::numeric_limits::denorm_min() for long
|
||||
// specialization of boost::hash_detail::float_limits::denorm_min() for long
|
||||
// doubles which causes this test to fail.
|
||||
if(x1(std::numeric_limits<T>::denorm_min()) !=
|
||||
HASH_NAMESPACE::hash_value(std::numeric_limits<T>::denorm_min()))
|
||||
if(x1(boost::hash_detail::float_limits<T>::denorm_min()) !=
|
||||
HASH_NAMESPACE::hash_value(boost::hash_detail::float_limits<T>::denorm_min()))
|
||||
{
|
||||
std::cerr<<"x1(std::numeric_limits<T>::denorm_min()) = "
|
||||
<< x1(std::numeric_limits<T>::denorm_min())
|
||||
<< "\nhash_value(std::numeric_limits<T>::denorm_min()) = "
|
||||
std::cerr<<"x1(boost::hash_detail::float_limits<T>::denorm_min()) = "
|
||||
<< x1(boost::hash_detail::float_limits<T>::denorm_min())
|
||||
<< "\nhash_value(boost::hash_detail::float_limits<T>::denorm_min()) = "
|
||||
<< HASH_NAMESPACE::hash_value(
|
||||
std::numeric_limits<T>::denorm_min())
|
||||
boost::hash_detail::float_limits<T>::denorm_min())
|
||||
<< "\nx1(0) = "<<x1(0)<<"\n";
|
||||
}
|
||||
#endif
|
||||
@@ -183,12 +183,12 @@ void float_tests(char const* name, T* = 0)
|
||||
|
||||
// NaN also causes borland to crash.
|
||||
#if !defined(__BORLANDC__)
|
||||
if(std::numeric_limits<T>::has_quiet_NaN) {
|
||||
if(x1(std::numeric_limits<T>::quiet_NaN()) == x1(1.0)) {
|
||||
if(boost::hash_detail::float_limits<T>::has_quiet_NaN) {
|
||||
if(x1(boost::hash_detail::float_limits<T>::quiet_NaN()) == x1(1.0)) {
|
||||
std::cerr<<"x1(quiet_NaN) == x1(1.0) == "<<x1(1.0)<<"\n";
|
||||
}
|
||||
BOOST_TEST(x1(std::numeric_limits<T>::quiet_NaN()) ==
|
||||
HASH_NAMESPACE::hash_value(std::numeric_limits<T>::quiet_NaN()));
|
||||
BOOST_TEST(x1(boost::hash_detail::float_limits<T>::quiet_NaN()) ==
|
||||
HASH_NAMESPACE::hash_value(boost::hash_detail::float_limits<T>::quiet_NaN()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user