newWeightedRandomTestSelector constructs a weightedRandomTestSelector with the given list of testCaseWithWeight.
(tests []testCaseWithWeight)
| 122 | |
| 123 | // newWeightedRandomTestSelector constructs a weightedRandomTestSelector with the given list of testCaseWithWeight. |
| 124 | func newWeightedRandomTestSelector(tests []testCaseWithWeight) *weightedRandomTestSelector { |
| 125 | var totalWeight int |
| 126 | for _, t := range tests { |
| 127 | totalWeight += t.weight |
| 128 | } |
| 129 | return &weightedRandomTestSelector{tests, totalWeight} |
| 130 | } |
| 131 | |
| 132 | func (selector weightedRandomTestSelector) getNextTest() string { |
| 133 | random := rand.IntN(selector.totalWeight) |