Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71420 - trunk/libs/math/test
From: john_at_[hidden]
Date: 2011-04-22 13:24:55


Author: johnmaddock
Date: 2011-04-22 13:24:53 EDT (Fri, 22 Apr 2011)
New Revision: 71420
URL: http://svn.boost.org/trac/boost/changeset/71420

Log:
Fix Intel/Linux regressions.
Text files modified:
   trunk/libs/math/test/test_basic_nonfinite.cpp | 24 ++++++++++++++++++++++--
   trunk/libs/math/test/test_lexical_cast.cpp | 10 ++++++++--
   2 files changed, 30 insertions(+), 4 deletions(-)

Modified: trunk/libs/math/test/test_basic_nonfinite.cpp
==============================================================================
--- trunk/libs/math/test/test_basic_nonfinite.cpp (original)
+++ trunk/libs/math/test/test_basic_nonfinite.cpp 2011-04-22 13:24:53 EDT (Fri, 22 Apr 2011)
@@ -1,4 +1,5 @@
 
+
 // 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)
@@ -80,6 +81,9 @@
 
 template<class CharType, class ValType> void basic_test_finite_impl()
 {
+ if((std::numeric_limits<ValType>::has_infinity == 0) || (std::numeric_limits<ValType>::infinity() == 0))
+ return;
+
     std::locale old_locale;
     std::locale tmp_locale(old_locale, new nonfinite_num_put<CharType>);
     std::locale new_locale(tmp_locale, new nonfinite_num_get<CharType>);
@@ -129,6 +133,9 @@
 
 template<class CharType, class ValType> void basic_test_inf_impl()
 {
+ if((std::numeric_limits<ValType>::has_infinity == 0) || (std::numeric_limits<ValType>::infinity() == 0))
+ return;
+
     std::locale old_locale;
     std::locale tmp_locale(old_locale, new nonfinite_num_put<CharType>);
     std::locale new_locale(tmp_locale, new nonfinite_num_get<CharType>);
@@ -139,6 +146,9 @@
     ValType a1 = std::numeric_limits<ValType>::infinity();
     ValType a2 = -std::numeric_limits<ValType>::infinity();
 
+ BOOST_CHECK((boost::math::isinf)(a1));
+ BOOST_CHECK((boost::math::isinf)(a2));
+
     ss << a1 << ' ' << a2;
 
     std::basic_string<CharType> s = S_("inf -inf");
@@ -173,6 +183,9 @@
 
 template<class CharType, class ValType> void basic_test_nan_impl()
 {
+ if((std::numeric_limits<ValType>::has_quiet_NaN == 0) || (std::numeric_limits<ValType>::quiet_NaN() == 0))
+ return;
+
     std::locale old_locale;
     std::locale tmp_locale(old_locale, new nonfinite_num_put<CharType>);
     std::locale new_locale(tmp_locale, new nonfinite_num_get<CharType>);
@@ -181,11 +194,13 @@
     ss.imbue(new_locale);
 
     ValType a1 = std::numeric_limits<ValType>::quiet_NaN();
- ValType a2 = -std::numeric_limits<ValType>::quiet_NaN();
+ ValType a2 = (boost::math::changesign)(std::numeric_limits<ValType>::quiet_NaN());
     ValType a3 = std::numeric_limits<ValType>::signaling_NaN();
- ValType a4 = -std::numeric_limits<ValType>::signaling_NaN();
+ ValType a4 = (boost::math::changesign)(std::numeric_limits<ValType>::signaling_NaN());
     ss << a1 << ' ' << a2 << ' ' << a3 << ' ' << a4;
 
+ BOOST_CHECK((boost::math::isnan)(a1) && (boost::math::isnan)(a2) && (boost::math::isnan)(a3) && (boost::math::isnan)(a4));
+
     std::basic_string<CharType> s = S_("nan -nan nan -nan");
     BOOST_CHECK(ss.str() == s);
 
@@ -226,6 +241,9 @@
 
 template<class CharType, class ValType> void basic_test_format_impl()
 {
+ if((std::numeric_limits<ValType>::has_infinity == 0) || (std::numeric_limits<ValType>::infinity() == 0))
+ return;
+
     std::locale old_locale;
     std::locale tmp_locale(old_locale, new nonfinite_num_put<CharType>);
     std::locale new_locale(tmp_locale, new nonfinite_num_get<CharType>);
@@ -235,6 +253,8 @@
 
     ValType a = std::numeric_limits<ValType>::infinity();
 
+ BOOST_CHECK((boost::math::isinf)(a));
+
     ss << std::setw(6) << a; // Expect right justified in field of six, so 3 leading spaces.
     ss << '|';
     ss << std::setw(2) << a; // Too narrow for "inf", but should still be "inf".

Modified: trunk/libs/math/test/test_lexical_cast.cpp
==============================================================================
--- trunk/libs/math/test/test_lexical_cast.cpp (original)
+++ trunk/libs/math/test/test_lexical_cast.cpp 2011-04-22 13:24:53 EDT (Fri, 22 Apr 2011)
@@ -1,3 +1,4 @@
+
 // Copyright (c) 2006 Johan Rade
 
 // Copyright (c) 2011 Paul A. Bristow incorporated Boost.Math
@@ -52,6 +53,11 @@
 
 template<class CharType, class ValType> void lexical_cast_test_impl()
 {
+ if((std::numeric_limits<ValType>::has_infinity == 0) || (std::numeric_limits<ValType>::infinity() == 0))
+ return;
+ if((std::numeric_limits<ValType>::has_quiet_NaN == 0) || (std::numeric_limits<ValType>::quiet_NaN() == 0))
+ return;
+
     std::locale old_locale;
     std::locale tmp_locale(old_locale,
         new nonfinite_num_put<CharType>(signed_zero));
@@ -66,8 +72,8 @@
     ValType a6 = (changesign)(static_cast<ValType>(0));
     ValType a7 = static_cast<ValType>(-57);
     ValType a8 = -std::numeric_limits<ValType>::infinity();
- ValType a9 = -std::numeric_limits<ValType>::quiet_NaN();
- ValType a10 = -std::numeric_limits<ValType>::signaling_NaN();
+ ValType a9 = (changesign)(std::numeric_limits<ValType>::quiet_NaN());
+ ValType a10 = (changesign)(std::numeric_limits<ValType>::signaling_NaN());
 
     std::basic_string<CharType> s1 = S_("0");
     std::basic_string<CharType> s2 = S_("13");


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk