diff --git a/src/test/basics/Number_test.cpp b/src/test/basics/Number_test.cpp index 9e928f4e9f..aa57af01b3 100644 --- a/src/test/basics/Number_test.cpp +++ b/src/test/basics/Number_test.cpp @@ -1981,13 +1981,17 @@ public: case MantissaRange::MantissaScale::Small: case MantissaRange::MantissaScale::LargeLegacy: { // Without the fix, all the results but one round up - BEAST_EXPECT(sums.at(Number::RoundingMode::TowardsZero).first > exact); - BEAST_EXPECT(sums.at(Number::RoundingMode::Upward).first > exact); - BEAST_EXPECT(sums.at(Number::RoundingMode::ToNearest).first > exact); - // Downward works because the Guard sign is negative, and Downward returns Up - // instead of Down if negative and there's a remainder, whereas TowardsZero - // always returns Down. - BEAST_EXPECT(sums.at(Number::RoundingMode::Downward).first < exact); + for (auto const& [r, sum] : sums) { + if (r == Number::RoundingMode::Downward) { + // Downward works because the Guard sign is negative, and Downward returns Up + // instead of Down if negative and there's a remainder, whereas TowardsZero + // always returns Down. + BEAST_EXPECTS(sums.at(Number::RoundingMode::Downward).first < exact, to_string(r)); + } + else { + BEAST_EXPECTS(sums.at(r).first > exact, to_string(r)); + } + } break; } default: { @@ -2000,12 +2004,12 @@ public: { case Number::RoundingMode::Upward: case Number::RoundingMode::ToNearest: - BEAST_EXPECT(sum.first > exact); - BEAST_EXPECT(diff < epsilon); + BEAST_EXPECTS(sum.first > exact, to_string(r)); + BEAST_EXPECTS(diff < epsilon, to_string(r)); break; default: - BEAST_EXPECT(sum.first < exact); - BEAST_EXPECT(-diff < epsilon); + BEAST_EXPECTS(sum.first < exact, to_string(r)); + BEAST_EXPECTS(-diff < epsilon, to_string(r)); } } } @@ -2054,14 +2058,17 @@ public: { case MantissaRange::MantissaScale::Small: case MantissaRange::MantissaScale::LargeLegacy: { - // Without the fix, all the results but one round up - BEAST_EXPECT(sums.at(Number::RoundingMode::TowardsZero).first > exact); - BEAST_EXPECT(sums.at(Number::RoundingMode::Upward).first > exact); - BEAST_EXPECT(sums.at(Number::RoundingMode::ToNearest).first > exact); - // Downward works because the Guard sign is negative, and Downward returns Up - // instead of Down if negative and there's a remainder, whereas TowardsZero - // always returns Down. - BEAST_EXPECT(sums.at(Number::RoundingMode::Downward).first < exact); + for (auto const& [r, sum] : sums) { + if (r == Number::RoundingMode::Downward) { + // Downward works because the Guard sign is negative, and Downward returns Up + // instead of Down if negative and there's a remainder, whereas TowardsZero + // always returns Down. + BEAST_EXPECTS(sums.at(Number::RoundingMode::Downward).first < exact, to_string(r)); + } + else { + BEAST_EXPECTS(sums.at(r).first > exact, to_string(r)); + } + } break; } default: { @@ -2073,12 +2080,12 @@ public: { case Number::RoundingMode::Upward: case Number::RoundingMode::ToNearest: - BEAST_EXPECT(sum.first > exact); - BEAST_EXPECT(diff < epsilon); + BEAST_EXPECTS(sum.first > exact, to_string(r)); + BEAST_EXPECTS(diff < epsilon, to_string(r)); break; default: - BEAST_EXPECT(sum.first < exact); - BEAST_EXPECT(-diff < epsilon); + BEAST_EXPECTS(sum.first < exact, to_string(r)); + BEAST_EXPECTS(-diff < epsilon, to_string(r)); } } }