mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Tests: Convert TestQuotedPrintable decode test to use StringViews
This commit is contained in:
parent
f6b1db37fc
commit
fded8f861d
Notes:
sideshowbarker
2024-07-17 17:38:29 +09:00
Author: https://github.com/sin-ack Commit: https://github.com/SerenityOS/serenity/commit/fded8f861d Pull-request: https://github.com/SerenityOS/serenity/pull/14555 Reviewed-by: https://github.com/Dexesttp ✅ Reviewed-by: https://github.com/kleinesfilmroellchen
1 changed files with 13 additions and 13 deletions
|
@ -10,29 +10,29 @@
|
||||||
|
|
||||||
TEST_CASE(test_decode)
|
TEST_CASE(test_decode)
|
||||||
{
|
{
|
||||||
auto decode_equal = [](char const* input, char const* expected) {
|
auto decode_equal = [](StringView input, StringView expected) {
|
||||||
auto decoded = IMAP::decode_quoted_printable(StringView(input));
|
auto decoded = IMAP::decode_quoted_printable(input);
|
||||||
EXPECT(String::copy(decoded) == String(expected));
|
EXPECT(decoded.bytes() == expected.bytes());
|
||||||
};
|
};
|
||||||
|
|
||||||
auto decode_equal_byte_buffer = [](char const* input, char const* expected, size_t expected_length) {
|
auto decode_equal_byte_buffer = [](StringView input, StringView expected) {
|
||||||
auto decoded = IMAP::decode_quoted_printable(StringView(input));
|
auto decoded = IMAP::decode_quoted_printable(input);
|
||||||
EXPECT(decoded == ByteBuffer::copy(expected, expected_length).value());
|
EXPECT(decoded.bytes() == expected.bytes());
|
||||||
};
|
};
|
||||||
|
|
||||||
decode_equal("hello world", "hello world");
|
decode_equal("hello world"sv, "hello world"sv);
|
||||||
decode_equal("=3D", "=");
|
decode_equal("=3D"sv, "="sv);
|
||||||
decode_equal("hello=\r\n world", "hello world");
|
decode_equal("hello=\r\n world"sv, "hello world"sv);
|
||||||
decode_equal("=68=65=6C=6C=6F=20=\r\n=77=6F=72=6C=64", "hello world");
|
decode_equal("=68=65=6C=6C=6F=20=\r\n=77=6F=72=6C=64"sv, "hello world"sv);
|
||||||
|
|
||||||
// Doesn't mistake hex sequences without a preceding '=' as an escape sequence.
|
// Doesn't mistake hex sequences without a preceding '=' as an escape sequence.
|
||||||
decode_equal("4A=4B=4C4D", "4AKL4D");
|
decode_equal("4A=4B=4C4D"sv, "4AKL4D"sv);
|
||||||
|
|
||||||
// Allows lowercase escape sequences.
|
// Allows lowercase escape sequences.
|
||||||
decode_equal("=4a=4b=4c=4d=4e=4f", "JKLMNO");
|
decode_equal("=4a=4b=4c=4d=4e=4f"sv, "JKLMNO"sv);
|
||||||
|
|
||||||
// Bytes for U+1F41E LADY BEETLE
|
// Bytes for U+1F41E LADY BEETLE
|
||||||
decode_equal_byte_buffer("=F0=9F=90=9E", "\xF0\x9F\x90\x9E", 4);
|
decode_equal_byte_buffer("=F0=9F=90=9E"sv, "\xF0\x9F\x90\x9E"sv);
|
||||||
|
|
||||||
// Illegal characters. If these aren't escaped, they are simply ignored.
|
// Illegal characters. If these aren't escaped, they are simply ignored.
|
||||||
// Illegal characters are:
|
// Illegal characters are:
|
||||||
|
|
Loading…
Reference in a new issue