mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
test: Add ParseMoney and ParseScript tests
This commit is contained in:
@@ -1239,6 +1239,11 @@ BOOST_AUTO_TEST_CASE(util_FormatMoney)
|
||||
BOOST_AUTO_TEST_CASE(util_ParseMoney)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(ParseMoney("0.0").value(), 0);
|
||||
BOOST_CHECK_EQUAL(ParseMoney(".").value(), 0);
|
||||
BOOST_CHECK_EQUAL(ParseMoney("0.").value(), 0);
|
||||
BOOST_CHECK_EQUAL(ParseMoney(".0").value(), 0);
|
||||
BOOST_CHECK_EQUAL(ParseMoney(".6789").value(), 6789'0000);
|
||||
BOOST_CHECK_EQUAL(ParseMoney("12345.").value(), COIN * 12345);
|
||||
|
||||
BOOST_CHECK_EQUAL(ParseMoney("12345.6789").value(), (COIN/10000)*123456789);
|
||||
|
||||
@@ -1276,11 +1281,18 @@ BOOST_AUTO_TEST_CASE(util_ParseMoney)
|
||||
BOOST_CHECK(!ParseMoney(" "));
|
||||
|
||||
// Parsing two numbers should fail
|
||||
BOOST_CHECK(!ParseMoney(".."));
|
||||
BOOST_CHECK(!ParseMoney("0..0"));
|
||||
BOOST_CHECK(!ParseMoney("1 2"));
|
||||
BOOST_CHECK(!ParseMoney(" 1 2 "));
|
||||
BOOST_CHECK(!ParseMoney(" 1.2 3 "));
|
||||
BOOST_CHECK(!ParseMoney(" 1 2.3 "));
|
||||
|
||||
// Embedded whitespace should fail
|
||||
BOOST_CHECK(!ParseMoney(" -1 .2 "));
|
||||
BOOST_CHECK(!ParseMoney(" 1 .2 "));
|
||||
BOOST_CHECK(!ParseMoney(" +1 .2 "));
|
||||
|
||||
// Attempted 63 bit overflow should fail
|
||||
BOOST_CHECK(!ParseMoney("92233720368.54775808"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user