From 7ab77fc7258b374b58a0c0d337a8029f377aeb7d Mon Sep 17 00:00:00 2001 From: ccpwcn Date: Thu, 17 Oct 2024 16:59:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=98=BF=E6=8B=89=E4=BC=AF=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E8=BD=AC=E6=8D=A2=E5=8A=9F=E8=83=BD=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.go | 2 +- kg_str/arabic_convert.go | 3 ++- kg_str/arabic_convert_test.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/init.go b/init.go index 5f7625c..a46e5e9 100644 --- a/init.go +++ b/init.go @@ -1,7 +1,7 @@ package kgo type IntUintBig interface { - ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 + ~int | ~int64 | ~uint | ~uint64 } type IntUintFloat interface { diff --git a/kg_str/arabic_convert.go b/kg_str/arabic_convert.go index aebd82d..d766725 100644 --- a/kg_str/arabic_convert.go +++ b/kg_str/arabic_convert.go @@ -27,10 +27,11 @@ var ( // ArabicToChinese 阿里数字转中文数字 func ArabicToChinese[T kgo.IntUintBig](arabic T) string { + var maxSupportedNum T = 9999_9999_9999 if arabic < 0 { return "" } - if arabic > 9999_9999_9999 { + if arabic > maxSupportedNum { return "" } var ( diff --git a/kg_str/arabic_convert_test.go b/kg_str/arabic_convert_test.go index 39f948a..2979ee8 100644 --- a/kg_str/arabic_convert_test.go +++ b/kg_str/arabic_convert_test.go @@ -54,7 +54,7 @@ func TestArabicToChinese(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := ArabicToChinese(tt.args.arabic); got != tt.want { + if got := ArabicToChinese[int](tt.args.arabic); got != tt.want { t.Errorf("ArabicToChinese() = %v, want %v", got, tt.want) } })