format: byte formatting test coverage (#8692)

Removed redundant checks and streamlined the switch-case structure.
Added test cases for both HumanBytes and HumanBytes2 to cover a wide range of scenarios.
This commit is contained in:
Azis Alvriyanto 2025-02-06 03:23:07 +07:00 committed by GitHub
parent f00d359a67
commit 8d8b9f83ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 91 additions and 2 deletions

View file

@ -40,8 +40,6 @@ func HumanBytes(b int64) string {
}
switch {
case value >= 100:
return fmt.Sprintf("%d %s", int(value), unit)
case value >= 10:
return fmt.Sprintf("%d %s", int(value), unit)
case value != math.Trunc(value):