mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
test: Add padding tests for Base32/Base64
This commit is contained in:
@@ -29,11 +29,28 @@ BOOST_AUTO_TEST_CASE(base32_testvectors)
|
||||
BOOST_CHECK_MESSAGE(std::ranges::equal(*dec, vstrIn[i]), vstrOut[i]);
|
||||
}
|
||||
|
||||
BOOST_CHECK(!DecodeBase32("AWSX3VPPinvalid")); // invalid size
|
||||
BOOST_CHECK( DecodeBase32("AWSX3VPP")); // valid
|
||||
|
||||
// Decoding strings with embedded NUL characters should fail
|
||||
BOOST_CHECK(!DecodeBase32("invalid\0"s)); // correct size, invalid due to \0
|
||||
BOOST_CHECK(DecodeBase32("AWSX3VPP"s)); // valid
|
||||
BOOST_CHECK(!DecodeBase32("AWSX3VPP\0invalid"s)); // correct size, invalid due to \0
|
||||
BOOST_CHECK(!DecodeBase32("AWSX3VPPinvalid"s)); // invalid size
|
||||
BOOST_CHECK(!DecodeBase32("invalid\0"sv)); // correct size, invalid due to \0
|
||||
BOOST_CHECK(!DecodeBase32("AWSX3VPP\0invalid"sv)); // correct size, invalid due to \0
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(base32_padding)
|
||||
{
|
||||
// Is valid without padding
|
||||
BOOST_CHECK_EQUAL(EncodeBase32("fooba"), "mzxw6ytb");
|
||||
|
||||
// Valid size
|
||||
BOOST_CHECK(!DecodeBase32("========"));
|
||||
BOOST_CHECK(!DecodeBase32("a======="));
|
||||
BOOST_CHECK( DecodeBase32("aa======"));
|
||||
BOOST_CHECK(!DecodeBase32("aaa====="));
|
||||
BOOST_CHECK( DecodeBase32("aaaa===="));
|
||||
BOOST_CHECK( DecodeBase32("aaaaa==="));
|
||||
BOOST_CHECK(!DecodeBase32("aaaaaa=="));
|
||||
BOOST_CHECK( DecodeBase32("aaaaaaa="));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user