...
1
16
17 package parallelize
18
19 import (
20 "fmt"
21 "testing"
22 )
23
24 func TestChunkSize(t *testing.T) {
25 tests := []struct {
26 input int
27 wantOutput int
28 }{
29 {
30 input: 32,
31 wantOutput: 3,
32 },
33 {
34 input: 16,
35 wantOutput: 2,
36 },
37 {
38 input: 1,
39 wantOutput: 1,
40 },
41 {
42 input: 0,
43 wantOutput: 1,
44 },
45 }
46
47 for _, test := range tests {
48 t.Run(fmt.Sprintf("%d", test.input), func(t *testing.T) {
49 if chunkSizeFor(test.input, DefaultParallelism) != test.wantOutput {
50 t.Errorf("Expected: %d, got: %d", test.wantOutput, chunkSizeFor(test.input, DefaultParallelism))
51 }
52 })
53 }
54 }
55
View as plain text