]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/format-table: print BPS with part after point 33081/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 29 May 2024 16:09:48 +0000 (18:09 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 30 May 2024 09:38:30 +0000 (11:38 +0200)
Fixes https://github.com/systemd/systemd/issues/33076.
"2Gbps" → "2.5Gbps".

src/shared/format-table.c
src/test/test-format-table.c

index ad186a5aac7b3252270a566bdaf6d1bb8372a1ca..9146444d9c052afb461ed9a8f968082178716e1c 100644 (file)
@@ -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);
index 3a0efdacc16ada12e444887cada79a161ebae652..3dbfda7f967ae38f33afd92e5d3c8d37aa04ab9b 100644 (file)
@@ -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"
                   ));
 }