Skip to content

Commit

Permalink
fix: 阿拉伯数字转换功能存在问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ccpwcn committed Oct 17, 2024
1 parent ba01794 commit 7ab77fc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion init.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion kg_str/arabic_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion kg_str/arabic_convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
Expand Down

0 comments on commit 7ab77fc

Please sign in to comment.