mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
test: Add uint256 string parse tests
This commit is contained in:
parent
facf629ce8
commit
fa63f16018
1 changed files with 28 additions and 0 deletions
|
@ -279,6 +279,34 @@ BOOST_AUTO_TEST_CASE( operator_with_self )
|
|||
BOOST_CHECK(v == UintToArith256(uint256S("0")));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(parse)
|
||||
{
|
||||
{
|
||||
std::string s_12{"0000000000000000000000000000000000000000000000000000000000000012"};
|
||||
BOOST_CHECK_EQUAL(uint256S("12\0").GetHex(), s_12);
|
||||
BOOST_CHECK_EQUAL(uint256S(std::string{"12\0", 3}).GetHex(), s_12);
|
||||
BOOST_CHECK_EQUAL(uint256S("0x12").GetHex(), s_12);
|
||||
BOOST_CHECK_EQUAL(uint256S(" 0x12").GetHex(), s_12);
|
||||
BOOST_CHECK_EQUAL(uint256S(" 12").GetHex(), s_12);
|
||||
}
|
||||
{
|
||||
std::string s_1{uint256::ONE.GetHex()};
|
||||
BOOST_CHECK_EQUAL(uint256S("1\0").GetHex(), s_1);
|
||||
BOOST_CHECK_EQUAL(uint256S(std::string{"1\0", 2}).GetHex(), s_1);
|
||||
BOOST_CHECK_EQUAL(uint256S("0x1").GetHex(), s_1);
|
||||
BOOST_CHECK_EQUAL(uint256S(" 0x1").GetHex(), s_1);
|
||||
BOOST_CHECK_EQUAL(uint256S(" 1").GetHex(), s_1);
|
||||
}
|
||||
{
|
||||
std::string s_0{uint256::ZERO.GetHex()};
|
||||
BOOST_CHECK_EQUAL(uint256S("\0").GetHex(), s_0);
|
||||
BOOST_CHECK_EQUAL(uint256S(std::string{"\0", 1}).GetHex(), s_0);
|
||||
BOOST_CHECK_EQUAL(uint256S("0x").GetHex(), s_0);
|
||||
BOOST_CHECK_EQUAL(uint256S(" 0x").GetHex(), s_0);
|
||||
BOOST_CHECK_EQUAL(uint256S(" ").GetHex(), s_0);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( check_ONE )
|
||||
{
|
||||
uint256 one = uint256S("0000000000000000000000000000000000000000000000000000000000000001");
|
||||
|
|
Loading…
Add table
Reference in a new issue