Skip to content

Commit 9664e53

Browse files
authored
fix: out of range with 1 test on 3 buckets (#5)
1 parent ed88341 commit 9664e53

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

main.go

+4
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ func filterTests(tests *[]testing.InternalTest, bucketIndex, bucketCount int, di
155155
perBucket := int(math.Ceil(float64(len(*tests)) / float64(bucketCount)))
156156

157157
from := bucketIndex * perBucket
158+
if from >= len(*tests) { // out of bounds
159+
*tests = (*tests)[:0]
160+
return
161+
}
158162
to := from + perBucket
159163

160164
if to > len(*tests)-1 {

main_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ func Test_filterTestsBuckets(t *testing.T) {
183183
2,
184184
[]int{1, 0},
185185
},
186+
{
187+
"1/3",
188+
1,
189+
3,
190+
[]int{1, 0, 0},
191+
},
186192
{
187193
"3/2",
188194
3,

0 commit comments

Comments
 (0)