1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:57:35 +00:00

AK+Userland: Make AK::decode_base64 return ErrorOr

This commit is contained in:
Sam Atkins 2022-01-20 17:18:17 +00:00 committed by Andreas Kling
parent f590cd1850
commit c388a879d7
11 changed files with 31 additions and 43 deletions

View file

@ -14,7 +14,7 @@ TEST_CASE(test_decode)
{
auto decode_equal = [&](const char* input, const char* expected) {
auto decoded_option = decode_base64(StringView(input));
EXPECT(decoded_option.has_value());
EXPECT(!decoded_option.is_error());
auto decoded = decoded_option.release_value();
EXPECT(String::copy(decoded) == String(expected));
EXPECT(StringView(expected).length() <= calculate_base64_decoded_length(StringView(input).bytes()));
@ -31,10 +31,10 @@ TEST_CASE(test_decode)
TEST_CASE(test_decode_invalid)
{
EXPECT(!decode_base64(StringView("asdf\xffqwe")).has_value());
EXPECT(!decode_base64(StringView("asdf\x80qwe")).has_value());
EXPECT(!decode_base64(StringView("asdf:qwe")).has_value());
EXPECT(!decode_base64(StringView("asdf=qwe")).has_value());
EXPECT(decode_base64(StringView("asdf\xffqwe")).is_error());
EXPECT(decode_base64(StringView("asdf\x80qwe")).is_error());
EXPECT(decode_base64(StringView("asdf:qwe")).is_error());
EXPECT(decode_base64(StringView("asdf=qwe")).is_error());
}
TEST_CASE(test_encode)