9#include <boost/test/unit_test.hpp>
17static const int64_t
values[] = { 0, 1, -2, 127, 128, -255, 256, (1LL << 15) - 1, -(1LL << 16), (1LL << 24) - 1, (1LL << 31), 1 - (1LL << 32), 1LL << 40 };
19static const int64_t
offsets[] = { 1, 0x79, 0x80, 0x81, 0xFF, 0x7FFF, 0x8000, 0xFFFF, 0x10000};
52static void CheckAdd(
const int64_t& num1,
const int64_t& num2)
64 bool invalid = (((num2 > 0) && (num1 > (std::numeric_limits<int64_t>::max() - num2))) ||
65 ((num2 < 0) && (num1 < (std::numeric_limits<int64_t>::min() - num2))));
80 if (num != std::numeric_limits<int64_t>::min())
92 bool invalid = ((num2 > 0 && num1 < std::numeric_limits<int64_t>::min() + num2) ||
93 (num2 < 0 && num1 > std::numeric_limits<int64_t>::max() + num2));
100 invalid = ((num1 > 0 && num2 < std::numeric_limits<int64_t>::min() + num1) ||
101 (num1 < 0 && num2 > std::numeric_limits<int64_t>::max() + num1));
116 BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == scriptnum1));
117 BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != scriptnum1));
118 BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < scriptnum1));
119 BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > scriptnum1));
120 BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= scriptnum1));
121 BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= scriptnum1));
123 BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == num1));
124 BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != num1));
125 BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < num1));
126 BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > num1));
127 BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= num1));
128 BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= num1));
130 BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == scriptnum2));
131 BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != scriptnum2));
132 BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < scriptnum2));
133 BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > scriptnum2));
134 BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= scriptnum2));
135 BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= scriptnum2));
137 BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == num2));
138 BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != num2));
139 BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < num2));
140 BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > num2));
141 BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= num2));
142 BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= num2));
167 for(
size_t i = 0; i < std::size(
values); ++i)
169 for(
size_t j = 0; j < std::size(
offsets); ++j)
180 for(
size_t i = 0; i < std::size(
values); ++i)
182 for(
size_t j = 0; j < std::size(
offsets); ++j)
std::vector< unsigned char > getvch() const
std::vector< unsigned char > getvch() const
static const size_t nDefaultMaxNumSize
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
#define BOOST_CHECK_THROW(stmt, excMatch)
#define BOOST_CHECK(expr)
static void CheckAdd(const int64_t &num1, const int64_t &num2)
static void RunOperators(const int64_t &num1, const int64_t &num2)
static const int64_t offsets[]
static void CheckCompare(const int64_t &num1, const int64_t &num2)
static void CheckCreateVch(const int64_t &num)
static void CheckSubtract(const int64_t &num1, const int64_t &num2)
static void RunCreate(const int64_t &num)
static void CheckCreateInt(const int64_t &num)
static void CheckNegate(const int64_t &num)
static bool verify(const CScriptNum10 &bignum, const CScriptNum &scriptnum)
static const int64_t values[]
A selection of numbers that do not trigger int64_t overflow when added/subtracted.
BOOST_AUTO_TEST_CASE(creation)