StoreSkuBind添加JxPrice
This commit is contained in:
@@ -164,3 +164,47 @@ func TestCaculateSkuPrice(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetPricePercentage(t *testing.T) {
|
||||
type tTestInfo struct {
|
||||
DesiredPrice int
|
||||
UnitPrice int
|
||||
SpecQuality float32
|
||||
SpecUnit string
|
||||
Unit string
|
||||
}
|
||||
l := []*model.PricePercentageItem{
|
||||
&model.PricePercentageItem{
|
||||
BeginPrice: 0,
|
||||
PricePercentage: 0,
|
||||
PriceAdd: 0,
|
||||
},
|
||||
&model.PricePercentageItem{
|
||||
BeginPrice: 10,
|
||||
PricePercentage: 10,
|
||||
PriceAdd: 1,
|
||||
},
|
||||
&model.PricePercentageItem{
|
||||
BeginPrice: 20,
|
||||
PricePercentage: 20,
|
||||
PriceAdd: 2,
|
||||
},
|
||||
&model.PricePercentageItem{
|
||||
BeginPrice: 30,
|
||||
PricePercentage: 30,
|
||||
PriceAdd: 3,
|
||||
},
|
||||
}
|
||||
for _, v := range [][]int{
|
||||
[]int{0, 0, 0, 0},
|
||||
[]int{30, 3, 40, 0},
|
||||
[]int{20, 2, 25, 0},
|
||||
[]int{10, 1, 10, 0},
|
||||
} {
|
||||
pricePercentage, priceAdd := GetPricePercentage(l, v[2], v[3])
|
||||
if pricePercentage != v[0] || priceAdd != v[1] {
|
||||
t.Errorf("price:%d, defPricePercentage:%d, expected pricePercentage:%d, priceAdd:%d, actual pricePercentage:%d, priceAdd:%d",
|
||||
v[2], v[3], v[0], v[1], pricePercentage, priceAdd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user