This repository was archived by the owner on Sep 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathgeo_test.go
More file actions
132 lines (124 loc) · 2.22 KB
/
Copy pathgeo_test.go
File metadata and controls
132 lines (124 loc) · 2.22 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package api
import (
"fmt"
"testing"
)
func TestHasPartial(t *testing.T) {
tests := []struct {
Results GeocodeResults
Expected bool
}{
{
Results: GeocodeResults{
GeocodeResult{
Partial: false,
},
GeocodeResult{
Partial: true,
},
},
Expected: true,
},
{
Results: GeocodeResults{
GeocodeResult{
Partial: false,
},
GeocodeResult{
Partial: false,
},
},
Expected: false,
},
}
for _, test := range tests {
partial := test.Results.HasPartial()
if partial != test.Expected {
t.Errorf("Expected [%v] to be [%v] but got [%v]", test.Results, test.Expected, partial)
}
}
}
func TestHasErrors(t *testing.T) {
tests := []struct {
Results GeocodeResults
Expected bool
}{
{
Results: GeocodeResults{
GeocodeResult{
Error: "Foo",
},
GeocodeResult{
Error: "",
},
},
Expected: true,
},
{
Results: GeocodeResults{
GeocodeResult{
Error: "",
},
},
Expected: false,
},
}
for _, test := range tests {
partial := test.Results.HasErrors()
if partial != test.Expected {
t.Errorf("Expected [%v] to be [%v] but got [%v]", test.Results, test.Expected, partial)
}
}
}
func TestEmpty(t *testing.T) {
tests := []struct {
Results GeocodeResults
Expected bool
}{
{
Results: GeocodeResults{},
Expected: true,
},
{
Results: GeocodeResults{
GeocodeResult{
Error: "",
},
},
Expected: false,
},
}
for _, test := range tests {
partial := test.Results.Empty()
if partial != test.Expected {
t.Errorf("Expected [%v] to be [%v] but got [%v]", test.Results, test.Expected, partial)
}
}
}
func TestResultsString(t *testing.T) {
result := GeocodeResult{
Street: "123",
Street2: "APT 1",
City: "Arlington",
State: "VA",
County: "ATown",
Zipcode: "22202",
Formatted: "",
Partial: false,
Error: "",
}
expected := fmt.Sprintf("Street: %s\nStreet2: %s\nCity: %s\nState: %s\nZipcode: %s\nCounty: %s\nCountry: %s\nPartial: %v\nFormatted: %s",
"123",
"APT 1",
"Arlington",
"VA",
"22202",
"ATown",
"",
false,
"",
)
if result.String() != expected {
t.Errorf("Expected [%v] to be [%v]", result.String(), expected)
}
}