-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlocation_test.go
63 lines (60 loc) · 1.13 KB
/
location_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
package main
import (
"testing"
)
func TestFixLocation(t *testing.T) {
tests := []struct {
Input string
Output []string
}{
{
Input: "Quimperlé",
Output: []string{"quimperlé"},
},
{
Input: "Paris",
Output: []string{"paris"},
},
{
Input: "Idf",
Output: []string{"ile-de-france"},
},
{
Input: "29 - 56/75 ou 92, 93 ",
Output: []string{"29", "56", "75", "92", "93"},
},
{
Input: "proche velizy",
Output: []string{"velizy"},
},
{
Input: "départements 22 et 1",
Output: []string{"22", "1"},
},
{
Input: "BOULOGNE BILL",
Output: []string{"boulogne billancourt"},
},
{
Input: "Nantes ou paris",
Output: []string{"nantes", "paris"},
},
{
Input: "Rhône",
Output: []string{"rhone-alpes"},
},
}
for _, test := range tests {
res := fixLocation(test.Input)
if len(res) != len(test.Output) {
t.Fatalf("candidate lengths do not match for '%s': %+v != %+v",
test.Input, res, test.Output)
}
for i, v := range test.Output {
if res[i] != v {
t.Fatalf("candidates do not match for '%s': %s != %s",
test.Input, v, res[i])
}
}
}
}