1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:57:44 +00:00

AK+Format: Support all format specifiers for strings.

The following is now possible:

    outf("{:.4}", "abcdef"); // abcd
    outf("{:*<8}", "abcdef"); // abcdef**
This commit is contained in:
asynts 2020-09-29 13:55:58 +02:00 committed by Andreas Kling
parent c0d9daadb0
commit 71b7ef0992
3 changed files with 58 additions and 9 deletions

View file

@ -122,4 +122,12 @@ TEST_CASE(replacement_field)
EXPECT_EQ(String::formatted("{:0{}}", 1, 3), "001");
}
TEST_CASE(complex_string_specifiers)
{
EXPECT_EQ(String::formatted("{:.8}", "123456789"), "12345678");
EXPECT_EQ(String::formatted("{:9}", "abcd"), "abcd ");
EXPECT_EQ(String::formatted("{:>9}", "abcd"), " abcd");
EXPECT_EQ(String::formatted("{:^9}", "abcd"), " abcd ");
}
TEST_MAIN(Format)