Fix a couple of issues: fix error check, remove incorrect test

This commit is contained in:
Ed Hennis
2026-07-16 18:59:26 -04:00
parent e0ced0e375
commit cbf2c87d7c
2 changed files with 6 additions and 4 deletions

View File

@@ -429,10 +429,10 @@ Number::Guard::doDropDigitWithTarget(T& mantissa, int& exponent, int const targe
{
XRPL_ASSERT(
targetExponent > exponent, "Number::Guard::doDropDigitWithTarget : something to do");
if (mantissa == 0 && unrecoverable() && targetExponent >= exponent)
if (mantissa == 0 && unrecoverable() && targetExponent > exponent)
{
// No number of dropped digits is going to change any of the operative parameters at this
// point
// point.
exponent = targetExponent;
return;
}

View File

@@ -185,14 +185,16 @@ struct STNumber_test : public beast::unit_test::Suite
}
catch (std::exception const& e)
{
BEAST_EXPECT(std::string(e.what()) == expected);
std::ostringstream out;
out << "Json: " << num.asString() << " got exception: " << e.what()
<< ", expected: " << expected;
BEAST_EXPECTS(std::string(e.what()) == expected, out.str());
}
};
// Obvious overflows tested here
expectJsonThrows("1e2000000", "Number::normalize 2");
expectJsonThrows("1e2000000000", "Number::normalize 2");
expectJsonThrows("1e2000000000000", "Number::normalize 2");
// Obvious non-numbers tested here
expectJsonThrows("", "'' is not a number");