summaryrefslogtreecommitdiffstats
path: root/src/test/test-format-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2024-05-29 18:07:23 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2024-05-30 11:38:30 +0200
commit11226bf19bb9effcc130dc297a7c7a660ccb75ee (patch)
tree2459bbe9bd21f5e45a26d5eb4737c104c0363b4d /src/test/test-format-util.c
parenttest-format-table: add test for TABLE_BPS formatting (diff)
downloadsystemd-11226bf19bb9effcc130dc297a7c7a660ccb75ee.tar.xz
systemd-11226bf19bb9effcc130dc297a7c7a660ccb75ee.zip
shared/format-table: do not print '.0'
This makes output a bit shorter and nicer. For us, shorter output is generally better. Also, drop unnecessary UINT64_C macros. The left operand is always uint64_t, and C upcasting rules mean that it doesn't matter if the right operand is narrower or signed, the operation is always done on the wider unsigned type.
Diffstat (limited to 'src/test/test-format-util.c')
-rw-r--r--src/test/test-format-util.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/test/test-format-util.c b/src/test/test-format-util.c
index 94feb6cafc..8afba4e585 100644
--- a/src/test/test-format-util.c
+++ b/src/test/test-format-util.c
@@ -43,17 +43,17 @@ static void test_format_bytes_one(uint64_t val, bool trailing_B, const char *iec
TEST(format_bytes) {
test_format_bytes_one(900, true, "900B", "900B", "900B", "900B");
test_format_bytes_one(900, false, "900", "900", "900", "900");
- test_format_bytes_one(1023, true, "1023B", "1023B", "1.0K", "1K");
- test_format_bytes_one(1023, false, "1023", "1023", "1.0K", "1K");
- test_format_bytes_one(1024, true, "1.0K", "1K", "1.0K", "1K");
- test_format_bytes_one(1024, false, "1.0K", "1K", "1.0K", "1K");
- test_format_bytes_one(1100, true, "1.0K", "1K", "1.1K", "1K");
+ test_format_bytes_one(1023, true, "1023B", "1023B", "1K", "1K");
+ test_format_bytes_one(1023, false, "1023", "1023", "1K", "1K");
+ test_format_bytes_one(1024, true, "1K", "1K", "1K", "1K");
+ test_format_bytes_one(1024, false, "1K", "1K", "1K", "1K");
+ test_format_bytes_one(1100, true, "1K", "1K", "1.1K", "1K");
test_format_bytes_one(1500, true, "1.4K", "1K", "1.5K", "1K");
- test_format_bytes_one(UINT64_C(3)*1024*1024, true, "3.0M", "3M", "3.1M", "3M");
- test_format_bytes_one(UINT64_C(3)*1024*1024*1024, true, "3.0G", "3G", "3.2G", "3G");
- test_format_bytes_one(UINT64_C(3)*1024*1024*1024*1024, true, "3.0T", "3T", "3.2T", "3T");
- test_format_bytes_one(UINT64_C(3)*1024*1024*1024*1024*1024, true, "3.0P", "3P", "3.3P", "3P");
- test_format_bytes_one(UINT64_C(3)*1024*1024*1024*1024*1024*1024, true, "3.0E", "3E", "3.4E", "3E");
+ test_format_bytes_one(UINT64_C(3)*1024*1024, true, "3M", "3M", "3.1M", "3M");
+ test_format_bytes_one(UINT64_C(3)*1024*1024*1024, true, "3G", "3G", "3.2G", "3G");
+ test_format_bytes_one(UINT64_C(3)*1024*1024*1024*1024, true, "3T", "3T", "3.2T", "3T");
+ test_format_bytes_one(UINT64_C(3)*1024*1024*1024*1024*1024, true, "3P", "3P", "3.3P", "3P");
+ test_format_bytes_one(UINT64_C(3)*1024*1024*1024*1024*1024*1024, true, "3E", "3E", "3.4E", "3E");
test_format_bytes_one(UINT64_MAX, true, NULL, NULL, NULL, NULL);
test_format_bytes_one(UINT64_MAX, false, NULL, NULL, NULL, NULL);
}