test: Add more test cases for Base58 parser (#5174)

---------
Co-authored-by: John Freeman <jfreeman08@gmail.com>
This commit is contained in:
Ed Hennis
2024-12-03 16:13:31 -05:00
committed by GitHub
parent 8215c605b4
commit 47b0543461
2 changed files with 12 additions and 3 deletions

View File

@@ -177,7 +177,8 @@ inplace_bigint_div_rem(std::span<uint64_t> numerator, std::uint64_t divisor)
[[nodiscard]] inline std::array<std::uint8_t, 10>
b58_10_to_b58_be(std::uint64_t input)
{
constexpr std::uint64_t B_58_10 = 430804206899405824; // 58^10;
[[maybe_unused]] static constexpr std::uint64_t B_58_10 =
430804206899405824; // 58^10;
ASSERT(
input < B_58_10,
"ripple::b58_fast::detail::b58_10_to_b58_be : valid input");

View File

@@ -28,8 +28,16 @@ struct types_test : public beast::unit_test::suite
testAccountID()
{
auto const s = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
if (BEAST_EXPECT(parseBase58<AccountID>(s)))
BEAST_EXPECT(toBase58(*parseBase58<AccountID>(s)) == s);
if (auto const parsed = parseBase58<AccountID>(s); BEAST_EXPECT(parsed))
{
BEAST_EXPECT(toBase58(*parsed) == s);
}
{
auto const s =
"âabcd1rNxp4h8apvRis6mJf9Sh8C6iRxfrDWNâabcdAVâ\xc2\x80\xc2\x8f";
BEAST_EXPECT(!parseBase58<AccountID>(s));
}
}
void