From 0105600120891c3cd87ffc0bb53bbaab478b0055 Mon Sep 17 00:00:00 2001 From: Arda Cinar Date: Thu, 15 Dec 2022 16:47:03 +0300 Subject: [PATCH] AK+Tests: Add a test for formatting numbers in base 10 units Added a test case to TestNumberFormat to test the new base 10 formatting capability --- Tests/AK/TestNumberFormat.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Tests/AK/TestNumberFormat.cpp b/Tests/AK/TestNumberFormat.cpp index 373d3bef98..7f10ced2b0 100644 --- a/Tests/AK/TestNumberFormat.cpp +++ b/Tests/AK/TestNumberFormat.cpp @@ -125,3 +125,11 @@ TEST_CASE(extremes_8byte) warnln("(Skipping 8-byte-size_t test on 32-bit platform)"); } } + +TEST_CASE(base10_units) +{ + EXPECT_EQ(human_readable_size(999, AK::HumanReadableBasedOn::Base10), "999 B"); + EXPECT_EQ(human_readable_size(1024, AK::HumanReadableBasedOn::Base10), "1.0 KB"); + EXPECT_EQ(human_readable_size(1100, AK::HumanReadableBasedOn::Base10), "1.1 KB"); + EXPECT_EQ(human_readable_size(1000000, AK::HumanReadableBasedOn::Base10), "1.0 MB"); +}