Changeset View
Changeset View
Standalone View
Standalone View
src/test/intmath_tests.cpp
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | const i128_t b = b_64; | ||||
had_overflow_emulated, result_emulated, a + b); | had_overflow_emulated, result_emulated, a + b); | ||||
if (!expect_overflow) { | if (!expect_overflow) { | ||||
BOOST_CHECK_EQUAL(result, result_emulated); | BOOST_CHECK_EQUAL(result, result_emulated); | ||||
} | } | ||||
BOOST_CHECK_EQUAL(had_overflow, had_overflow_emulated); | BOOST_CHECK_EQUAL(had_overflow, had_overflow_emulated); | ||||
} | } | ||||
{ | { | ||||
bool expect_overflow = !IsInScriptBounds(a - b); | bool expect_overflow = !IsInScriptBounds(a - b); | ||||
// Test AddInt63OverflowEmulated | // Test SubInt63OverflowEmulated | ||||
int64_t result_emulated; | int64_t result_emulated; | ||||
bool had_overflow_emulated = | bool had_overflow_emulated = | ||||
SubInt63OverflowEmulated(a_64, b_64, result_emulated); | SubInt63OverflowEmulated(a_64, b_64, result_emulated); | ||||
CheckArithmeticResult(strprintf("%d - %d", a, b), expect_overflow, | CheckArithmeticResult(strprintf("%d - %d", a, b), expect_overflow, | ||||
had_overflow_emulated, result_emulated, a - b); | had_overflow_emulated, result_emulated, a - b); | ||||
// Test AddInt63Overflow | // Test SubInt63Overflow | ||||
int64_t result; | int64_t result; | ||||
bool had_overflow = SubInt63Overflow(a_64, b_64, result); | bool had_overflow = SubInt63Overflow(a_64, b_64, result); | ||||
CheckArithmeticResult(strprintf("%d - %d", a, b), expect_overflow, | CheckArithmeticResult(strprintf("%d - %d", a, b), expect_overflow, | ||||
had_overflow_emulated, result_emulated, a - b); | had_overflow_emulated, result_emulated, a - b); | ||||
if (!expect_overflow) { | if (!expect_overflow) { | ||||
BOOST_CHECK_EQUAL(result, result_emulated); | BOOST_CHECK_EQUAL(result, result_emulated); | ||||
} | } | ||||
BOOST_CHECK_EQUAL(had_overflow, had_overflow_emulated); | BOOST_CHECK_EQUAL(had_overflow, had_overflow_emulated); | ||||
Show All 36 Lines |