diff options
author | Pieter Wuille <pieter@wuille.net> | 2022-04-04 13:52:06 -0400 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-04-27 14:12:55 +0200 |
commit | 78f3ac51b7d073d12da6a3b9b7d80d91e04ce3a7 (patch) | |
tree | 60a138e61a7281fbba6391da8d0d73bd0c1f9fee /src/test/base64_tests.cpp | |
parent | a65931e3ce66d87b8f83d67ecdbb46f137e6a670 (diff) | |
download | bitcoin-78f3ac51b7d073d12da6a3b9b7d80d91e04ce3a7.tar.xz |
Make DecodeBase{32,64} return optional instead of taking bool*
Diffstat (limited to 'src/test/base64_tests.cpp')
-rw-r--r-- | src/test/base64_tests.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/test/base64_tests.cpp b/src/test/base64_tests.cpp index 5727b09838..54a02c6bf8 100644 --- a/src/test/base64_tests.cpp +++ b/src/test/base64_tests.cpp @@ -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() |