-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathtask_test.go
More file actions
44 lines (39 loc) · 762 Bytes
/
Copy pathtask_test.go
File metadata and controls
44 lines (39 loc) · 762 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 main
import (
"fmt"
"testing"
)
type TestItemInput struct {
a, b int
}
type TestItem struct {
input struct{ a, b int }
output int
}
func TestTask(t *testing.T) {
tasks := generateTasks()
for i, v := range tasks {
t.Run(fmt.Sprintf("Test %d", i+1), func(t *testing.T) {
res := solution(v.input.a, v.input.b)
if res != v.output {
t.Errorf("Неверный ответ решения!\nОтвет: \n%v \nВерно: \n%v", res, v.output)
}
})
}
}
func generateTasks() []TestItem {
return []TestItem{
{
input: TestItemInput{a: 12, b: 90},
output: 102,
},
{
input: TestItemInput{a: 200, b: -200},
output: 0,
},
{
input: TestItemInput{a: 1000000000, b: 1000000000},
output: 2000000000,
},
}
}