-
Notifications
You must be signed in to change notification settings - Fork 15
/
phonegeocode_test.go
51 lines (44 loc) · 1007 Bytes
/
phonegeocode_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
package phonegeocode
import (
"testing"
)
func TestThingsThatAreFound(t *testing.T) {
cases := []struct {
number, country string
}{
{"+4479991113332", "GB"},
{"+1807142342342", "CA"},
{"+1781234555552", "US"},
{"+3462233455552", "ES"},
{"+3538523523455", "IE"},
{"+19425242343333", "US"},
{"+1786822211132", "US"},
{"+34634343434443", "ES"},
{"+190572354235235", "CA"},
}
p := New()
for _, tc := range cases {
cc, err := p.Country(tc.number)
if err != nil {
t.Errorf("Not expecting number '%s' to yield an error; got %v", tc.number, err)
}
if cc != tc.country {
t.Errorf("Number '%s' did not match expected CC '%s'; got '%s'", tc.number, tc.country, cc)
}
}
}
func TestThingsThatAreNotFound(t *testing.T) {
cases := []struct {
number string
}{
{"+9915155235325"},
{"+898235265"},
}
p := New()
for _, tc := range cases {
_, err := p.Country(tc.number)
if err == nil {
t.Errorf("Expecting number '%s' to yield an error", tc.number)
}
}
}