Changeset View
Changeset View
Standalone View
Standalone View
src/test/scriptnum_tests.cpp
| Show All 29 Lines | static const int64_t values[] = {0, | ||||
| 1LL << 40}; | 1LL << 40}; | ||||
| static const int64_t offsets[] = {1, 0x79, 0x80, 0x81, 0xFF, | static const int64_t offsets[] = {1, 0x79, 0x80, 0x81, 0xFF, | ||||
| 0x7FFF, 0x8000, 0xFFFF, 0x10000}; | 0x7FFF, 0x8000, 0xFFFF, 0x10000}; | ||||
| static void CheckCreateVch(const int64_t &num) { | static void CheckCreateVch(const int64_t &num) { | ||||
| CScriptNum scriptnum(num); | CScriptNum scriptnum(num); | ||||
| CScriptNum scriptnum2(scriptnum.getvch(), false, | CScriptNum scriptnum2(scriptnum.getvch(), false, | ||||
| CScriptNum::MAXIMUM_ELEMENT_SIZE); | CScriptNum::MAXIMUM_ELEMENT_SIZE_32_BIT); | ||||
| CScriptNum scriptnum3(scriptnum2.getvch(), false, | CScriptNum scriptnum3(scriptnum2.getvch(), false, | ||||
| CScriptNum::MAXIMUM_ELEMENT_SIZE); | CScriptNum::MAXIMUM_ELEMENT_SIZE_64_BIT); | ||||
| } | } | ||||
| static void CheckAdd(const int64_t &num1, const int64_t &num2) { | static void CheckAdd(const int64_t &num1, const int64_t &num2) { | ||||
| const CScriptNum scriptnum1(num1); | const CScriptNum scriptnum1(num1); | ||||
| const CScriptNum scriptnum2(num2); | const CScriptNum scriptnum2(num2); | ||||
| CScriptNum scriptnum3(num1); | CScriptNum scriptnum3(num1); | ||||
| // int64_t overflow is undefined. | // int64_t overflow is undefined. | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | static void CheckCompare(const int64_t &num1, const int64_t &num2) { | ||||
| BOOST_CHECK((num1 < num2) == (scriptnum1 < num2)); | BOOST_CHECK((num1 < num2) == (scriptnum1 < num2)); | ||||
| BOOST_CHECK((num1 > num2) == (scriptnum1 > num2)); | BOOST_CHECK((num1 > num2) == (scriptnum1 > num2)); | ||||
| BOOST_CHECK((num1 >= num2) == (scriptnum1 >= num2)); | BOOST_CHECK((num1 >= num2) == (scriptnum1 >= num2)); | ||||
| BOOST_CHECK((num1 <= num2) == (scriptnum1 <= num2)); | BOOST_CHECK((num1 <= num2) == (scriptnum1 <= num2)); | ||||
| } | } | ||||
| static void RunCreate(const int64_t &num) { | static void RunCreate(const int64_t &num) { | ||||
| CScriptNum scriptnum(num); | CScriptNum scriptnum(num); | ||||
| if (scriptnum.getvch().size() <= CScriptNum::MAXIMUM_ELEMENT_SIZE) { | if (scriptnum.getvch().size() <= CScriptNum::MAXIMUM_ELEMENT_SIZE_32_BIT) { | ||||
| CheckCreateVch(num); | CheckCreateVch(num); | ||||
| } else { | } else { | ||||
| BOOST_CHECK_THROW(CheckCreateVch(num), scriptnum_error); | BOOST_CHECK_THROW(CheckCreateVch(num), scriptnum_error); | ||||
| } | } | ||||
| } | } | ||||
| static void RunOperators(const int64_t &num1, const int64_t &num2) { | static void RunOperators(const int64_t &num1, const int64_t &num2) { | ||||
| CheckAdd(num1, num2); | CheckAdd(num1, num2); | ||||
| ▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines | |||||