Initial commit
This commit is contained in:
43
worker/worker_test.go
Normal file
43
worker/worker_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package worker
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWorker_findMax(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
in [10]int
|
||||
out [3]int
|
||||
}{
|
||||
{
|
||||
in: [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
out: [3]int{8, 9, 10},
|
||||
},
|
||||
{
|
||||
in: [10]int{10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
|
||||
out: [3]int{8, 9, 10},
|
||||
},
|
||||
{
|
||||
in: [10]int{9, 7, 6, 10, 5, 4, 3, 8, 1},
|
||||
out: [3]int{8, 9, 10},
|
||||
},
|
||||
}
|
||||
|
||||
for idx, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(strconv.Itoa(idx), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
w := &Worker{}
|
||||
|
||||
if got := w.findMax(tt.in); !reflect.DeepEqual(got, tt.out) {
|
||||
t.Errorf("findMax() = %v, want %v", got, tt.out)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user