Skip to content

Commit b120f7b

Browse files
committed
[test] Add tests for self usage in arith_uint256
1 parent 08b17de commit b120f7b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/test/uint256_tests.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,17 @@ BOOST_AUTO_TEST_CASE( conversion )
266266
BOOST_CHECK(R2L.GetHex() == UintToArith256(R2L).GetHex());
267267
}
268268

269+
BOOST_AUTO_TEST_CASE( operator_with_self )
270+
{
271+
arith_uint256 v = UintToArith256(uint256S("02"));
272+
v *= v;
273+
BOOST_CHECK(v == UintToArith256(uint256S("04")));
274+
v /= v;
275+
BOOST_CHECK(v == UintToArith256(uint256S("01")));
276+
v += v;
277+
BOOST_CHECK(v == UintToArith256(uint256S("02")));
278+
v -= v;
279+
BOOST_CHECK(v == UintToArith256(uint256S("0")));
280+
}
281+
269282
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)