-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathg_test.go
More file actions
44 lines (40 loc) · 997 Bytes
/
Copy pathg_test.go
File metadata and controls
44 lines (40 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package g
import "testing"
// TestParallelTasks tests the ParallelTasks function.
func TestParallelTasks(t *testing.T) {
maxParallelTasks = 10 // set to whatever value you need
parallelTasks = 1 // initialize to a default value
tests := []struct {
name string
input []int
expected int
}{
{
name: "No parameters",
input: nil,
expected: 1, // should return the default value
},
{
name: "Zero sum",
input: []int{-5, 5},
expected: 1, // should return minimum value of 1
},
{
name: "Positive sum less than max",
input: []int{3, 2},
expected: 5, // should return the sum
},
{
name: "Positive sum greater than max",
input: []int{15, 10},
expected: 10, // should return maxParallelTasks
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ParallelTasks(tt.input...); got != tt.expected {
t.Errorf("ParallelTasks() = %v, want %v", got, tt.expected)
}
})
}
}