Skip to content

Commit 05dc162

Browse files
committed
Add tests for naturalsize with non-integer bytes below the base
Refs #459
1 parent 38d9d91 commit 05dc162

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

‎tests/test_filesize.py‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474
([3000, False, True, "%.3f"], "2.930K"),
7575
([3000000000, False, True, "%.0f"], "3G"),
7676
([10**26 * 30, True, False, "%.3f"], "2.423 RiB"),
77-
([1.123456789], "1 Bytes"),
77+
([1.123456789], "1.1 Bytes"),
7878
([1.123456789 * 10**3], "1.1 kB"),
7979
([1.123456789 * 10**6], "1.1 MB"),
80-
([1.123456789, False, True], "1B"),
80+
([1.123456789, False, True], "1.1B"),
8181
([1.123456789 * 10**3, False, True], "1.1K"),
8282
([1.123456789 * 10**6, False, True], "1.1M"),
8383
# Rounding must not leave the mantissa at the base while a larger suffix
@@ -89,6 +89,30 @@
8989
([1024**2 - 1, True], "1.0 MiB"),
9090
([1024**3 - 1, True], "1.0 GiB"),
9191
([1024**2 - 1, False, True], "1.0M"),
92+
([1.5], "1.5 Bytes"),
93+
([1.9], "1.9 Bytes"),
94+
([0.5], "0.5 Bytes"),
95+
(["1.5"], "1.5 Bytes"),
96+
([999.5], "999.5 Bytes"),
97+
([999.94], "999.9 Bytes"),
98+
([1.5, True], "1.5 Bytes"),
99+
([1.123456789, True], "1.1 Bytes"),
100+
([1023.5, True], "1023.5 Bytes"),
101+
([1.5, False, True], "1.5B"),
102+
([1023.5, False, True], "1023.5B"),
103+
([1.25, False, False, "%.2f"], "1.25 Bytes"),
104+
([1.5, False, True, "%.3f"], "1.500B"),
105+
([2.04], "2.0 Bytes"),
106+
([1.04], "1.0 Bytes"),
107+
([0.96], "1.0 Bytes"),
108+
([2.0], "2 Bytes"),
109+
([999], "999 Bytes"),
110+
([999.0], "999 Bytes"),
111+
([1023, True], "1023 Bytes"),
112+
([1023, False, True], "1023B"),
113+
([300, False, False, "%.3f"], "300 Bytes"),
114+
([300, False, True, "%.3f"], "300B"),
115+
([1.0, False, False, "%.3f"], "1 Byte"),
92116
],
93117
)
94118
def test_naturalsize(test_args: list[int] | list[int | bool], expected: str) -> None:

0 commit comments

Comments
 (0)