-
Notifications
You must be signed in to change notification settings - Fork 16
/
geocode_test.go
97 lines (91 loc) · 2.07 KB
/
geocode_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
package geocode
import "testing"
func TestMoved(t *testing.T) {
t.Log(msg)
t.Fail()
}
func TestLookup(t *testing.T) {
req := &Request{
Address: "New York City",
Provider: GOOGLE,
}
resp, err := req.Lookup(nil)
if err != nil {
t.Fatalf("Lookup error: %v", err)
}
if s := resp.Status; s != "OK" {
t.Fatalf(`Status == %q, want "OK"`, s)
}
if l := len(resp.Results); l != 1 {
t.Fatalf("len(Results) == %d, want 1", l)
}
addr := "New York, NY, USA"
if a := resp.Found; a != addr {
t.Errorf("Address == %q, want %q", a, addr)
}
}
func TestLookupWithBounds(t *testing.T) {
req := &Request{
Address: "Winnetka",
Provider: GOOGLE,
}
bounds := &Bounds{Point{34.172684, -118.604794},
Point{34.236144, -118.500938}}
req.Bounds = bounds
resp, err := req.Lookup(nil)
if err != nil {
t.Fatalf("Lookup error: %v", err)
}
if s := resp.Status; s != "OK" {
t.Fatalf(`Status == %q, want "OK"`, s)
}
if l := len(resp.Results); l != 1 {
t.Fatalf("len(Results) == %d, want 1", l)
}
addr := "Winnetka, Los Angeles, CA, USA"
if a := resp.Found; a != addr {
t.Errorf("Address == %q, want %q", a, addr)
}
}
func TestLookupWithLanguage(t *testing.T) {
req := &Request{
Address: "札幌市",
Provider: GOOGLE,
}
req.Language = "ja"
resp, err := req.Lookup(nil)
if err != nil {
t.Fatalf("Lookup error: %v", err)
}
if s := resp.Status; s != "OK" {
t.Fatalf(`Status == %q, want "OK"`, s)
}
if l := len(resp.Results); l != 1 {
t.Fatalf("len(Results) == %d, want 1", l)
}
addr := "日本, 北海道札幌市"
if a := resp.Found; a != addr {
t.Errorf("Address == %q, want %q", a, addr)
}
}
func TestLookupWithRegion(t *testing.T) {
req := &Request{
Address: "Toledo",
Provider: GOOGLE,
}
req.Region = "es"
resp, err := req.Lookup(nil)
if err != nil {
t.Fatalf("Lookup error: %v", err)
}
if s := resp.Status; s != "OK" {
t.Fatalf(`Status == %q, want "OK"`, s)
}
if l := len(resp.Results); l != 1 {
t.Fatalf("len(Results) == %d, want 1", l)
}
addr := "Toledo, Spain"
if a := resp.Found; a != addr {
t.Errorf("Address == %q, want %q", a, addr)
}
}