diff --git a/platformapi/mtwmapi/order_test.go b/platformapi/mtwmapi/order_test.go index 3d91ae88..bd44ea75 100644 --- a/platformapi/mtwmapi/order_test.go +++ b/platformapi/mtwmapi/order_test.go @@ -2,11 +2,11 @@ package mtwmapi import ( "fmt" + "git.rosy.net.cn/baseapi/utils" "strings" "testing" "time" - - "git.rosy.net.cn/baseapi/utils" + "unicode" ) func TestOrderViewStatus(t *testing.T) { @@ -183,3 +183,49 @@ func TestOrderDelivering(t *testing.T) { err := api.OrderDelivering(148815413321281654) t.Fatal(err) } + +// 88 67 【组合菜】尖椒茄子(茄子500g 青尖椒200g)700g/组(茄子500g 青椒200g) +// 90 60 +func TestLen(t *testing.T) { + aa := "【组合菜】尖椒茄子(茄子500g 青尖椒200g)700g/组(茄子500g 青椒200g)" + var count int // 中文 + var punctZh int // 中文标点 + var punctEn int // 英文标点 + var punctAZ int // 字母 + var punctNum int // 字母 + var spance int // 空格 + for _, v := range aa { + if unicode.Is(unicode.Han, v) { // 中文 + count++ + continue + } + if unicode.IsPunct(v) { // 字符 + if v >= 1000 { + fmt.Println(v) + punctZh++ + } else { + punctEn++ + } + continue + } + if unicode.IsLetter(v) { + punctAZ++ + continue + } + if unicode.IsNumber(v) { + punctNum++ + continue + } + if unicode.IsSpace(v) { + spance++ + continue + } + } + fmt.Println("count:= ", count) + fmt.Println("count:= ", punctZh) + fmt.Println("count:= ", punctEn) + fmt.Println("count:= ", punctAZ) + fmt.Println("count:= ", punctNum) + + fmt.Println("all = ", (count*2)+(punctZh*2)+punctEn+punctAZ+punctNum+spance) +}