mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-10 04:33:59 +01:00
Make DecodeBase{32,64} return optional instead of taking bool*
This commit is contained in:
@@ -19,10 +19,9 @@ BOOST_AUTO_TEST_CASE(base64_testvectors)
|
||||
{
|
||||
std::string strEnc = EncodeBase64(vstrIn[i]);
|
||||
BOOST_CHECK_EQUAL(strEnc, vstrOut[i]);
|
||||
bool invalid;
|
||||
auto dec = DecodeBase64(strEnc, &invalid);
|
||||
BOOST_CHECK(!invalid);
|
||||
BOOST_CHECK_MESSAGE(MakeByteSpan(dec) == MakeByteSpan(vstrIn[i]), vstrOut[i]);
|
||||
auto dec = DecodeBase64(strEnc);
|
||||
BOOST_REQUIRE(dec);
|
||||
BOOST_CHECK_MESSAGE(MakeByteSpan(*dec) == MakeByteSpan(vstrIn[i]), vstrOut[i]);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -36,15 +35,10 @@ BOOST_AUTO_TEST_CASE(base64_testvectors)
|
||||
}
|
||||
|
||||
// Decoding strings with embedded NUL characters should fail
|
||||
bool failure;
|
||||
(void)DecodeBase64("invalid\0"s, &failure);
|
||||
BOOST_CHECK(failure);
|
||||
(void)DecodeBase64("nQB/pZw="s, &failure);
|
||||
BOOST_CHECK(!failure);
|
||||
(void)DecodeBase64("nQB/pZw=\0invalid"s, &failure);
|
||||
BOOST_CHECK(failure);
|
||||
(void)DecodeBase64("nQB/pZw=invalid\0"s, &failure);
|
||||
BOOST_CHECK(failure);
|
||||
BOOST_CHECK(!DecodeBase64("invalid\0"s));
|
||||
BOOST_CHECK(DecodeBase64("nQB/pZw="s));
|
||||
BOOST_CHECK(!DecodeBase64("nQB/pZw=\0invalid"s));
|
||||
BOOST_CHECK(!DecodeBase64("nQB/pZw=invalid\0"s));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user