wheat-cache/pkg/util/memory_test.go

29 lines
643 B
Go
Raw Normal View History

2021-09-27 11:29:47 +08:00
package util
import (
"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-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
}