diff options
| author | Karl-Johan Alm <[email protected]> | 2018-02-26 15:34:11 +0900 |
|---|---|---|
| committer | Karl-Johan Alm <[email protected]> | 2018-03-01 11:49:36 +0900 |
| commit | b120f7bdbee83c00e46a9ec6d0cd09a816631f45 (patch) | |
| tree | a4f83eb535a97b72326e12d4cca07c5abd314b19 /src/test/uint256_tests.cpp | |
| parent | [arith_uint256] Do not destroy *this content if passed-in operator may refere... (diff) | |
| download | discoin-b120f7bdbee83c00e46a9ec6d0cd09a816631f45.tar.xz discoin-b120f7bdbee83c00e46a9ec6d0cd09a816631f45.zip | |
[test] Add tests for self usage in arith_uint256
Diffstat (limited to 'src/test/uint256_tests.cpp')
| -rw-r--r-- | src/test/uint256_tests.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp index ad5478e82..20ed29f59 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() |