mirror of
https://github.com/AskDavis/Casinotest.git
synced 2026-01-09 06:09:47 -08:00
Version 1.1.0.0 update
This commit is contained in:
@@ -12,8 +12,8 @@ BOOST_AUTO_TEST_SUITE(bignum_tests)
|
||||
// You should use it like this:
|
||||
// NOINLINE void function() {...}
|
||||
#if defined(__GNUC__)
|
||||
// This also works and will be defined for any compiler implementing gcc
|
||||
// extensions, such as clang and icc.
|
||||
// This also works and will be defined for any compiler implementing GCC
|
||||
// extensions, such as Clang and ICC.
|
||||
#define NOINLINE __attribute__((noinline))
|
||||
#elif defined(_MSC_VER)
|
||||
#define NOINLINE __declspec(noinline)
|
||||
@@ -48,7 +48,7 @@ BOOST_AUTO_TEST_SUITE(bignum_tests)
|
||||
// that -ftrapv will detect overflows.
|
||||
NOINLINE void mysetint64(CBigNum& num, int64 n)
|
||||
{
|
||||
num.setint64(n);
|
||||
num.setint64(n);
|
||||
}
|
||||
|
||||
// For each number, we do 2 tests: one with inline code, then we reset the
|
||||
@@ -122,4 +122,57 @@ BOOST_AUTO_TEST_CASE(bignum_setint64)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bignum_SetCompact)
|
||||
{
|
||||
CBigNum num;
|
||||
num.SetCompact(0);
|
||||
BOOST_CHECK_EQUAL(num.GetHex(), "0");
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
|
||||
|
||||
num.SetCompact(0x00123456);
|
||||
BOOST_CHECK_EQUAL(num.GetHex(), "0");
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
|
||||
|
||||
num.SetCompact(0x01123456);
|
||||
BOOST_CHECK_EQUAL(num.GetHex(), "12");
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0x01120000U);
|
||||
|
||||
// Make sure that we don't generate compacts with the 0x00800000 bit set
|
||||
num = 0x80;
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0x02008000U);
|
||||
|
||||
num.SetCompact(0x01fedcba);
|
||||
BOOST_CHECK_EQUAL(num.GetHex(), "-7e");
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0x01fe0000U);
|
||||
|
||||
num.SetCompact(0x02123456);
|
||||
BOOST_CHECK_EQUAL(num.GetHex(), "1234");
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0x02123400U);
|
||||
|
||||
num.SetCompact(0x03123456);
|
||||
BOOST_CHECK_EQUAL(num.GetHex(), "123456");
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0x03123456U);
|
||||
|
||||
num.SetCompact(0x04123456);
|
||||
BOOST_CHECK_EQUAL(num.GetHex(), "12345600");
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0x04123456U);
|
||||
|
||||
num.SetCompact(0x04923456);
|
||||
BOOST_CHECK_EQUAL(num.GetHex(), "-12345600");
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0x04923456U);
|
||||
|
||||
num.SetCompact(0x05009234);
|
||||
BOOST_CHECK_EQUAL(num.GetHex(), "92340000");
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0x05009234U);
|
||||
|
||||
num.SetCompact(0x20123456);
|
||||
BOOST_CHECK_EQUAL(num.GetHex(), "1234560000000000000000000000000000000000000000000000000000000000");
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0x20123456U);
|
||||
|
||||
num.SetCompact(0xff123456);
|
||||
BOOST_CHECK_EQUAL(num.GetHex(), "123456000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
|
||||
BOOST_CHECK_EQUAL(num.GetCompact(), 0xff123456U);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user