修复GetPricePercentage中的bug

This commit is contained in:
gazebo
2019-11-19 16:02:25 +08:00
parent cee40f9a92
commit 15020a0c9f
2 changed files with 15 additions and 3 deletions

View File

@@ -173,6 +173,7 @@ func TestGetPricePercentage(t *testing.T) {
SpecUnit string
Unit string
}
l := []*model.PricePercentageItem{
&model.PricePercentageItem{
BeginPrice: 0,
@@ -194,12 +195,21 @@ func TestGetPricePercentage(t *testing.T) {
PricePercentage: 30,
PriceAdd: 3,
},
&model.PricePercentageItem{
BeginPrice: 60,
PricePercentage: 60,
PriceAdd: 6,
},
}
for _, v := range [][]int{
[]int{88, 0, -1, 88},
[]int{0, 0, 0, 0},
[]int{30, 3, 40, 0},
[]int{20, 2, 25, 0},
[]int{10, 1, 10, 0},
[]int{60, 6, 60, 0},
[]int{60, 6, 1000, 10},
} {
pricePercentage, priceAdd := GetPricePercentage(l, v[2], v[3])
if pricePercentage != v[0] || priceAdd != v[1] {