Permalink
Browse files

add TestLookupWithBounds, TestLookupWithLanguage, and TestLookupWithR…

…egion
  • Loading branch information...
1 parent 0c0f3d4 commit bdad8e61b0cc13156155e169192e632e1c77a1bb @shawnps committed Jun 26, 2012
Showing with 65 additions and 0 deletions.
  1. +65 −0 geocode_test.go
View
@@ -21,3 +21,68 @@ func TestLookup(t *testing.T) {
t.Errorf("Address == %q, want %q", a, addr)
}
}
+
+func TestLookupWithBounds(t *testing.T) {
+ req := &Request{
+ Address: "Winnetka",
+ }
+ 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.Results[0].Address; a != addr {
+ t.Errorf("Address == %q, want %q", a, addr)
+ }
+}
+
+func TestLookupWithLanguage(t *testing.T) {
+ req := &Request{
+ Address: "札幌市",
+ }
+ 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.Results[0].Address; a != addr {
+ t.Errorf("Address == %q, want %q", a, addr)
+ }
+}
+
+func TestLookupWithRegion(t *testing.T) {
+ req := &Request{
+ Address: "Toledo",
+ }
+ 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.Results[0].Address; a != addr {
+ t.Errorf("Address == %q, want %q", a, addr)
+ }
+}

0 comments on commit bdad8e6

Please sign in to comment.