summaryrefslogtreecommitdiff
path: root/AK/Tests/TestFormat.cpp
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-09-29 13:55:58 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-29 16:14:58 +0200
commit71b7ef0992b5d18bd4d463943a5ab3f3876ce41d (patch)
tree8836d4780cafe0dabae6866a8cd6ed1a8680d5a2 /AK/Tests/TestFormat.cpp
parentc0d9daadb07432db6667d2f3b9080af9f26f6925 (diff)
downloadserenity-71b7ef0992b5d18bd4d463943a5ab3f3876ce41d.zip
AK+Format: Support all format specifiers for strings.
The following is now possible: outf("{:.4}", "abcdef"); // abcd outf("{:*<8}", "abcdef"); // abcdef**
Diffstat (limited to 'AK/Tests/TestFormat.cpp')
-rw-r--r--AK/Tests/TestFormat.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/AK/Tests/TestFormat.cpp b/AK/Tests/TestFormat.cpp
index 898fd49df0..18994250fd 100644
--- a/AK/Tests/TestFormat.cpp
+++ b/AK/Tests/TestFormat.cpp
@@ -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)