Chris Broadfoot | 5d51656 | 2015-08-25 20:43:02 | [diff] [blame] | 1 | // Copyright 2014 Google Inc. All rights reserved. |
| 2 | // Use of this source code is governed by the Apache 2.0 |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
Dave Day | 349848c | 2014-03-27 05:47:20 | [diff] [blame] | 5 | package appengine |
| 6 | |
| 7 | import ( |
| 8 | "testing" |
| 9 | ) |
| 10 | |
| 11 | func TestValidGeoPoint(t *testing.T) { |
| 12 | testCases := []struct { |
| 13 | desc string |
| 14 | pt GeoPoint |
| 15 | want bool |
| 16 | }{ |
| 17 | { |
| 18 | "valid", |
| 19 | GeoPoint{67.21, 13.37}, |
| 20 | true, |
| 21 | }, |
| 22 | { |
| 23 | "high lat", |
| 24 | GeoPoint{-90.01, 13.37}, |
| 25 | false, |
| 26 | }, |
| 27 | { |
| 28 | "low lat", |
| 29 | GeoPoint{90.01, 13.37}, |
| 30 | false, |
| 31 | }, |
| 32 | { |
| 33 | "high lng", |
| 34 | GeoPoint{67.21, 182}, |
| 35 | false, |
| 36 | }, |
| 37 | { |
| 38 | "low lng", |
| 39 | GeoPoint{67.21, -181}, |
| 40 | false, |
| 41 | }, |
| 42 | } |
| 43 | |
| 44 | for _, tc := range testCases { |
| 45 | if got := tc.pt.Valid(); got != tc.want { |
| 46 | t.Errorf("%s: got %v, want %v", tc.desc, got, tc.want) |
| 47 | } |
| 48 | } |
| 49 | } |