From e637cccaede949c03c930af6e64808bad31be768 Mon Sep 17 00:00:00 2001 From: HuangJiaLuo <1820799930@qq.com> Date: Mon, 4 Oct 2021 21:06:40 +0800 Subject: [PATCH] fix(util): fix the bug of memory --- pkg/util/memory_test.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/pkg/util/memory_test.go b/pkg/util/memory_test.go index d7422d0..a328a88 100644 --- a/pkg/util/memory_test.go +++ b/pkg/util/memory_test.go @@ -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)) }