MCPcopy
hub / github.com/grpc/grpc-go / newWeightedRandomTestSelector

Function newWeightedRandomTestSelector

interop/stress/client/main.go:124–130  ·  view source on GitHub ↗

newWeightedRandomTestSelector constructs a weightedRandomTestSelector with the given list of testCaseWithWeight.

(tests []testCaseWithWeight)

Source from the content-addressed store, hash-verified

122
123// newWeightedRandomTestSelector constructs a weightedRandomTestSelector with the given list of testCaseWithWeight.
124func 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
132func (selector weightedRandomTestSelector) getNextTest() string {
133 random := rand.IntN(selector.totalWeight)

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected