1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:37:35 +00:00

AK: Add a basic formatter for wchar_t

This commit is contained in:
Tim Schumacher 2021-09-21 23:07:03 +02:00 committed by Brian Gianforcaro
parent 4ef3ed4ba3
commit 67a579aab0
3 changed files with 31 additions and 0 deletions

View file

@ -323,3 +323,17 @@ TEST_CASE(vector_format)
EXPECT_EQ(String::formatted("{}", v), "[ [ 1, 2 ], [ 3, 4 ] ]");
}
}
TEST_CASE(format_wchar)
{
EXPECT_EQ(String::formatted("{}", L'a'), "a");
EXPECT_EQ(String::formatted("{}", L'\U0001F41E'), "\xF0\x9F\x90\x9E");
EXPECT_EQ(String::formatted("{:x}", L'a'), "61");
EXPECT_EQ(String::formatted("{:x}", L'\U0001F41E'), "1f41e");
EXPECT_EQ(String::formatted("{:d}", L'a'), "97");
EXPECT_EQ(String::formatted("{:d}", L'\U0001F41E'), "128030");
EXPECT_EQ(String::formatted("{:6}", L'a'), "a ");
EXPECT_EQ(String::formatted("{:6d}", L'a'), " 97");
EXPECT_EQ(String::formatted("{:#x}", L'\U0001F41E'), "0x1f41e");
}