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

Function CheckAdd

src/test/scriptnum_tests.cpp:47–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45
46
47static void CheckAdd(const int64_t& num1, const int64_t& num2)
48{
49 const CBigNum bignum1(num1);
50 const CBigNum bignum2(num2);
51 const CScriptNum scriptnum1(num1);
52 const CScriptNum scriptnum2(num2);
53 CBigNum bignum3(num1);
54 CBigNum bignum4(num1);
55 CScriptNum scriptnum3(num1);
56 CScriptNum scriptnum4(num1);
57
58 // int64_t overflow is undefined.
59 bool invalid = (((num2 > 0) && (num1 > (std::numeric_limits<int64_t>::max() - num2))) ||
60 ((num2 < 0) && (num1 < (std::numeric_limits<int64_t>::min() - num2))));
61 if (!invalid)
62 {
63 BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + scriptnum2));
64 BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + num2));
65 BOOST_CHECK(verify(bignum1 + bignum2, scriptnum2 + num1));
66 }
67}
68
69static void CheckNegate(const int64_t& num)
70{

Callers 1

RunOperatorsFunction · 0.85

Calls 2

maxFunction · 0.85
verifyFunction · 0.85

Tested by

no test coverage detected