-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathtask_test.go
114 lines (110 loc) · 2.22 KB
/
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package main
import (
"fmt"
"reflect"
"testing"
)
type task struct {
Input struct {
Docs,
Query []string
}
Result [][]int
}
func TestTask(t *testing.T) {
tasks := generateTasks()
for i := 0; i < len(tasks); i++ {
t.Run(fmt.Sprintf("Test %d", i+1), func(t *testing.T) {
res := testMain(tasks[i].Input.Docs, tasks[i].Input.Query)
if !reflect.DeepEqual(res, tasks[i].Result) {
t.Errorf("Неверный ответ решения!\nОтвет: %v \nВерно: %v", res, tasks[i].Result)
}
})
}
}
func generateTasks() []*task {
return []*task{
{
Input: struct{ Docs, Query []string }{
Docs: []string{
"i love coffee",
"coffee with milk and sugar",
"free tea for everyone",
},
Query: []string{
"i like black coffee without milk",
"everyone loves new year",
"mary likes black coffee without milk",
},
},
Result: [][]int{
{1, 2},
{3},
{2, 1},
},
},
{
Input: struct{ Docs, Query []string }{
Docs: []string{
"buy flat in moscow",
"rent flat in moscow",
"sell flat in moscow",
"want flat in moscow like crazy",
"clean flat in moscow on weekends",
"renovate flat in moscow",
},
Query: []string{
"flat in moscow for crazy weekends",
},
},
Result: [][]int{
{4, 5, 1, 2, 3},
},
},
{
Input: struct{ Docs, Query []string }{
Docs: []string{
"i like dfs and bfs",
"i like dfs dfs",
"i like bfs with bfs and bfs",
},
Query: []string{
"dfs dfs dfs dfs bfs",
},
},
Result: [][]int{
{3, 1, 2},
},
},
{
Input: struct{ Docs, Query []string }{
Docs: []string{
"tjegerxbyk pdvmj wulmqfrx",
"pndygsm dvjihmxr tcdtqsmfe",
"txamzxqzeq dxkxwq aua",
"hsciljsrdo fipazun kngi",
"xtkomk aua wulmqfrx ydkbncmzee",
"pndygsm cqvffye pyrhcxbcef",
"szyc uffqhayg ccktodig",
"ntr wpvlifrgjg htywpe",
"kngi tjegerxbyk zsnfd",
"tqilkkd gq qc fipazun",
},
Query: []string{
"dxkxwq htywpe",
"aua tjegerxbyk",
"xtkomk tjegerxbyk",
"szyc fipazun",
"xtkomk tjegerxbyk",
},
},
Result: [][]int{
{3, 8},
{1, 3, 5, 9},
{1, 5, 9},
{4, 7, 10},
{1, 5, 9},
},
},
}
}