2021-09-27 11:29:47 +08:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
2021-10-03 16:22:33 +08:00
|
|
|
"github.com/stretchr/testify/require"
|
2021-09-27 11:29:47 +08:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseSizeToBit(t *testing.T) {
|
2021-10-04 21:06:40 +08:00
|
|
|
size, err := ParseSizeToBit("18kb")
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, size, int64(18*1024*8))
|
2021-10-03 16:22:33 +08:00
|
|
|
|
2021-10-04 21:06:40 +08:00
|
|
|
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))
|
2021-09-27 11:29:47 +08:00
|
|
|
}
|