diff options
author | 赵智超 <1012112796@qq.com> | 2020-09-16 12:07:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-16 00:07:18 -0400 |
commit | a9decf0dacb56e57024ef7c5a0ade7fdcc56407e (patch) | |
tree | f6d1d48eaa324530b93af2780ff2297e11b39e25 /modules/base/tool_test.go | |
parent | d8b5235dedbb69812aeb43218a8d35938259a1c3 (diff) | |
download | gitea-a9decf0dacb56e57024ef7c5a0ade7fdcc56407e.tar.gz gitea-a9decf0dacb56e57024ef7c5a0ade7fdcc56407e.zip |
Use a simple format for the big number on ui (#12822)
* Use a simple format for the big number on ui
Signed-off-by: a1012112796 <1012112796@qq.com>
* make fmt
* Apply review suggestion @silverwind
* Change name 2
* make fmt
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules/base/tool_test.go')
-rw-r--r-- | modules/base/tool_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/base/tool_test.go b/modules/base/tool_test.go index cadb851858..f765fd0db0 100644 --- a/modules/base/tool_test.go +++ b/modules/base/tool_test.go @@ -223,5 +223,13 @@ func TestIsTextFile(t *testing.T) { assert.True(t, IsTextFile([]byte("lorem ipsum"))) } +func TestFormatNumberSI(t *testing.T) { + assert.Equal(t, "125", FormatNumberSI(int(125))) + assert.Equal(t, "1.3k", FormatNumberSI(int64(1317))) + assert.Equal(t, "21.3M", FormatNumberSI(21317675)) + assert.Equal(t, "45.7G", FormatNumberSI(45721317675)) + assert.Equal(t, "", FormatNumberSI("test")) +} + // TODO: IsImageFile(), currently no idea how to test // TODO: IsPDFFile(), currently no idea how to test |