mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-05 09:46:53 +00:00
chore: Enable clang-tidy misc checks (#6655)
This commit is contained in:
@@ -28,7 +28,7 @@ public:
|
||||
return amount;
|
||||
|
||||
std::uint64_t mantissa = amount.mantissa();
|
||||
std::uint64_t valueDigits = mantissa % 1000000000;
|
||||
std::uint64_t const valueDigits = mantissa % 1000000000;
|
||||
|
||||
if (valueDigits == 1)
|
||||
{
|
||||
@@ -67,15 +67,15 @@ public:
|
||||
roundTest(int n, int d, int m)
|
||||
{
|
||||
// check STAmount rounding
|
||||
STAmount num(noIssue(), n);
|
||||
STAmount den(noIssue(), d);
|
||||
STAmount mul(noIssue(), m);
|
||||
STAmount quot = divide(STAmount(n), STAmount(d), noIssue());
|
||||
STAmount res = roundSelf(multiply(quot, mul, noIssue()));
|
||||
STAmount const num(noIssue(), n);
|
||||
STAmount const den(noIssue(), d);
|
||||
STAmount const mul(noIssue(), m);
|
||||
STAmount const quot = divide(STAmount(n), STAmount(d), noIssue());
|
||||
STAmount const res = roundSelf(multiply(quot, mul, noIssue()));
|
||||
|
||||
BEAST_EXPECT(!res.native());
|
||||
|
||||
STAmount cmp(noIssue(), (n * m) / d);
|
||||
STAmount const cmp(noIssue(), (n * m) / d);
|
||||
|
||||
BEAST_EXPECT(!cmp.native());
|
||||
|
||||
@@ -93,13 +93,14 @@ public:
|
||||
void
|
||||
mulTest(int a, int b)
|
||||
{
|
||||
STAmount aa(noIssue(), a);
|
||||
STAmount bb(noIssue(), b);
|
||||
STAmount prod1(multiply(aa, bb, noIssue()));
|
||||
STAmount const aa(noIssue(), a);
|
||||
STAmount const bb(noIssue(), b);
|
||||
STAmount const prod1(multiply(aa, bb, noIssue()));
|
||||
|
||||
BEAST_EXPECT(!prod1.native());
|
||||
|
||||
STAmount prod2(noIssue(), static_cast<std::uint64_t>(a) * static_cast<std::uint64_t>(b));
|
||||
STAmount const prod2(
|
||||
noIssue(), static_cast<std::uint64_t>(a) * static_cast<std::uint64_t>(b));
|
||||
|
||||
if (prod1 != prod2)
|
||||
{
|
||||
@@ -196,7 +197,11 @@ public:
|
||||
testNativeCurrency()
|
||||
{
|
||||
testcase("native currency");
|
||||
STAmount zeroSt, one(1), hundred(100);
|
||||
|
||||
STAmount const zeroSt;
|
||||
STAmount const one(1);
|
||||
STAmount const hundred(100);
|
||||
|
||||
// VFALCO NOTE Why repeat "STAmount fail" so many times??
|
||||
unexpected(serializeAndDeserialize(zeroSt) != zeroSt, "STAmount fail");
|
||||
unexpected(serializeAndDeserialize(one) != one, "STAmount fail");
|
||||
@@ -206,60 +211,60 @@ public:
|
||||
unexpected(zeroSt != beast::zero, "STAmount fail");
|
||||
unexpected(one == beast::zero, "STAmount fail");
|
||||
unexpected(hundred == beast::zero, "STAmount fail");
|
||||
unexpected((zeroSt < zeroSt), "STAmount fail");
|
||||
unexpected((zeroSt < zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt < one), "STAmount fail");
|
||||
unexpected(!(zeroSt < hundred), "STAmount fail");
|
||||
unexpected((one < zeroSt), "STAmount fail");
|
||||
unexpected((one < one), "STAmount fail");
|
||||
unexpected((one < one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(one < hundred), "STAmount fail");
|
||||
unexpected((hundred < zeroSt), "STAmount fail");
|
||||
unexpected((hundred < one), "STAmount fail");
|
||||
unexpected((hundred < hundred), "STAmount fail");
|
||||
unexpected((zeroSt > zeroSt), "STAmount fail");
|
||||
unexpected((hundred < hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((zeroSt > zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((zeroSt > one), "STAmount fail");
|
||||
unexpected((zeroSt > hundred), "STAmount fail");
|
||||
unexpected(!(one > zeroSt), "STAmount fail");
|
||||
unexpected((one > one), "STAmount fail");
|
||||
unexpected((one > one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((one > hundred), "STAmount fail");
|
||||
unexpected(!(hundred > zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred > one), "STAmount fail");
|
||||
unexpected((hundred > hundred), "STAmount fail");
|
||||
unexpected(!(zeroSt <= zeroSt), "STAmount fail");
|
||||
unexpected((hundred > hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt <= zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt <= one), "STAmount fail");
|
||||
unexpected(!(zeroSt <= hundred), "STAmount fail");
|
||||
unexpected((one <= zeroSt), "STAmount fail");
|
||||
unexpected(!(one <= one), "STAmount fail");
|
||||
unexpected(!(one <= one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(one <= hundred), "STAmount fail");
|
||||
unexpected((hundred <= zeroSt), "STAmount fail");
|
||||
unexpected((hundred <= one), "STAmount fail");
|
||||
unexpected(!(hundred <= hundred), "STAmount fail");
|
||||
unexpected(!(zeroSt >= zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred <= hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt >= zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((zeroSt >= one), "STAmount fail");
|
||||
unexpected((zeroSt >= hundred), "STAmount fail");
|
||||
unexpected(!(one >= zeroSt), "STAmount fail");
|
||||
unexpected(!(one >= one), "STAmount fail");
|
||||
unexpected(!(one >= one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((one >= hundred), "STAmount fail");
|
||||
unexpected(!(hundred >= zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred >= one), "STAmount fail");
|
||||
unexpected(!(hundred >= hundred), "STAmount fail");
|
||||
unexpected(!(zeroSt == zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred >= hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt == zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((zeroSt == one), "STAmount fail");
|
||||
unexpected((zeroSt == hundred), "STAmount fail");
|
||||
unexpected((one == zeroSt), "STAmount fail");
|
||||
unexpected(!(one == one), "STAmount fail");
|
||||
unexpected(!(one == one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((one == hundred), "STAmount fail");
|
||||
unexpected((hundred == zeroSt), "STAmount fail");
|
||||
unexpected((hundred == one), "STAmount fail");
|
||||
unexpected(!(hundred == hundred), "STAmount fail");
|
||||
unexpected((zeroSt != zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred == hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((zeroSt != zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt != one), "STAmount fail");
|
||||
unexpected(!(zeroSt != hundred), "STAmount fail");
|
||||
unexpected(!(one != zeroSt), "STAmount fail");
|
||||
unexpected((one != one), "STAmount fail");
|
||||
unexpected((one != one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(one != hundred), "STAmount fail");
|
||||
unexpected(!(hundred != zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred != one), "STAmount fail");
|
||||
unexpected((hundred != hundred), "STAmount fail");
|
||||
unexpected((hundred != hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(STAmount().getText() != "0", "STAmount fail");
|
||||
unexpected(STAmount(31).getText() != "31", "STAmount fail");
|
||||
unexpected(STAmount(310).getText() != "310", "STAmount fail");
|
||||
@@ -279,7 +284,11 @@ public:
|
||||
testCustomCurrency()
|
||||
{
|
||||
testcase("custom currency");
|
||||
STAmount zeroSt(noIssue()), one(noIssue(), 1), hundred(noIssue(), 100);
|
||||
|
||||
STAmount const zeroSt(noIssue());
|
||||
STAmount const one(noIssue(), 1);
|
||||
STAmount const hundred(noIssue(), 100);
|
||||
|
||||
unexpected(serializeAndDeserialize(zeroSt) != zeroSt, "STAmount fail");
|
||||
unexpected(serializeAndDeserialize(one) != one, "STAmount fail");
|
||||
unexpected(serializeAndDeserialize(hundred) != hundred, "STAmount fail");
|
||||
@@ -288,60 +297,60 @@ public:
|
||||
unexpected(zeroSt != beast::zero, "STAmount fail");
|
||||
unexpected(one == beast::zero, "STAmount fail");
|
||||
unexpected(hundred == beast::zero, "STAmount fail");
|
||||
unexpected((zeroSt < zeroSt), "STAmount fail");
|
||||
unexpected((zeroSt < zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt < one), "STAmount fail");
|
||||
unexpected(!(zeroSt < hundred), "STAmount fail");
|
||||
unexpected((one < zeroSt), "STAmount fail");
|
||||
unexpected((one < one), "STAmount fail");
|
||||
unexpected((one < one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(one < hundred), "STAmount fail");
|
||||
unexpected((hundred < zeroSt), "STAmount fail");
|
||||
unexpected((hundred < one), "STAmount fail");
|
||||
unexpected((hundred < hundred), "STAmount fail");
|
||||
unexpected((zeroSt > zeroSt), "STAmount fail");
|
||||
unexpected((hundred < hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((zeroSt > zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((zeroSt > one), "STAmount fail");
|
||||
unexpected((zeroSt > hundred), "STAmount fail");
|
||||
unexpected(!(one > zeroSt), "STAmount fail");
|
||||
unexpected((one > one), "STAmount fail");
|
||||
unexpected((one > one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((one > hundred), "STAmount fail");
|
||||
unexpected(!(hundred > zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred > one), "STAmount fail");
|
||||
unexpected((hundred > hundred), "STAmount fail");
|
||||
unexpected(!(zeroSt <= zeroSt), "STAmount fail");
|
||||
unexpected((hundred > hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt <= zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt <= one), "STAmount fail");
|
||||
unexpected(!(zeroSt <= hundred), "STAmount fail");
|
||||
unexpected((one <= zeroSt), "STAmount fail");
|
||||
unexpected(!(one <= one), "STAmount fail");
|
||||
unexpected(!(one <= one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(one <= hundred), "STAmount fail");
|
||||
unexpected((hundred <= zeroSt), "STAmount fail");
|
||||
unexpected((hundred <= one), "STAmount fail");
|
||||
unexpected(!(hundred <= hundred), "STAmount fail");
|
||||
unexpected(!(zeroSt >= zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred <= hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt >= zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((zeroSt >= one), "STAmount fail");
|
||||
unexpected((zeroSt >= hundred), "STAmount fail");
|
||||
unexpected(!(one >= zeroSt), "STAmount fail");
|
||||
unexpected(!(one >= one), "STAmount fail");
|
||||
unexpected(!(one >= one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((one >= hundred), "STAmount fail");
|
||||
unexpected(!(hundred >= zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred >= one), "STAmount fail");
|
||||
unexpected(!(hundred >= hundred), "STAmount fail");
|
||||
unexpected(!(zeroSt == zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred >= hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt == zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((zeroSt == one), "STAmount fail");
|
||||
unexpected((zeroSt == hundred), "STAmount fail");
|
||||
unexpected((one == zeroSt), "STAmount fail");
|
||||
unexpected(!(one == one), "STAmount fail");
|
||||
unexpected(!(one == one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((one == hundred), "STAmount fail");
|
||||
unexpected((hundred == zeroSt), "STAmount fail");
|
||||
unexpected((hundred == one), "STAmount fail");
|
||||
unexpected(!(hundred == hundred), "STAmount fail");
|
||||
unexpected((zeroSt != zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred == hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected((zeroSt != zeroSt), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(zeroSt != one), "STAmount fail");
|
||||
unexpected(!(zeroSt != hundred), "STAmount fail");
|
||||
unexpected(!(one != zeroSt), "STAmount fail");
|
||||
unexpected((one != one), "STAmount fail");
|
||||
unexpected((one != one), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(!(one != hundred), "STAmount fail");
|
||||
unexpected(!(hundred != zeroSt), "STAmount fail");
|
||||
unexpected(!(hundred != one), "STAmount fail");
|
||||
unexpected((hundred != hundred), "STAmount fail");
|
||||
unexpected((hundred != hundred), "STAmount fail"); // NOLINT(misc-redundant-expression)
|
||||
unexpected(STAmount(noIssue()).getText() != "0", "STAmount fail");
|
||||
unexpected(STAmount(noIssue(), 31).getText() != "31", "STAmount fail");
|
||||
unexpected(STAmount(noIssue(), 31, 1).getText() != "310", "STAmount fail");
|
||||
@@ -382,7 +391,8 @@ public:
|
||||
divide(STAmount(noIssue(), 60), STAmount(noIssue(), 3), xrpIssue()).getText() != "20",
|
||||
"STAmount divide fail");
|
||||
|
||||
STAmount a1(noIssue(), 60), a2(noIssue(), 10, -1);
|
||||
STAmount const a1(noIssue(), 60);
|
||||
STAmount const a2(noIssue(), 10, -1);
|
||||
|
||||
unexpected(
|
||||
divide(a2, a1, noIssue()) != amountFromQuality(getRate(a1, a2)),
|
||||
@@ -464,14 +474,14 @@ public:
|
||||
{
|
||||
testcase("underflow");
|
||||
|
||||
STAmount bigNative(STAmount::cMaxNative / 2);
|
||||
STAmount bigValue(
|
||||
STAmount const bigNative(STAmount::cMaxNative / 2);
|
||||
STAmount const bigValue(
|
||||
noIssue(), (STAmount::cMinValue + STAmount::cMaxValue) / 2, STAmount::cMaxOffset - 1);
|
||||
STAmount smallValue(
|
||||
STAmount const smallValue(
|
||||
noIssue(), (STAmount::cMinValue + STAmount::cMaxValue) / 2, STAmount::cMinOffset + 1);
|
||||
STAmount zeroSt(noIssue(), 0);
|
||||
STAmount const zeroSt(noIssue(), 0);
|
||||
|
||||
STAmount smallXSmall = multiply(smallValue, smallValue, noIssue());
|
||||
STAmount const smallXSmall = multiply(smallValue, smallValue, noIssue());
|
||||
|
||||
BEAST_EXPECT(smallXSmall == beast::zero);
|
||||
|
||||
@@ -822,43 +832,43 @@ public:
|
||||
|
||||
// Adding zero
|
||||
{
|
||||
STAmount amt1(XRPAmount(0));
|
||||
STAmount amt2(XRPAmount(1000));
|
||||
STAmount const amt1(XRPAmount(0));
|
||||
STAmount const amt2(XRPAmount(1000));
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Adding zero
|
||||
{
|
||||
STAmount amt1(XRPAmount(1000));
|
||||
STAmount amt2(XRPAmount(0));
|
||||
STAmount const amt1(XRPAmount(1000));
|
||||
STAmount const amt2(XRPAmount(0));
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Adding two positive XRP amounts
|
||||
{
|
||||
STAmount amt1(XRPAmount(500));
|
||||
STAmount amt2(XRPAmount(1500));
|
||||
STAmount const amt1(XRPAmount(500));
|
||||
STAmount const amt2(XRPAmount(1500));
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Adding two negative XRP amounts
|
||||
{
|
||||
STAmount amt1(XRPAmount(-500));
|
||||
STAmount amt2(XRPAmount(-1500));
|
||||
STAmount const amt1(XRPAmount(-500));
|
||||
STAmount const amt2(XRPAmount(-1500));
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Adding a positive and a negative XRP amount
|
||||
{
|
||||
STAmount amt1(XRPAmount(1000));
|
||||
STAmount amt2(XRPAmount(-1000));
|
||||
STAmount const amt1(XRPAmount(1000));
|
||||
STAmount const amt2(XRPAmount(-1000));
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Overflow check for max XRP amounts
|
||||
{
|
||||
STAmount amt1(std::numeric_limits<XRPAmount::value_type>::max());
|
||||
STAmount amt2(XRPAmount(1));
|
||||
STAmount const amt1(std::numeric_limits<XRPAmount::value_type>::max());
|
||||
STAmount const amt2(XRPAmount(1));
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
@@ -866,7 +876,7 @@ public:
|
||||
{
|
||||
STAmount amt1(std::numeric_limits<XRPAmount::value_type>::max());
|
||||
amt1 += XRPAmount(1);
|
||||
STAmount amt2(XRPAmount(-1));
|
||||
STAmount const amt2(XRPAmount(-1));
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == false);
|
||||
}
|
||||
}
|
||||
@@ -881,50 +891,50 @@ public:
|
||||
|
||||
// Adding two IOU amounts
|
||||
{
|
||||
STAmount amt1(usd, 500);
|
||||
STAmount amt2(usd, 1500);
|
||||
STAmount const amt1(usd, 500);
|
||||
STAmount const amt2(usd, 1500);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Adding a positive and a negative IOU amount
|
||||
{
|
||||
STAmount amt1(usd, 1000);
|
||||
STAmount amt2(usd, -1000);
|
||||
STAmount const amt1(usd, 1000);
|
||||
STAmount const amt2(usd, -1000);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Overflow check for max IOU amounts
|
||||
{
|
||||
STAmount amt1(usd, std::numeric_limits<int64_t>::max());
|
||||
STAmount amt2(usd, 1);
|
||||
STAmount const amt1(usd, std::numeric_limits<int64_t>::max());
|
||||
STAmount const amt2(usd, 1);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Overflow check for min IOU amounts
|
||||
{
|
||||
STAmount amt1(usd, std::numeric_limits<std::int64_t>::min());
|
||||
STAmount amt2(usd, -1);
|
||||
STAmount const amt1(usd, std::numeric_limits<std::int64_t>::min());
|
||||
STAmount const amt2(usd, -1);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Adding XRP and IOU
|
||||
{
|
||||
STAmount amt1(XRPAmount(1));
|
||||
STAmount amt2(usd, 1);
|
||||
STAmount const amt1(XRPAmount(1));
|
||||
STAmount const amt2(usd, 1);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Adding different IOU issues (non zero)
|
||||
{
|
||||
STAmount amt1(usd, 1000);
|
||||
STAmount amt2(eur, 500);
|
||||
STAmount const amt1(usd, 1000);
|
||||
STAmount const amt2(eur, 500);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Adding different IOU issues (zero)
|
||||
{
|
||||
STAmount amt1(usd, 0);
|
||||
STAmount amt2(eur, 500);
|
||||
STAmount const amt1(usd, 0);
|
||||
STAmount const amt2(eur, 500);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == false);
|
||||
}
|
||||
}
|
||||
@@ -939,43 +949,43 @@ public:
|
||||
|
||||
// Adding zero
|
||||
{
|
||||
STAmount amt1(mpt, 0);
|
||||
STAmount amt2(mpt, 1000);
|
||||
STAmount const amt1(mpt, 0);
|
||||
STAmount const amt2(mpt, 1000);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Adding zero
|
||||
{
|
||||
STAmount amt1(mpt, 1000);
|
||||
STAmount amt2(mpt, 0);
|
||||
STAmount const amt1(mpt, 1000);
|
||||
STAmount const amt2(mpt, 0);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Adding two positive MPT amounts
|
||||
{
|
||||
STAmount amt1(mpt, 500);
|
||||
STAmount amt2(mpt, 1500);
|
||||
STAmount const amt1(mpt, 500);
|
||||
STAmount const amt2(mpt, 1500);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Adding two negative MPT amounts
|
||||
{
|
||||
STAmount amt1(mpt, -500);
|
||||
STAmount amt2(mpt, -1500);
|
||||
STAmount const amt1(mpt, -500);
|
||||
STAmount const amt2(mpt, -1500);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Adding a positive and a negative MPT amount
|
||||
{
|
||||
STAmount amt1(mpt, 1000);
|
||||
STAmount amt2(mpt, -1000);
|
||||
STAmount const amt1(mpt, 1000);
|
||||
STAmount const amt2(mpt, -1000);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Overflow check for max MPT amounts
|
||||
{
|
||||
STAmount amt1(mpt, std::numeric_limits<MPTAmount::value_type>::max());
|
||||
STAmount amt2(mpt, 1);
|
||||
STAmount const amt1(mpt, std::numeric_limits<MPTAmount::value_type>::max());
|
||||
STAmount const amt2(mpt, 1);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
@@ -985,22 +995,22 @@ public:
|
||||
|
||||
// Adding MPT and XRP
|
||||
{
|
||||
STAmount amt1(XRPAmount(1000));
|
||||
STAmount amt2(mpt, 1000);
|
||||
STAmount const amt1(XRPAmount(1000));
|
||||
STAmount const amt2(mpt, 1000);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Adding different MPT issues (non zero)
|
||||
{
|
||||
STAmount amt1(mpt2, 500);
|
||||
STAmount amt2(mpt, 500);
|
||||
STAmount const amt1(mpt2, 500);
|
||||
STAmount const amt2(mpt, 500);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Adding different MPT issues (non zero)
|
||||
{
|
||||
STAmount amt1(mpt2, 0);
|
||||
STAmount amt2(mpt, 500);
|
||||
STAmount const amt1(mpt2, 0);
|
||||
STAmount const amt2(mpt, 500);
|
||||
BEAST_EXPECT(canAdd(amt1, amt2) == false);
|
||||
}
|
||||
}
|
||||
@@ -1012,36 +1022,36 @@ public:
|
||||
|
||||
// Subtracting zero
|
||||
{
|
||||
STAmount amt1(XRPAmount(1000));
|
||||
STAmount amt2(XRPAmount(0));
|
||||
STAmount const amt1(XRPAmount(1000));
|
||||
STAmount const amt2(XRPAmount(0));
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Subtracting zero
|
||||
{
|
||||
STAmount amt1(XRPAmount(0));
|
||||
STAmount amt2(XRPAmount(1000));
|
||||
STAmount const amt1(XRPAmount(0));
|
||||
STAmount const amt2(XRPAmount(1000));
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Subtracting two positive XRP amounts
|
||||
{
|
||||
STAmount amt1(XRPAmount(1500));
|
||||
STAmount amt2(XRPAmount(500));
|
||||
STAmount const amt1(XRPAmount(1500));
|
||||
STAmount const amt2(XRPAmount(500));
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Subtracting two negative XRP amounts
|
||||
{
|
||||
STAmount amt1(XRPAmount(-1500));
|
||||
STAmount amt2(XRPAmount(-500));
|
||||
STAmount const amt1(XRPAmount(-1500));
|
||||
STAmount const amt2(XRPAmount(-500));
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Subtracting a positive and a negative XRP amount
|
||||
{
|
||||
STAmount amt1(XRPAmount(1000));
|
||||
STAmount amt2(XRPAmount(-1000));
|
||||
STAmount const amt1(XRPAmount(1000));
|
||||
STAmount const amt2(XRPAmount(-1000));
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
@@ -1049,14 +1059,14 @@ public:
|
||||
{
|
||||
STAmount amt1(std::numeric_limits<XRPAmount::value_type>::max());
|
||||
amt1 += XRPAmount(1);
|
||||
STAmount amt2(XRPAmount(1));
|
||||
STAmount const amt2(XRPAmount(1));
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Overflow check for max XRP amounts
|
||||
{
|
||||
STAmount amt1(std::numeric_limits<XRPAmount::value_type>::max());
|
||||
STAmount amt2(XRPAmount(-1));
|
||||
STAmount const amt1(std::numeric_limits<XRPAmount::value_type>::max());
|
||||
STAmount const amt2(XRPAmount(-1));
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == false);
|
||||
}
|
||||
}
|
||||
@@ -1070,29 +1080,29 @@ public:
|
||||
|
||||
// Subtracting two IOU amounts
|
||||
{
|
||||
STAmount amt1(usd, 1500);
|
||||
STAmount amt2(usd, 500);
|
||||
STAmount const amt1(usd, 1500);
|
||||
STAmount const amt2(usd, 500);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Subtracting XRP and IOU
|
||||
{
|
||||
STAmount amt1(XRPAmount(1000));
|
||||
STAmount amt2(usd, 1000);
|
||||
STAmount const amt1(XRPAmount(1000));
|
||||
STAmount const amt2(usd, 1000);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Subtracting different IOU issues (non zero)
|
||||
{
|
||||
STAmount amt1(usd, 1000);
|
||||
STAmount amt2(eur, 500);
|
||||
STAmount const amt1(usd, 1000);
|
||||
STAmount const amt2(eur, 500);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Subtracting different IOU issues (zero)
|
||||
{
|
||||
STAmount amt1(usd, 0);
|
||||
STAmount amt2(eur, 500);
|
||||
STAmount const amt1(usd, 0);
|
||||
STAmount const amt2(eur, 500);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == false);
|
||||
}
|
||||
}
|
||||
@@ -1107,36 +1117,36 @@ public:
|
||||
|
||||
// Subtracting zero
|
||||
{
|
||||
STAmount amt1(mpt, 1000);
|
||||
STAmount amt2(mpt, 0);
|
||||
STAmount const amt1(mpt, 1000);
|
||||
STAmount const amt2(mpt, 0);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Subtracting zero
|
||||
{
|
||||
STAmount amt1(mpt, 0);
|
||||
STAmount amt2(mpt, 1000);
|
||||
STAmount const amt1(mpt, 0);
|
||||
STAmount const amt2(mpt, 1000);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Subtracting two positive MPT amounts
|
||||
{
|
||||
STAmount amt1(mpt, 1500);
|
||||
STAmount amt2(mpt, 500);
|
||||
STAmount const amt1(mpt, 1500);
|
||||
STAmount const amt2(mpt, 500);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Subtracting two negative MPT amounts
|
||||
{
|
||||
STAmount amt1(mpt, -1500);
|
||||
STAmount amt2(mpt, -500);
|
||||
STAmount const amt1(mpt, -1500);
|
||||
STAmount const amt2(mpt, -500);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
// Subtracting a positive and a negative MPT amount
|
||||
{
|
||||
STAmount amt1(mpt, 1000);
|
||||
STAmount amt2(mpt, -1000);
|
||||
STAmount const amt1(mpt, 1000);
|
||||
STAmount const amt2(mpt, -1000);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == true);
|
||||
}
|
||||
|
||||
@@ -1146,29 +1156,29 @@ public:
|
||||
|
||||
// Overflow check for max positive MPT amounts (should fail)
|
||||
{
|
||||
STAmount amt1(mpt, std::numeric_limits<MPTAmount::value_type>::max());
|
||||
STAmount amt2(mpt, -2);
|
||||
STAmount const amt1(mpt, std::numeric_limits<MPTAmount::value_type>::max());
|
||||
STAmount const amt2(mpt, -2);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Subtracting MPT and XRP
|
||||
{
|
||||
STAmount amt1(XRPAmount(1000));
|
||||
STAmount amt2(mpt, 1000);
|
||||
STAmount const amt1(XRPAmount(1000));
|
||||
STAmount const amt2(mpt, 1000);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Subtracting different MPT issues (non zero)
|
||||
{
|
||||
STAmount amt1(mpt, 1000);
|
||||
STAmount amt2(mpt2, 500);
|
||||
STAmount const amt1(mpt, 1000);
|
||||
STAmount const amt2(mpt2, 500);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == false);
|
||||
}
|
||||
|
||||
// Subtracting different MPT issues (zero)
|
||||
{
|
||||
STAmount amt1(mpt, 0);
|
||||
STAmount amt2(mpt2, 500);
|
||||
STAmount const amt1(mpt, 0);
|
||||
STAmount const amt2(mpt2, 500);
|
||||
BEAST_EXPECT(canSubtract(amt1, amt2) == false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user