mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
test: move uint256_tests/operator_with_self to arith_uint256_tests
move/formatting-only change. These tests do not cover uint256, so move them to the appropriate test suite. Additionally, apply clang-format suggestions.
This commit is contained in:
parent
c6c994cb2b
commit
43cd83b0c7
2 changed files with 30 additions and 33 deletions
|
@ -578,4 +578,34 @@ BOOST_AUTO_TEST_CASE(conversion)
|
|||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(operator_with_self)
|
||||
{
|
||||
/* Clang 16 and earlier detects v -= v and v /= v as self-assignments
|
||||
to 0 and 1 respectively.
|
||||
See: https://github.com/llvm/llvm-project/issues/42469
|
||||
and the fix in commit c5302325b2a62d77cf13dd16cd5c19141862fed0 .
|
||||
|
||||
This makes some sense for arithmetic classes, but could be considered a bug
|
||||
elsewhere. Disable the warning here so that the code can be tested, but the
|
||||
warning should remain on as there will likely always be a better way to
|
||||
express this.
|
||||
*/
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wself-assign-overloaded"
|
||||
#endif
|
||||
arith_uint256 v{2};
|
||||
v *= v;
|
||||
BOOST_CHECK_EQUAL(v, arith_uint256{4});
|
||||
v /= v;
|
||||
BOOST_CHECK_EQUAL(v, arith_uint256{1});
|
||||
v += v;
|
||||
BOOST_CHECK_EQUAL(v, arith_uint256{2});
|
||||
v -= v;
|
||||
BOOST_CHECK_EQUAL(v, arith_uint256{0});
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <arith_uint256.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <uint256.h>
|
||||
|
@ -245,38 +244,6 @@ BOOST_AUTO_TEST_CASE(methods) // GetHex SetHexDeprecated FromHex begin() end() s
|
|||
ss.clear();
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( operator_with_self )
|
||||
{
|
||||
|
||||
/* Clang 16 and earlier detects v -= v and v /= v as self-assignments
|
||||
to 0 and 1 respectively.
|
||||
See: https://github.com/llvm/llvm-project/issues/42469
|
||||
and the fix in commit c5302325b2a62d77cf13dd16cd5c19141862fed0 .
|
||||
|
||||
This makes some sense for arithmetic classes, but could be considered a bug
|
||||
elsewhere. Disable the warning here so that the code can be tested, but the
|
||||
warning should remain on as there will likely always be a better way to
|
||||
express this.
|
||||
*/
|
||||
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wself-assign-overloaded"
|
||||
#endif
|
||||
arith_uint256 v{2};
|
||||
v *= v;
|
||||
BOOST_CHECK_EQUAL(v, arith_uint256{4});
|
||||
v /= v;
|
||||
BOOST_CHECK_EQUAL(v, arith_uint256{1});
|
||||
v += v;
|
||||
BOOST_CHECK_EQUAL(v, arith_uint256{2});
|
||||
v -= v;
|
||||
BOOST_CHECK_EQUAL(v, arith_uint256{0});
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented as a templated function so it can be reused by other classes that have a FromHex()
|
||||
* method that wraps base_blob::FromHex(), such as transaction_identifier::FromHex().
|
||||
|
|
Loading…
Add table
Reference in a new issue