aboutsummaryrefslogtreecommitdiff
path: root/src/test/base32_tests.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2022-04-04 13:52:06 -0400
committerMacroFake <falke.marco@gmail.com>2022-04-27 14:12:55 +0200
commit78f3ac51b7d073d12da6a3b9b7d80d91e04ce3a7 (patch)
tree60a138e61a7281fbba6391da8d0d73bd0c1f9fee /src/test/base32_tests.cpp
parenta65931e3ce66d87b8f83d67ecdbb46f137e6a670 (diff)
Make DecodeBase{32,64} return optional instead of taking bool*
Diffstat (limited to 'src/test/base32_tests.cpp')
-rw-r--r--src/test/base32_tests.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/test/base32_tests.cpp b/src/test/base32_tests.cpp
index 2e5f6a2378..c6109dfeb0 100644
--- a/src/test/base32_tests.cpp
+++ b/src/test/base32_tests.cpp
@@ -22,22 +22,16 @@ BOOST_AUTO_TEST_CASE(base32_testvectors)
BOOST_CHECK_EQUAL(strEnc, vstrOut[i]);
strEnc = EncodeBase32(vstrIn[i], false);
BOOST_CHECK_EQUAL(strEnc, vstrOutNoPadding[i]);
- bool invalid;
- auto dec = DecodeBase32(vstrOut[i], &invalid);
- BOOST_CHECK(!invalid);
- BOOST_CHECK_MESSAGE(MakeByteSpan(dec) == MakeByteSpan(vstrIn[i]), vstrOut[i]);
+ auto dec = DecodeBase32(vstrOut[i]);
+ BOOST_REQUIRE(dec);
+ BOOST_CHECK_MESSAGE(MakeByteSpan(*dec) == MakeByteSpan(vstrIn[i]), vstrOut[i]);
}
// Decoding strings with embedded NUL characters should fail
- bool failure;
- (void)DecodeBase32("invalid\0"s, &failure); // correct size, invalid due to \0
- BOOST_CHECK(failure);
- (void)DecodeBase32("AWSX3VPP"s, &failure); // valid
- BOOST_CHECK(!failure);
- (void)DecodeBase32("AWSX3VPP\0invalid"s, &failure); // correct size, invalid due to \0
- BOOST_CHECK(failure);
- (void)DecodeBase32("AWSX3VPPinvalid"s, &failure); // invalid size
- BOOST_CHECK(failure);
+ 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_AUTO_TEST_SUITE_END()