From 12080b1f7dbc9f9f2ebbbef2428a8965e1d13ce2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 29 May 2024 18:09:48 +0200 Subject: [PATCH] shared/format-table: print BPS with part after point MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes https://github.com/systemd/systemd/issues/33076. "2Gbps" → "2.5Gbps". --- src/shared/format-table.c | 2 +- src/test/test-format-table.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/shared/format-table.c b/src/shared/format-table.c index ad186a5aac7..9146444d9c0 100644 --- a/src/shared/format-table.c +++ b/src/shared/format-table.c @@ -1712,7 +1712,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas if (!p) return NULL; - if (!format_bytes_full(p, FORMAT_BYTES_MAX, d->size, 0)) + if (!format_bytes_full(p, FORMAT_BYTES_MAX, d->size, FORMAT_BYTES_BELOW_POINT)) return table_ersatz_string(t); n = strlen(p); diff --git a/src/test/test-format-table.c b/src/test/test-format-table.c index 3a0efdacc16..3dbfda7f967 100644 --- a/src/test/test-format-table.c +++ b/src/test/test-format-table.c @@ -650,14 +650,14 @@ TEST(table_bps) { printf("%s", formatted); assert_se(streq(formatted, - "UINT64 SIZE BPS\n" - "2500 2.4K 2Kbps\n" - "10000000 9.5M 10Mbps\n" - "20000000 19M 20Mbps\n" - "25000000 23.8M 25Mbps\n" - "1000000000 953.6M 1Gbps\n" - "2000000000 1.8G 2Gbps\n" - "2500000000 2.3G 2Gbps\n" + "UINT64 SIZE BPS\n" + "2500 2.4K 2.5Kbps\n" + "10000000 9.5M 10Mbps\n" + "20000000 19M 20Mbps\n" + "25000000 23.8M 25Mbps\n" + "1000000000 953.6M 1Gbps\n" + "2000000000 1.8G 2Gbps\n" + "2500000000 2.3G 2.5Gbps\n" )); } -- 2.47.3