mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
chore: Enable clang-tidy misc checks (#6655)
This commit is contained in:
@@ -37,7 +37,8 @@ public:
|
||||
auto const minMantissa = Number::minMantissa();
|
||||
try
|
||||
{
|
||||
Number x = Number{false, minMantissa * 10, 32768, Number::normalized{}};
|
||||
[[maybe_unused]] Number const x =
|
||||
Number{false, minMantissa * 10, 32768, Number::normalized{}};
|
||||
}
|
||||
catch (std::overflow_error const&)
|
||||
{
|
||||
@@ -86,7 +87,7 @@ public:
|
||||
try
|
||||
{
|
||||
[[maybe_unused]]
|
||||
Number q = Number{false, minMantissa, 32767, Number::normalized{}} * 100;
|
||||
Number const q = Number{false, minMantissa, 32767, Number::normalized{}} * 100;
|
||||
}
|
||||
catch (std::overflow_error const&)
|
||||
{
|
||||
@@ -332,7 +333,7 @@ public:
|
||||
};
|
||||
auto const maxMantissa = Number::maxMantissa();
|
||||
|
||||
saveNumberRoundMode save{Number::setround(Number::to_nearest)};
|
||||
saveNumberRoundMode const save{Number::setround(Number::to_nearest)};
|
||||
{
|
||||
auto const cSmall = std::to_array<Case>({
|
||||
{Number{7}, Number{8}, Number{56}},
|
||||
@@ -642,7 +643,7 @@ public:
|
||||
test(cLarge);
|
||||
}
|
||||
};
|
||||
saveNumberRoundMode save{Number::setround(Number::to_nearest)};
|
||||
saveNumberRoundMode const save{Number::setround(Number::to_nearest)};
|
||||
{
|
||||
auto const cSmall = std::to_array<Case>(
|
||||
{{Number{1}, Number{2}, Number{5, -1}},
|
||||
@@ -857,7 +858,7 @@ public:
|
||||
test(cSmall);
|
||||
if (Number::getMantissaScale() != MantissaRange::small)
|
||||
{
|
||||
NumberRoundModeGuard mg(Number::towards_zero);
|
||||
NumberRoundModeGuard const mg(Number::towards_zero);
|
||||
test(cLarge);
|
||||
}
|
||||
bool caught = false;
|
||||
@@ -928,7 +929,7 @@ public:
|
||||
{
|
||||
testcase << "test_power1 " << to_string(Number::getMantissaScale());
|
||||
using Case = std::tuple<Number, unsigned, Number>;
|
||||
Case c[]{
|
||||
Case const c[]{
|
||||
{Number{64}, 0, Number{1}},
|
||||
{Number{64}, 1, Number{64}},
|
||||
{Number{64}, 2, Number{4096}},
|
||||
@@ -946,7 +947,7 @@ public:
|
||||
{
|
||||
testcase << "test_power2 " << to_string(Number::getMantissaScale());
|
||||
using Case = std::tuple<Number, unsigned, unsigned, Number>;
|
||||
Case c[]{
|
||||
Case const c[]{
|
||||
{Number{1}, 3, 7, Number{1}},
|
||||
{Number{-1}, 1, 0, Number{1}},
|
||||
{Number{-1, -1}, 1, 0, Number{0}},
|
||||
@@ -992,24 +993,24 @@ public:
|
||||
{
|
||||
testcase << "testConversions " << to_string(Number::getMantissaScale());
|
||||
|
||||
IOUAmount x{5, 6};
|
||||
Number y = x;
|
||||
IOUAmount const x{5, 6};
|
||||
Number const y = x;
|
||||
BEAST_EXPECT((y == Number{5, 6}));
|
||||
IOUAmount z{y};
|
||||
IOUAmount const z{y};
|
||||
BEAST_EXPECT(x == z);
|
||||
XRPAmount xrp{500};
|
||||
STAmount st = xrp;
|
||||
Number n = st;
|
||||
XRPAmount const xrp{500};
|
||||
STAmount const st = xrp;
|
||||
Number const n = st;
|
||||
BEAST_EXPECT(XRPAmount{n} == xrp);
|
||||
IOUAmount x0{0, 0};
|
||||
Number y0 = x0;
|
||||
IOUAmount const x0{0, 0};
|
||||
Number const y0 = x0;
|
||||
BEAST_EXPECT((y0 == Number{0}));
|
||||
IOUAmount z0{y0};
|
||||
IOUAmount const z0{y0};
|
||||
BEAST_EXPECT(x0 == z0);
|
||||
XRPAmount xrp0{0};
|
||||
Number n0 = xrp0;
|
||||
XRPAmount const xrp0{0};
|
||||
Number const n0 = xrp0;
|
||||
BEAST_EXPECT(n0 == Number{0});
|
||||
XRPAmount xrp1{n0};
|
||||
XRPAmount const xrp1{n0};
|
||||
BEAST_EXPECT(xrp1 == xrp0);
|
||||
}
|
||||
|
||||
@@ -1018,9 +1019,9 @@ public:
|
||||
{
|
||||
testcase << "test_to_integer " << to_string(Number::getMantissaScale());
|
||||
using Case = std::tuple<Number, std::int64_t>;
|
||||
saveNumberRoundMode save{Number::setround(Number::to_nearest)};
|
||||
saveNumberRoundMode const save{Number::setround(Number::to_nearest)};
|
||||
{
|
||||
Case c[]{
|
||||
Case const c[]{
|
||||
{Number{0}, 0},
|
||||
{Number{1}, 1},
|
||||
{Number{2}, 2},
|
||||
@@ -1058,7 +1059,7 @@ public:
|
||||
auto prev_mode = Number::setround(Number::towards_zero);
|
||||
BEAST_EXPECT(prev_mode == Number::to_nearest);
|
||||
{
|
||||
Case c[]{
|
||||
Case const c[]{
|
||||
{Number{0}, 0},
|
||||
{Number{1}, 1},
|
||||
{Number{2}, 2},
|
||||
@@ -1096,7 +1097,7 @@ public:
|
||||
prev_mode = Number::setround(Number::downward);
|
||||
BEAST_EXPECT(prev_mode == Number::towards_zero);
|
||||
{
|
||||
Case c[]{
|
||||
Case const c[]{
|
||||
{Number{0}, 0},
|
||||
{Number{1}, 1},
|
||||
{Number{2}, 2},
|
||||
@@ -1134,7 +1135,7 @@ public:
|
||||
prev_mode = Number::setround(Number::upward);
|
||||
BEAST_EXPECT(prev_mode == Number::downward);
|
||||
{
|
||||
Case c[]{
|
||||
Case const c[]{
|
||||
{Number{0}, 0},
|
||||
{Number{1}, 1},
|
||||
{Number{2}, 2},
|
||||
@@ -1185,7 +1186,7 @@ public:
|
||||
test_squelch()
|
||||
{
|
||||
testcase << "test_squelch " << to_string(Number::getMantissaScale());
|
||||
Number limit{1, -6};
|
||||
Number const limit{1, -6};
|
||||
BEAST_EXPECT((squelch(Number{2, -6}, limit) == Number{2, -6}));
|
||||
BEAST_EXPECT((squelch(Number{1, -6}, limit) == Number{1, -6}));
|
||||
BEAST_EXPECT((squelch(Number{9, -7}, limit) == Number{0}));
|
||||
@@ -1233,7 +1234,7 @@ public:
|
||||
test(Number::max(), "9999999999999999e32768");
|
||||
test(Number::lowest(), "-9999999999999999e32768");
|
||||
{
|
||||
NumberRoundModeGuard mg(Number::towards_zero);
|
||||
NumberRoundModeGuard const mg(Number::towards_zero);
|
||||
|
||||
auto const maxMantissa = Number::maxMantissa();
|
||||
BEAST_EXPECT(maxMantissa == 9'999'999'999'999'999);
|
||||
@@ -1263,7 +1264,7 @@ public:
|
||||
test(Number::max(), "9223372036854775807e32768");
|
||||
test(Number::lowest(), "-9223372036854775807e32768");
|
||||
{
|
||||
NumberRoundModeGuard mg(Number::towards_zero);
|
||||
NumberRoundModeGuard const mg(Number::towards_zero);
|
||||
|
||||
auto const maxMantissa = Number::maxMantissa();
|
||||
BEAST_EXPECT(maxMantissa == 9'999'999'999'999'999'999ULL);
|
||||
@@ -1314,7 +1315,7 @@ public:
|
||||
test_stream()
|
||||
{
|
||||
testcase << "test_stream " << to_string(Number::getMantissaScale());
|
||||
Number x{100};
|
||||
Number const x{100};
|
||||
std::ostringstream os;
|
||||
os << x;
|
||||
BEAST_EXPECT(os.str() == to_string(x));
|
||||
@@ -1325,7 +1326,7 @@ public:
|
||||
{
|
||||
testcase << "test_inc_dec " << to_string(Number::getMantissaScale());
|
||||
Number x{100};
|
||||
Number y = +x;
|
||||
Number const y = +x;
|
||||
BEAST_EXPECT(x == y);
|
||||
BEAST_EXPECT(x++ == y);
|
||||
BEAST_EXPECT(x == Number{101});
|
||||
@@ -1336,7 +1337,7 @@ public:
|
||||
void
|
||||
test_toSTAmount()
|
||||
{
|
||||
NumberSO stNumberSO{true};
|
||||
NumberSO const stNumberSO{true};
|
||||
Issue const issue;
|
||||
Number const n{7'518'783'80596, -5};
|
||||
saveNumberRoundMode const save{Number::setround(Number::to_nearest)};
|
||||
@@ -1478,7 +1479,7 @@ public:
|
||||
{
|
||||
for (auto const& [mode, val] : roundings)
|
||||
{
|
||||
NumberRoundModeGuard g{mode};
|
||||
NumberRoundModeGuard const g{mode};
|
||||
auto const res = static_cast<std::int64_t>(num);
|
||||
BEAST_EXPECTS(
|
||||
res == val,
|
||||
@@ -1496,7 +1497,7 @@ public:
|
||||
|
||||
// Control case
|
||||
BEAST_EXPECT(Number::maxMantissa() > 10);
|
||||
Number ten{10};
|
||||
Number const ten{10};
|
||||
BEAST_EXPECT(ten.exponent() <= 0);
|
||||
|
||||
if (scale == MantissaRange::small)
|
||||
@@ -1528,7 +1529,7 @@ public:
|
||||
// 85'070'591'730'234'615'847'396'907'784'232'501'249 - 38 digits
|
||||
BEAST_EXPECT((power(maxInt64, 2) == Number{85'070'591'730'234'615'85, 19}));
|
||||
|
||||
NumberRoundModeGuard mg(Number::towards_zero);
|
||||
NumberRoundModeGuard const mg(Number::towards_zero);
|
||||
|
||||
auto const maxMantissa = Number::maxMantissa();
|
||||
Number const max = Number{false, maxMantissa, 0, Number::normalized{}};
|
||||
@@ -1546,7 +1547,7 @@ public:
|
||||
{
|
||||
for (auto const scale : {MantissaRange::small, MantissaRange::large})
|
||||
{
|
||||
NumberMantissaScaleGuard sg(scale);
|
||||
NumberMantissaScaleGuard const sg(scale);
|
||||
testZero();
|
||||
test_limits();
|
||||
testToString();
|
||||
|
||||
Reference in New Issue
Block a user