1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:47:34 +00:00

AK+Format: Keep type information for integers in TypeErasedParameter.

It's now save to pass a signed integer as parameter and then use it as
replacement field (previously, this would just cast it to size_t which
would be bad.)
This commit is contained in:
asynts 2020-09-27 18:09:14 +02:00 committed by Andreas Kling
parent 6a2f5f4522
commit 56bfefabb6
3 changed files with 81 additions and 10 deletions

View file

@ -116,6 +116,9 @@ TEST_CASE(zero_pad)
TEST_CASE(replacement_field)
{
EXPECT_EQ(String::formatted("{:*>{1}}", 13, static_cast<size_t>(10)), "********13");
EXPECT_EQ(String::formatted("{:*<{1}}", 7, 4), "7***");
EXPECT_EQ(String::formatted("{:{2}}", -5, 8, 16), " -5");
EXPECT_EQ(String::formatted("{{{:*^{1}}}}", 1, 3), "{*1*}");
}
TEST_MAIN(Format)