mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-13 22:24:05 +01:00
tests: Add tests for decoding/parsing of base32, base64 and money strings containing NUL characters
This commit is contained in:
@@ -20,6 +20,17 @@ BOOST_AUTO_TEST_CASE(base64_testvectors)
|
||||
std::string strDec = DecodeBase64(strEnc);
|
||||
BOOST_CHECK_EQUAL(strDec, vstrIn[i]);
|
||||
}
|
||||
|
||||
// Decoding strings with embedded NUL characters should fail
|
||||
bool failure;
|
||||
(void)DecodeBase64(std::string("invalid", 7), &failure);
|
||||
BOOST_CHECK_EQUAL(failure, true);
|
||||
(void)DecodeBase64(std::string("nQB/pZw=", 8), &failure);
|
||||
BOOST_CHECK_EQUAL(failure, false);
|
||||
(void)DecodeBase64(std::string("nQB/pZw=\0invalid", 16), &failure);
|
||||
BOOST_CHECK_EQUAL(failure, true);
|
||||
(void)DecodeBase64(std::string("nQB/pZw=invalid", 15), &failure);
|
||||
BOOST_CHECK_EQUAL(failure, true);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user