Skip to content

Commit

Permalink
Add some tiny coverage improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed Jan 16, 2025
1 parent 7742123 commit 848688b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct numeric_limits<FloatingPointType,
static constexpr int max_exponent10 = std::numeric_limits<float_type>::max_exponent10;
static constexpr int min_exponent10 = std::numeric_limits<float_type>::min_exponent10;

// LCOV_EXCL_START
static constexpr auto (min) () noexcept -> float_type { return (std::numeric_limits<float_type>::min) (); }
static constexpr auto (max) () noexcept -> float_type { return (std::numeric_limits<float_type>::max) (); }
static constexpr auto lowest () noexcept -> float_type { return std::numeric_limits<float_type>::lowest (); }
Expand All @@ -67,6 +68,7 @@ struct numeric_limits<FloatingPointType,
static constexpr auto infinity () noexcept -> float_type { return std::numeric_limits<float_type>::infinity (); }
static constexpr auto quiet_NaN () noexcept -> float_type { return std::numeric_limits<float_type>::quiet_NaN (); }
static constexpr auto signaling_NaN() noexcept -> float_type { return std::numeric_limits<float_type>::signaling_NaN(); }
// LCOV_EXCL_STOP
};

#if defined(BOOST_MP_CPP_DOUBLE_FP_HAS_FLOAT128)
Expand Down
19 changes: 19 additions & 0 deletions test/test_various_edges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
#include <boost/multiprecision/cpp_double_fp.hpp>
#endif

#include <array>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <limits>
#include <random>
#include <string>

#if defined(__clang__)
# pragma clang diagnostic push
Expand Down Expand Up @@ -426,6 +430,21 @@ namespace local
BOOST_TEST(result_is_ok = ((conversion_result_max == (std::numeric_limits<unsigned long long>::max)()) && result_is_ok));
}

{
using str_nans_array_type = std::array<std::string, std::size_t { UINT8_C(3) }>;

const str_nans_array_type str_nan_reps {{ "nan", "NaN", "NAN" }};

for(auto i = static_cast<std::size_t>(UINT8_C(0)); i < str_nan_reps.size(); ++i)
{
float_type flt_nan { float_type { str_nan_reps[i].c_str() } * dis(gen) };

const bool result_nan_str_is_ok { isnan(flt_nan) };

BOOST_TEST(result_is_ok = (result_nan_str_is_ok && result_is_ok));
}
}

return result_is_ok;
}

Expand Down

0 comments on commit 848688b

Please sign in to comment.