1
This commit is contained in:
@@ -2,11 +2,11 @@ package mtwmapi
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
"unicode"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestOrderViewStatus(t *testing.T) {
|
func TestOrderViewStatus(t *testing.T) {
|
||||||
@@ -183,3 +183,49 @@ func TestOrderDelivering(t *testing.T) {
|
|||||||
err := api.OrderDelivering(148815413321281654)
|
err := api.OrderDelivering(148815413321281654)
|
||||||
t.Fatal(err)
|
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)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user