diff --git a/include/boost/math/special_functions/nonfinite_num_facets.hpp b/include/boost/math/special_functions/nonfinite_num_facets.hpp index 697a35f98..d86162dc5 100644 --- a/include/boost/math/special_functions/nonfinite_num_facets.hpp +++ b/include/boost/math/special_functions/nonfinite_num_facets.hpp @@ -493,10 +493,10 @@ namespace boost { return; } } - break; + break; // LCOV_EXCL_LINE simple fallthrough not registered as covered. default: - break; + break; // LCOV_EXCL_LINE simple fallthrough not registered as covered. } state |= std::ios_base::failbit; @@ -533,10 +533,10 @@ namespace boost { val = positive_nan(); return; } - break; + break; // LCOV_EXCL_LINE simple fallthrough not registered as covered. default: - break; + break; // LCOV_EXCL_LINE simple fallthrough not registered as covered. } } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6894dff27..66ab791ec 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -895,6 +895,7 @@ test-suite distribution_tests : [ run test_legacy_nonfinite.cpp /boost/test//boost_unit_test_framework ] [ run test_basic_nonfinite.cpp /boost/test//boost_unit_test_framework ] + [ run test_nonfinite_io.cpp /boost/test//boost_unit_test_framework ] [ run test_lexical_cast.cpp /boost/test//boost_unit_test_framework ] [ run test_nonfinite_trap.cpp /boost/test//boost_unit_test_framework : : : off:no ] [ run test_signed_zero.cpp /boost/test//boost_unit_test_framework ] diff --git a/test/test_basic_nonfinite.cpp b/test/test_basic_nonfinite.cpp index 20f0e222c..c279be9ae 100644 --- a/test/test_basic_nonfinite.cpp +++ b/test/test_basic_nonfinite.cpp @@ -163,6 +163,19 @@ template void basic_test_inf_impl() BOOST_CHECK(b2 == a2); BOOST_CHECK(b3 == std::numeric_limits::infinity()); BOOST_CHECK(ss.rdstate() == std::ios_base::eofbit); + + ss.clear(); + ss.str(S_("")); + ss << "ind"; + ss >> b1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit); + + ss.clear(); + ss.str(S_("")); + ss << "infinidy"; + ss >> b1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit); + } //------------------------------------------------------------------------------ @@ -221,6 +234,56 @@ template void basic_test_nan_impl() BOOST_CHECK(!(signbit)(b5)); BOOST_CHECK(ss.rdstate() == std::ios_base::eofbit); + + ss.clear(); + ss.str(S_("")); + ss << "nad"; + ss >> b1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit); + + ss.clear(); + ss.str(S_("")); + ss << "nan(123"; + ss >> b1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit | std::ios_base::eofbit); + + ss.clear(); + ss.str(S_("")); + ss << "qnad"; + ss >> b1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit | std::ios_base::eofbit); + + std::locale new_locale_2(tmp_locale, new nonfinite_num_get(legacy)); + ss.imbue(new_locale_2); + ss.clear(); + ss.str(S_("")); + ss << "qnan"; + ss >> b1; + BOOST_CHECK((boost::math::isnan)(b1)); + + ss.clear(); + ss.str(S_("")); + ss << "qnad"; + ss >> b1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit | std::ios_base::eofbit); + + ss.clear(); + ss.str(S_("")); + ss << "1.#SNAD"; + ss >> b1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit | std::ios_base::eofbit); + + ss.clear(); + ss.str(S_("")); + ss << "1.#POP"; + ss >> b1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit | std::ios_base::eofbit); + + ss.clear(); + ss.str(S_("")); + ss << "1.#IMP"; + ss >> b1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit | std::ios_base::eofbit); } //------------------------------------------------------------------------------ diff --git a/test/test_nonfinite_io.cpp b/test/test_nonfinite_io.cpp index 855843c71..9c50b4c25 100644 --- a/test/test_nonfinite_io.cpp +++ b/test/test_nonfinite_io.cpp @@ -22,6 +22,8 @@ #include #include +#include "boost/math/tools/test.hpp" + namespace { // Using an anonymous namespace resolves ambiguities on platforms @@ -30,7 +32,7 @@ namespace { using namespace boost::math; using boost::math::signbit; using boost::math::changesign; -using (boost::math::isnan)(; +using boost::math::isnan; //------------------------------------------------------------------------------ // Test nonfinite_num_put and nonfinite_num_get facets by checking @@ -232,6 +234,15 @@ template void trap_test_get_nan_impl() ss.clear(); ss.str(S_("")); + ValType a3 = std::numeric_limits::quiet_NaN(); + ss << std::showpos << a3; + ValType b3; + ss >> b3; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit); + + ss.clear(); + ss.str(S_("")); + ValType a2 = std::numeric_limits::signaling_NaN(); ss << a2; ValType b2;