diff --git a/test/test_basic_nonfinite.cpp b/test/test_basic_nonfinite.cpp index fe6222d54..1776abe82 100644 --- a/test/test_basic_nonfinite.cpp +++ b/test/test_basic_nonfinite.cpp @@ -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 @@ void basic_test_finite() template void basic_test_finite_impl() { + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + return; + std::locale old_locale; std::locale tmp_locale(old_locale, new nonfinite_num_put); std::locale new_locale(tmp_locale, new nonfinite_num_get); @@ -129,6 +133,9 @@ void basic_test_inf() template void basic_test_inf_impl() { + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + return; + std::locale old_locale; std::locale tmp_locale(old_locale, new nonfinite_num_put); std::locale new_locale(tmp_locale, new nonfinite_num_get); @@ -139,6 +146,9 @@ template void basic_test_inf_impl() ValType a1 = std::numeric_limits::infinity(); ValType a2 = -std::numeric_limits::infinity(); + BOOST_CHECK((boost::math::isinf)(a1)); + BOOST_CHECK((boost::math::isinf)(a2)); + ss << a1 << ' ' << a2; std::basic_string s = S_("inf -inf"); @@ -173,6 +183,9 @@ void basic_test_nan() template void basic_test_nan_impl() { + if((std::numeric_limits::has_quiet_NaN == 0) || (std::numeric_limits::quiet_NaN() == 0)) + return; + std::locale old_locale; std::locale tmp_locale(old_locale, new nonfinite_num_put); std::locale new_locale(tmp_locale, new nonfinite_num_get); @@ -181,11 +194,13 @@ template void basic_test_nan_impl() ss.imbue(new_locale); ValType a1 = std::numeric_limits::quiet_NaN(); - ValType a2 = -std::numeric_limits::quiet_NaN(); + ValType a2 = (boost::math::changesign)(std::numeric_limits::quiet_NaN()); ValType a3 = std::numeric_limits::signaling_NaN(); - ValType a4 = -std::numeric_limits::signaling_NaN(); + ValType a4 = (boost::math::changesign)(std::numeric_limits::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 s = S_("nan -nan nan -nan"); BOOST_CHECK(ss.str() == s); @@ -226,6 +241,9 @@ void basic_test_format() template void basic_test_format_impl() { + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + return; + std::locale old_locale; std::locale tmp_locale(old_locale, new nonfinite_num_put); std::locale new_locale(tmp_locale, new nonfinite_num_get); @@ -235,6 +253,8 @@ template void basic_test_format_impl() ValType a = std::numeric_limits::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". diff --git a/test/test_lexical_cast.cpp b/test/test_lexical_cast.cpp index ce9699e5e..fae34304e 100644 --- a/test/test_lexical_cast.cpp +++ b/test/test_lexical_cast.cpp @@ -1,3 +1,4 @@ + // Copyright (c) 2006 Johan Rade // Copyright (c) 2011 Paul A. Bristow incorporated Boost.Math @@ -52,6 +53,11 @@ BOOST_AUTO_TEST_CASE(lexical_cast_test) template void lexical_cast_test_impl() { + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + return; + if((std::numeric_limits::has_quiet_NaN == 0) || (std::numeric_limits::quiet_NaN() == 0)) + return; + std::locale old_locale; std::locale tmp_locale(old_locale, new nonfinite_num_put(signed_zero)); @@ -66,8 +72,8 @@ template void lexical_cast_test_impl() ValType a6 = (changesign)(static_cast(0)); ValType a7 = static_cast(-57); ValType a8 = -std::numeric_limits::infinity(); - ValType a9 = -std::numeric_limits::quiet_NaN(); - ValType a10 = -std::numeric_limits::signaling_NaN(); + ValType a9 = (changesign)(std::numeric_limits::quiet_NaN()); + ValType a10 = (changesign)(std::numeric_limits::signaling_NaN()); std::basic_string s1 = S_("0"); std::basic_string s2 = S_("13");