-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathtask_test.go
More file actions
36 lines (31 loc) · 698 Bytes
/
task_test.go
File metadata and controls
36 lines (31 loc) · 698 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
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(`6 3`), "13"},
{strings.NewReader(`7 7`), "32"},
{strings.NewReader(`2 2`), "1"},
{strings.NewReader(`62 44`), "535806680"},
}
}