Skip to content

Commit 1757452

Browse files
committed
test: Add tests for CFeeRate multiplication operator
1 parent 1553c80 commit 1757452

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test/amount_tests.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,30 @@ BOOST_AUTO_TEST_CASE(GetFeeTest)
8787
CFeeRate(MAX_MONEY, std::numeric_limits<uint32_t>::max()).GetFeePerK();
8888

8989
// check multiplication operator
90+
// check multiplying by zero
9091
feeRate = CFeeRate(1000);
9192
BOOST_CHECK(0 * feeRate == CFeeRate(0));
93+
BOOST_CHECK(feeRate * 0 == CFeeRate(0));
94+
// check multiplying by a positive integer
9295
BOOST_CHECK(3 * feeRate == CFeeRate(3000));
96+
BOOST_CHECK(feeRate * 3 == CFeeRate(3000));
97+
// check multiplying by a negative integer
9398
BOOST_CHECK(-3 * feeRate == CFeeRate(-3000));
99+
BOOST_CHECK(feeRate * -3 == CFeeRate(-3000));
100+
// check commutativity
101+
BOOST_CHECK(2 * feeRate == feeRate * 2);
102+
// check with large numbers
103+
int largeNumber = 1000000;
104+
BOOST_CHECK(largeNumber * feeRate == feeRate * largeNumber);
105+
// check boundary values
106+
int maxInt = std::numeric_limits<int>::max();
107+
feeRate = CFeeRate(maxInt);
108+
BOOST_CHECK(feeRate * 2 == CFeeRate(static_cast<int64_t>(maxInt) * 2));
109+
BOOST_CHECK(2 * feeRate == CFeeRate(static_cast<int64_t>(maxInt) * 2));
110+
// check with zero fee rate
111+
feeRate = CFeeRate(0);
112+
BOOST_CHECK(feeRate * 5 == CFeeRate(0));
113+
BOOST_CHECK(5 * feeRate == CFeeRate(0));
94114
}
95115

96116
BOOST_AUTO_TEST_CASE(BinaryOperatorTest)

0 commit comments

Comments
 (0)