test: Add tests for CFeeRate multiplication operator

This commit is contained in:
Kashif Smith 2023-12-11 16:27:58 -05:00
parent 1553c80786
commit 1757452cc5

View File

@ -87,10 +87,30 @@ BOOST_AUTO_TEST_CASE(GetFeeTest)
CFeeRate(MAX_MONEY, std::numeric_limits<uint32_t>::max()).GetFeePerK();
// check multiplication operator
// check multiplying by zero
feeRate = CFeeRate(1000);
BOOST_CHECK(0 * feeRate == CFeeRate(0));
BOOST_CHECK(feeRate * 0 == CFeeRate(0));
// check multiplying by a positive integer
BOOST_CHECK(3 * feeRate == CFeeRate(3000));
BOOST_CHECK(feeRate * 3 == CFeeRate(3000));
// check multiplying by a negative integer
BOOST_CHECK(-3 * feeRate == CFeeRate(-3000));
BOOST_CHECK(feeRate * -3 == CFeeRate(-3000));
// check commutativity
BOOST_CHECK(2 * feeRate == feeRate * 2);
// check with large numbers
int largeNumber = 1000000;
BOOST_CHECK(largeNumber * feeRate == feeRate * largeNumber);
// check boundary values
int maxInt = std::numeric_limits<int>::max();
feeRate = CFeeRate(maxInt);
BOOST_CHECK(feeRate * 2 == CFeeRate(static_cast<int64_t>(maxInt) * 2));
BOOST_CHECK(2 * feeRate == CFeeRate(static_cast<int64_t>(maxInt) * 2));
// check with zero fee rate
feeRate = CFeeRate(0);
BOOST_CHECK(feeRate * 5 == CFeeRate(0));
BOOST_CHECK(5 * feeRate == CFeeRate(0));
}
BOOST_AUTO_TEST_CASE(BinaryOperatorTest)