mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Format first-party source according to .clang-format
This commit is contained in:
committed by
manojsdoshi
parent
65dfc5d19e
commit
50760c6935
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/ledger/CashDiff.h>
|
||||
#include <ripple/protocol/STAmount.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace ripple {
|
||||
@@ -33,26 +33,26 @@ class CashDiff_test : public beast::unit_test::suite
|
||||
static_assert(std::is_nothrow_move_constructible<CashDiff>{}, "");
|
||||
static_assert(!std::is_move_assignable<CashDiff>{}, "");
|
||||
|
||||
// Exercise diffIsDust (STAmount, STAmount)
|
||||
// Exercise diffIsDust (STAmount, STAmount)
|
||||
void
|
||||
testDust ()
|
||||
testDust()
|
||||
{
|
||||
testcase ("diffIsDust (STAmount, STAmount)");
|
||||
testcase("diffIsDust (STAmount, STAmount)");
|
||||
|
||||
Issue const usd (Currency (0x5553440000000000), AccountID (0x4985601));
|
||||
Issue const usf (Currency (0x5553460000000000), AccountID (0x4985601));
|
||||
Issue const usd(Currency(0x5553440000000000), AccountID(0x4985601));
|
||||
Issue const usf(Currency(0x5553460000000000), AccountID(0x4985601));
|
||||
|
||||
// Positive and negative are never dust.
|
||||
expect (!diffIsDust (STAmount{usd, 1}, STAmount{usd, -1}));
|
||||
expect(!diffIsDust(STAmount{usd, 1}, STAmount{usd, -1}));
|
||||
|
||||
// Different issues are never dust.
|
||||
expect (!diffIsDust (STAmount{usd, 1}, STAmount{usf, 1}));
|
||||
expect(!diffIsDust(STAmount{usd, 1}, STAmount{usf, 1}));
|
||||
|
||||
// Native and non-native are never dust.
|
||||
expect (!diffIsDust (STAmount{usd, 1}, STAmount{1}));
|
||||
expect(!diffIsDust(STAmount{usd, 1}, STAmount{1}));
|
||||
|
||||
// Equal values are always dust.
|
||||
expect (diffIsDust (STAmount{0}, STAmount{0}));
|
||||
expect(diffIsDust(STAmount{0}, STAmount{0}));
|
||||
{
|
||||
// Test IOU.
|
||||
std::uint64_t oldProbe = 0;
|
||||
@@ -60,22 +60,22 @@ class CashDiff_test : public beast::unit_test::suite
|
||||
std::uint8_t e10 = 1;
|
||||
do
|
||||
{
|
||||
STAmount large (usd, newProbe + 1);
|
||||
STAmount small (usd, newProbe);
|
||||
STAmount large(usd, newProbe + 1);
|
||||
STAmount small(usd, newProbe);
|
||||
|
||||
expect (diffIsDust (large, small, e10));
|
||||
expect (diffIsDust (large, small, e10+1) == (e10 > 13));
|
||||
expect(diffIsDust(large, small, e10));
|
||||
expect(diffIsDust(large, small, e10 + 1) == (e10 > 13));
|
||||
|
||||
oldProbe = newProbe;
|
||||
newProbe = oldProbe * 10;
|
||||
e10 += 1;
|
||||
} while (newProbe > oldProbe &&
|
||||
newProbe < std::numeric_limits<std::int64_t>::max());
|
||||
newProbe < std::numeric_limits<std::int64_t>::max());
|
||||
}
|
||||
{
|
||||
// Test XRP.
|
||||
// A delta of 2 or less is always dust.
|
||||
expect (diffIsDust (STAmount{2}, STAmount{0}));
|
||||
expect(diffIsDust(STAmount{2}, STAmount{0}));
|
||||
|
||||
std::uint64_t oldProbe = 0;
|
||||
std::uint64_t newProbe = 10;
|
||||
@@ -84,28 +84,29 @@ class CashDiff_test : public beast::unit_test::suite
|
||||
{
|
||||
// Differences of 2 of fewer drops are always treated as dust,
|
||||
// so use a delta of 3.
|
||||
STAmount large (newProbe + 3);
|
||||
STAmount small (newProbe);
|
||||
STAmount large(newProbe + 3);
|
||||
STAmount small(newProbe);
|
||||
|
||||
expect (diffIsDust (large, small, e10));
|
||||
expect (diffIsDust (large, small, e10+1) == (e10 >= 20));
|
||||
expect(diffIsDust(large, small, e10));
|
||||
expect(diffIsDust(large, small, e10 + 1) == (e10 >= 20));
|
||||
|
||||
oldProbe = newProbe;
|
||||
newProbe = oldProbe * 10;
|
||||
e10 += 1;
|
||||
} while (newProbe > oldProbe &&
|
||||
newProbe < std::numeric_limits<std::int64_t>::max());
|
||||
newProbe < std::numeric_limits<std::int64_t>::max());
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
void run () override
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testDust();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE (CashDiff, ledger, ripple);
|
||||
BEAST_DEFINE_TESTSUITE(CashDiff, ledger, ripple);
|
||||
|
||||
} // test
|
||||
} // ripple
|
||||
} // namespace test
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user