aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl-Johan Alm <karljohan-alm@garage.co.jp>2018-02-26 15:34:11 +0900
committerKarl-Johan Alm <karljohan-alm@garage.co.jp>2018-03-01 11:49:36 +0900
commitb120f7bdbee83c00e46a9ec6d0cd09a816631f45 (patch)
treea4f83eb535a97b72326e12d4cca07c5abd314b19
parent08b17def58d4135c1dc904a6068670c3c92a3768 (diff)
[test] Add tests for self usage in arith_uint256
-rw-r--r--src/test/uint256_tests.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp
index ad5478e829..20ed29f59b 100644
--- a/src/test/uint256_tests.cpp
+++ b/src/test/uint256_tests.cpp
@@ -266,4 +266,17 @@ BOOST_AUTO_TEST_CASE( conversion )
BOOST_CHECK(R2L.GetHex() == UintToArith256(R2L).GetHex());
}
+BOOST_AUTO_TEST_CASE( operator_with_self )
+{
+ arith_uint256 v = UintToArith256(uint256S("02"));
+ v *= v;
+ BOOST_CHECK(v == UintToArith256(uint256S("04")));
+ v /= v;
+ BOOST_CHECK(v == UintToArith256(uint256S("01")));
+ v += v;
+ BOOST_CHECK(v == UintToArith256(uint256S("02")));
+ v -= v;
+ BOOST_CHECK(v == UintToArith256(uint256S("0")));
+}
+
BOOST_AUTO_TEST_SUITE_END()