-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathsolution_test.go
More file actions
39 lines (35 loc) · 735 Bytes
/
solution_test.go
File metadata and controls
39 lines (35 loc) · 735 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
package main
import (
"fmt"
"reflect"
"testing"
)
type TestItemInput struct {
nums [][]int
}
type TestItem struct {
input TestItemInput
output [][]int
}
func TestTask(t *testing.T) {
for i, v := range generateTasks() {
t.Run(fmt.Sprintf("Test %d", i+1), func(t *testing.T) {
res := merge(v.input.nums)
if !reflect.DeepEqual(res, v.output) {
t.Errorf("Wrong test.\nOutput: \n%v \nExpected: \n%v", res, v.output)
}
})
}
}
func generateTasks() []TestItem {
return []TestItem{
{
input: TestItemInput{nums: [][]int{{1, 3}, {2, 6}, {8, 10}, {15, 18}}},
output: [][]int{{1, 6}, {8, 10}, {15, 18}},
},
{
input: TestItemInput{nums: [][]int{{1, 4}, {4, 5}}},
output: [][]int{{1, 5}},
},
}
}