-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathtask_test.go
More file actions
46 lines (39 loc) · 730 Bytes
/
task_test.go
File metadata and controls
46 lines (39 loc) · 730 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
45
46
package main
import (
"fmt"
"strings"
"testing"
)
type task struct {
N int
Result string
}
func TestTask(t *testing.T) {
var taskItems = generateTasks()
for i := 0; i < len(taskItems); i++ {
t.Run(fmt.Sprintf("Test %d", i+1), func(t *testing.T) {
s := strings.Builder{}
solution(taskItems[i].N, "", 0, 0, &s)
if strings.TrimRight(s.String(), "\n") != taskItems[i].Result {
t.Errorf("Неверный ответ решения!\nОтвет: %s \nВерно: %s", s.String(), taskItems[i].Result)
}
})
}
}
func generateTasks() (tasks []task) {
tasks = append(
tasks,
task{
N: 3,
Result: `((()))
(()())
(())()
()(())
()()()`},
task{
N: 2,
Result: `(())
()()`},
)
return
}