1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-28 09:35:14 +03:00

Merge pull request #307 from hillmarcus/306-file-size

Issue #306, File Size Mismatch
This commit is contained in:
Zack 2020-12-28 10:46:39 -08:00 committed by GitHub
commit 0994e4eda5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -136,7 +136,7 @@ func GetRandomName() string {
// ByteCountDecimal converts bytes to human readable byte string
func ByteCountDecimal(b int64) string {
const unit = 1000
const unit = 1024
if b < unit {
return fmt.Sprintf("%d B", b)
}

View File

@ -88,9 +88,9 @@ func TestSHA256(t *testing.T) {
}
func TestByteCountDecimal(t *testing.T) {
assert.Equal(t, "10.0 kB", ByteCountDecimal(10000))
assert.Equal(t, "10.0 kB", ByteCountDecimal(10240))
assert.Equal(t, "50 B", ByteCountDecimal(50))
assert.Equal(t, "12.4 MB", ByteCountDecimal(12378517))
assert.Equal(t, "12.4 MB", ByteCountDecimal(13002343))
}
func TestMissingChunks(t *testing.T) {