Include rounding in failed unit tests

This commit is contained in:
Ed Hennis
2026-06-06 14:33:31 -04:00
parent 2f701121b4
commit 3a5c85067a

View File

@@ -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));
}
}
}