mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
fix(package): [formatter] use the next byte unit when rounding hits base (#425)
* fix(package): [formatter] use the next byte unit when rounding hits base * test(package): [formatter] cover byte unit rollover on rounding
This commit is contained in:
1 parent
285e69edd7
commit
9c56f5f525
2 files changed
+24
-2
No files matched your search
@@ -28,6 +28,10 @@ func TestDecimalBytes(t *testing.T) {
|
||||
|
||||
assert.Equal("4MB", DecimalBytes(4000000, 0))
|
||||
assert.Equal("4MB", DecimalBytes(4000000, 1))
|
||||
|
||||
assert.Equal("1MB", DecimalBytes(999999, 2))
|
||||
assert.Equal("1GB", DecimalBytes(999999999, 2))
|
||||
assert.Equal("999.99KB", DecimalBytes(999990, 2))
|
||||
}
|
||||
|
||||
func TestBinaryBytes(t *testing.T) {
|
||||
@@ -43,6 +47,9 @@ func TestBinaryBytes(t *testing.T) {
|
||||
assert.Equal("10KiB", BinaryBytes(10240, 0))
|
||||
assert.Equal("10KiB", BinaryBytes(10240, 1))
|
||||
assert.Equal("10KiB", BinaryBytes(10240, 2))
|
||||
|
||||
assert.Equal("1MiB", BinaryBytes(1048575, 2))
|
||||
assert.Equal("1023.99KiB", BinaryBytes(1048566, 2))
|
||||
}
|
||||
|
||||
func TestParseDecimalBytes(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user