diff options
author | Tom Lebreux <tomlebreux@hotmail.com> | 2020-06-12 22:12:59 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-18 23:21:41 +0200 |
commit | e14c8b2707139dc7e139d3fa941ca7b29b917e1d (patch) | |
tree | 6deda1ca133d5b0d6a1bc1ff6aaf6177656a06a6 /AK/Tests/TestBase64.cpp | |
parent | 79529ffd471e993c0448aadbe84ef42e435d6fd3 (diff) | |
download | serenity-e14c8b2707139dc7e139d3fa941ca7b29b917e1d.zip |
AK: Add tests for Base64 decoder
Diffstat (limited to 'AK/Tests/TestBase64.cpp')
-rw-r--r-- | AK/Tests/TestBase64.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/AK/Tests/TestBase64.cpp b/AK/Tests/TestBase64.cpp index 40b7e494a6..d495d79092 100644 --- a/AK/Tests/TestBase64.cpp +++ b/AK/Tests/TestBase64.cpp @@ -30,6 +30,22 @@ #include <AK/ByteBuffer.h> #include <AK/String.h> +TEST_CASE(test_decode) +{ + auto decode_equal = [&](const char* input, const char* expected) { + auto decoded = decode_base64(StringView(input)); + EXPECT(String::copy(decoded) == String(expected)); + }; + + decode_equal("", ""); + decode_equal("Zg==", "f"); + decode_equal("Zm8=", "fo"); + decode_equal("Zm9v", "foo"); + decode_equal("Zm9vYg==", "foob"); + decode_equal("Zm9vYmE=", "fooba"); + decode_equal("Zm9vYmFy", "foobar"); +} + TEST_CASE(test_encode) { auto encode_equal = [&](const char* input, const char* expected) { |