mirror of
https://github.com/go-gitea/gitea
synced 2024-11-19 00:11:24 +01:00
Add unit test for base.FileSize()
This commit is contained in:
parent
11c9160cd3
commit
d874a9bf6b
1 changed files with 23 additions and 2 deletions
|
@ -1,6 +1,9 @@
|
|||
package base
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEncodeMD5(t *testing.T) {
|
||||
if checksum := EncodeMD5("foobar"); checksum != "3858f62230ac3c915f300c664312c63f" {
|
||||
|
@ -70,7 +73,25 @@ func TestHashEmail(t *testing.T) {
|
|||
// TODO: TimeSince()
|
||||
// TODO: logn()
|
||||
// TODO: humanateBytes()
|
||||
// TODO: FileSize()
|
||||
|
||||
func TestFileSize(t *testing.T) {
|
||||
var size int64
|
||||
size = 512
|
||||
assert.Equal(t, "512B", FileSize(size))
|
||||
size = size * 1024
|
||||
assert.Equal(t, "512KB", FileSize(size))
|
||||
size = size * 1024
|
||||
assert.Equal(t, "512MB", FileSize(size))
|
||||
size = size * 1024
|
||||
assert.Equal(t, "512GB", FileSize(size))
|
||||
size = size * 1024
|
||||
assert.Equal(t, "512TB", FileSize(size))
|
||||
size = size * 1024
|
||||
assert.Equal(t, "512PB", FileSize(size))
|
||||
//size = size * 1024 TODO: Fix bug for EB
|
||||
//assert.Equal(t, "512EB", FileSize(size))
|
||||
}
|
||||
|
||||
// TODO: Subtract()
|
||||
// TODO: EllipsisString()
|
||||
// TODO: TruncateString()
|
||||
|
|
Loading…
Reference in a new issue