Merge pull request !45 from K-on/fix-util
This commit is contained in:
K-on 2021-10-04 13:14:27 +00:00 committed by Gitee
commit 15cede5780
1 changed files with 18 additions and 8 deletions

View File

@ -6,13 +6,23 @@ import (
)
func TestParseSizeToBit(t *testing.T) {
require.Equal(t, ParseSizeToBit("18Kb"), int64(18*1024*8))
require.Equal(t, ParseSizeToBit("18KB"), int64(18*1024*8))
require.Equal(t, ParseSizeToBit("18mB"), int64(18*1024*1024*8))
require.Equal(t, ParseSizeToBit("18gb"), int64(18*1024*1024*1024*8))
size, err := ParseSizeToBit("18kb")
require.NoError(t, err)
require.Equal(t, size, int64(18*1024*8))
require.Equal(t, ParseSizeToBit("18b"), int64(18*8))
require.Equal(t, ParseSizeToBit("18B"), int64(18*8))
require.Equal(t, ParseSizeToBit("18bit"), int64(18*8))
require.Equal(t, ParseSizeToBit("18BIt"), int64(18*8))
size, err = ParseSizeToBit("18Mb")
require.NoError(t, err)
require.Equal(t, size, int64(18*1024*1024*8))
size, err = ParseSizeToBit("18gB")
require.NoError(t, err)
require.Equal(t, size, int64(18*1024*1024*1024*8))
size, err = ParseSizeToBit("18b")
require.NoError(t, err)
require.Equal(t, size, int64(18*8))
size, err = ParseSizeToBit("18bit")
require.NoError(t, err)
require.Equal(t, size, int64(18*8))
}