mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Unit test framework.
This commit is contained in:
@@ -326,3 +326,66 @@ STAmount convertToInternalAmount(const STAmount& displayAmount, const STAmount&
|
|||||||
{ // Convert a display/request currency amount to an internal amount
|
{ // Convert a display/request currency amount to an internal amount
|
||||||
return (displayAmount * totalNow) / totalInit;
|
return (displayAmount * totalNow) / totalInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void STAmount::unitTest()
|
||||||
|
{
|
||||||
|
STAmount zero, one(1), hundred(100);
|
||||||
|
|
||||||
|
if (!zero.isZero()) throw std::runtime_error("STAmount fail");
|
||||||
|
if (one.isZero()) throw std::runtime_error("STAmount fail");
|
||||||
|
if (hundred.isZero()) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((zero < zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(zero < one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(zero < hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((one < zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((one < one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(one < hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((hundred < zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((hundred < one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((hundred < hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((zero > zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((zero > one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((zero > hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(one > zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((one > one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((one > hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(hundred > zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(hundred > one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((hundred > hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(zero <= zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(zero <= one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(zero <= hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((one <= zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(one <= one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(one <= hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((hundred <= zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((hundred <= one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(hundred <= hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(zero >= zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((zero >= one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((zero >= hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(one >= zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(one >= one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((one >= hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(hundred >= zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(hundred >= one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(hundred >= hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(zero == zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((zero == one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((zero == hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((one == zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(one == one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((one == hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((hundred == zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((hundred == one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(hundred == hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((zero != zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(zero != one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(zero != hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(one != zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((one != one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(one != hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(hundred != zero)) throw std::runtime_error("STAmount fail");
|
||||||
|
if (!(hundred != one)) throw std::runtime_error("STAmount fail");
|
||||||
|
if ((hundred != hundred)) throw std::runtime_error("STAmount fail");
|
||||||
|
}
|
||||||
|
|||||||
@@ -237,6 +237,8 @@ public:
|
|||||||
const STAmount& totalNow, const STAmount& totalInit);
|
const STAmount& totalNow, const STAmount& totalInit);
|
||||||
friend STAmount convertToInternalAmount(const STAmount& displayAmount,
|
friend STAmount convertToInternalAmount(const STAmount& displayAmount,
|
||||||
const STAmount& totalNow, const STAmount& totalInit);
|
const STAmount& totalNow, const STAmount& totalInit);
|
||||||
|
|
||||||
|
static void unitTest();
|
||||||
};
|
};
|
||||||
|
|
||||||
class STHash128 : public SerializedType
|
class STHash128 : public SerializedType
|
||||||
|
|||||||
Reference in New Issue
Block a user