MCPcopy Create free account
hub / github.com/LUX-Core/lux / CheckSubtract

Function CheckSubtract

src/test/scriptnum_tests.cpp:79–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79static void CheckSubtract(const int64_t& num1, const int64_t& num2)
80{
81 const CBigNum bignum1(num1);
82 const CBigNum bignum2(num2);
83 const CScriptNum scriptnum1(num1);
84 const CScriptNum scriptnum2(num2);
85 bool invalid = false;
86
87 // int64_t overflow is undefined.
88 invalid = ((num2 > 0 && num1 < std::numeric_limits<int64_t>::min() + num2) ||
89 (num2 < 0 && num1 > std::numeric_limits<int64_t>::max() + num2));
90 if (!invalid)
91 {
92 BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - scriptnum2));
93 BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - num2));
94 }
95
96 invalid = ((num1 > 0 && num2 < std::numeric_limits<int64_t>::min() + num1) ||
97 (num1 < 0 && num2 > std::numeric_limits<int64_t>::max() + num1));
98 if (!invalid)
99 {
100 BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - scriptnum1));
101 BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - num1));
102 }
103}
104
105static void CheckCompare(const int64_t& num1, const int64_t& num2)
106{

Callers 1

RunOperatorsFunction · 0.85

Calls 2

maxFunction · 0.85
verifyFunction · 0.85

Tested by

no test coverage detected