-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
task_test.go
68 lines (63 loc) · 922 Bytes
/
task_test.go
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
"io"
"strings"
"testing"
)
type TestItem struct {
input io.Reader
output string
}
func TestTask(t *testing.T) {
tasks := generateTasks()
for i, v := range tasks {
t.Run(fmt.Sprintf("Test %d", i+1), func(t *testing.T) {
buf := strings.Builder{}
Solution(v.input, &buf)
if buf.String() != v.output {
t.Errorf("Неверный ответ решения!\nОтвет: \n%v \nВерно: \n%v", buf.String(), v.output)
}
})
}
}
func generateTasks() []TestItem {
return []TestItem{
{strings.NewReader(`4 4
1 2 5
1 3 6
2 4 8
3 4 3
`), "19"},
{strings.NewReader(`3 3
1 2 1
1 2 2
2 3 1
`), "3"},
{strings.NewReader(`2 0
`), "Oops! I did it again"},
{strings.NewReader(`1 0
`), "0"},
{strings.NewReader(`10 20
9 10 4
2 2 4
4 2 8
10 5 3
1 10 6
7 4 2
10 10 6
3 7 4
8 9 4
8 10 7
6 10 10
2 8 8
3 8 1
3 10 3
9 5 8
10 10 2
1 8 1
10 1 5
3 6 10
9 10 8
`), "69"}}
}