feat: cargo unload challenge
This commit is contained in:
@@ -320,26 +320,45 @@ func TestListRoutedUnloadShipGroupIds(t *testing.T) {
|
||||
func TestMaxOrRandomLoadId(t *testing.T) {
|
||||
IDtoLoad := make(map[int]float64)
|
||||
|
||||
assert.Panics(t, func() { controller.MaxOrRandomLoadId(IDtoLoad) })
|
||||
pop := func(ri int) float64 {
|
||||
switch ri {
|
||||
case 1:
|
||||
return 0
|
||||
case 3:
|
||||
return 0
|
||||
case 5:
|
||||
return 9.99
|
||||
case 7:
|
||||
return 10
|
||||
case 11:
|
||||
return 10
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
assert.Panics(t, func() { controller.MaxOrRandomLoadId(IDtoLoad, pop) })
|
||||
IDtoLoad[1] = 100.
|
||||
assert.Panics(t, func() { controller.MaxOrRandomLoadId(IDtoLoad) })
|
||||
assert.Panics(t, func() { controller.MaxOrRandomLoadId(IDtoLoad, pop) })
|
||||
|
||||
IDtoLoad[5] = 100.001
|
||||
assert.Equal(t, 5, controller.MaxOrRandomLoadId(IDtoLoad))
|
||||
assert.Equal(t, 5, controller.MaxOrRandomLoadId(IDtoLoad, pop))
|
||||
|
||||
IDtoLoad[3] = 100.
|
||||
assert.NotContains(t, []int{1, 3}, controller.MaxOrRandomLoadId(IDtoLoad))
|
||||
assert.NotContains(t, []int{1, 3}, controller.MaxOrRandomLoadId(IDtoLoad, pop))
|
||||
|
||||
IDtoLoad[7] = 100.001
|
||||
assert.Equal(t, 7, controller.MaxOrRandomLoadId(IDtoLoad, pop))
|
||||
|
||||
IDtoLoad[11] = 100.001
|
||||
rndCount := make(map[int]int)
|
||||
for range 100 {
|
||||
id := controller.MaxOrRandomLoadId(IDtoLoad)
|
||||
assert.NotContains(t, []int{1, 3}, id)
|
||||
assert.Contains(t, []int{5, 7}, id)
|
||||
id := controller.MaxOrRandomLoadId(IDtoLoad, pop)
|
||||
assert.NotContains(t, []int{1, 3, 5}, id)
|
||||
assert.Contains(t, []int{7, 11}, id)
|
||||
rndCount[id]++
|
||||
}
|
||||
assert.Greater(t, rndCount[5], 10)
|
||||
assert.Greater(t, rndCount[7], 10)
|
||||
assert.Greater(t, rndCount[11], 10)
|
||||
}
|
||||
|
||||
func TestSelectColUnloadGroup(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user