This commit is contained in:
邹宗楠
2022-12-20 17:27:17 +08:00
parent 3142b3ba18
commit 1804ba70d7

View File

@@ -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 青尖椒200g700g/组(茄子500g 青椒200g)
// 90 60
func TestLen(t *testing.T) {
aa := "【组合菜】尖椒茄子茄子500g 青尖椒200g700g/组(茄子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)
}