AK: Add tests for Base64 decoder

This commit is contained in:
Tom Lebreux 2020-06-12 22:12:59 -04:00 committed by Andreas Kling
parent 79529ffd47
commit e14c8b2707

View file

@ -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) {