diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-06-19 17:00:31 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-19 16:13:59 +0100 |
commit | 5e53a690ace8dce64f72a5a734def8e832f6b7d3 (patch) | |
tree | dac0feb465c6a6e7719289f24ca6049f9bb06041 /Tests | |
parent | 4d5ffd364a366d7fbfccadf4650c6b7f8661e1fd (diff) | |
download | serenity-5e53a690ace8dce64f72a5a734def8e832f6b7d3.zip |
AK: Add support for keeping trailing zeros in fixed precision floats
This uses the same syntax as zero padding integers:
String::formatted("{:0.5}", 1.234) => "1.23400"
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/AK/TestFormat.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Tests/AK/TestFormat.cpp b/Tests/AK/TestFormat.cpp index 9e0aad7810..50ddde2f47 100644 --- a/Tests/AK/TestFormat.cpp +++ b/Tests/AK/TestFormat.cpp @@ -252,6 +252,12 @@ TEST_CASE(yay_this_implementation_sucks) EXPECT_EQ(String::formatted("{:.0}", .99999999999), "0"); } +TEST_CASE(precision_with_trailing_zeros) +{ + EXPECT_EQ(String::formatted("{:0.3}", 1.12), "1.120"); + EXPECT_EQ(String::formatted("{:0.1}", 1.12), "1.1"); +} + TEST_CASE(magnitude_less_than_zero) { EXPECT_EQ(String::formatted("{}", -0.654), "-0.654"); |