Files
baseapi/platformapi/showapi/barcode_test.go
2025-11-21 09:09:09 +08:00

57 lines
1.2 KiB
Go

package showapi
import (
"fmt"
"testing"
"git.rosy.net.cn/baseapi/utils"
)
func TestGetProductInfoByBarCode(t *testing.T) {
result, err := api.GetProductInfoByBarCode("6943924100033")
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestSplitProductSpec(t *testing.T) {
testData := []map[string]interface{}{
map[string]interface{}{
"spec": "9张/包",
"specQuality": 9,
"specUnit": "张",
"unit": "包",
},
map[string]interface{}{
"spec": "300克",
"specQuality": 300,
"specUnit": "克",
"unit": "",
},
map[string]interface{}{
"spec": "ffff",
"specQuality": 0,
"specUnit": "",
"unit": "",
},
}
for _, v := range testData {
specQuality, specUnit, unit := SplitProductSpec(v["spec"].(string))
// t.Log(specQuality, ",", specUnit, ",", unit)
if specQuality != v["specQuality"] {
t.Fatalf("%s specQuality is wrong", v["spec"].(string))
}
if specUnit != v["specUnit"] {
t.Fatalf("%s specUnit is wrong", v["spec"].(string))
}
if unit != v["unit"] {
t.Fatalf("%s unit is wrong", v["spec"].(string))
}
}
}
func Test111(t *testing.T) {
fmt.Println(23&16 != 0)
}