- reimplement TrimBlanChar
This commit is contained in:
@@ -105,3 +105,29 @@ func TestUpdateStoreConfig4Open(t *testing.T) {
|
|||||||
t.Fatalf("UpdateStoreConfig4Open failed, isAutoOrder:%d", isAutoOrder)
|
t.Fatalf("UpdateStoreConfig4Open failed, isAutoOrder:%d", isAutoOrder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetDeliveryRangeByStationNo(t *testing.T) {
|
||||||
|
const testStoreID = "11738152"
|
||||||
|
result, err := jdapi.GetDeliveryRangeByStationNo(testStoreID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
result2, err := jdapi.GetStoreInfoByStationNo(testStoreID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||||
|
baseapi.SugarLogger.Debug(utils.Format4Output(result2, false))
|
||||||
|
deliveryRange := result["deliveryRange"].(string)
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"lng": result2["lng"],
|
||||||
|
"lat": result2["lat"],
|
||||||
|
"coordinateType": 3,
|
||||||
|
"deliveryRangeType": 2,
|
||||||
|
"coordinatePoints": deliveryRange,
|
||||||
|
}
|
||||||
|
err = jdapi.UpdateStoreInfo4Open(testStoreID, "test", params)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -196,10 +196,7 @@ func FilterMb4(content string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TrimBlanChar(str string) string {
|
func TrimBlanChar(str string) string {
|
||||||
return strings.TrimFunc(str, func(value rune) bool {
|
return strings.Trim(str, "\n\r\t ")
|
||||||
strValue := string(value)
|
|
||||||
return strValue == " " || strValue == "\t" || strValue == "\n" || strValue == "\r"
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func RemoveGeneralMapKeys(obj map[string]interface{}, keys ...string) map[string]interface{} {
|
func RemoveGeneralMapKeys(obj map[string]interface{}, keys ...string) map[string]interface{} {
|
||||||
|
|||||||
@@ -125,3 +125,12 @@ func TestRemoveGeneralMapKeys(t *testing.T) {
|
|||||||
t.Fatal("RemoveGeneralMapKeys handle nil wrong")
|
t.Fatal("RemoveGeneralMapKeys handle nil wrong")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTrimBlanChar(t *testing.T) {
|
||||||
|
str := `
|
||||||
|
大小21
|
||||||
|
`
|
||||||
|
if TrimBlanChar(str) != "大小21" {
|
||||||
|
t.Fatal("TrimBlanChar doesn't work")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user