func TestDistance(t *testing.T) { fmt.Println("\n\n>>>>>>>>>>>>>>>>>>> TestDistance <<<<<<<<<<<<<<<<<<<<<<<<<<") fmt.Printf("------ Start TestDistance:\n%s\n", data.DisplayReports()) rlat := 37.151079 rlon := -121.602551 dist := 0.0 var ( dvals [5]float64 ) dvals[0] = 1788.1925774420406 dvals[1] = 32654.521037160826 dvals[2] = 24778.639830370197 dvals[3] = 32674.419251059397 dvals[4] = 32483.464206297744 for i, r := range *data.ReportDataTEST() { fmt.Printf("-- i: %d lat: %v lng: %v\n", i, r.LatitudeV, r.LongitudeV) dist = r.CalcDistance(rlat, rlon) fmt.Printf("ID: %v at %v:%v - distance: %v\n", r.ID, r.LatitudeV, r.LongitudeV, dist) if i < len(dvals) { if dist != dvals[i] { t.Errorf("Wrong distance: %v should be: %v", dist, dvals[i]) } } else { t.Errorf("Missing test value for Reports[%d]", i) } } }
func TestAddReport2(t *testing.T) { fmt.Println("\n\n>>>>>>>>>>>>>>>>>>> TestAddReport <<<<<<<<<<<<<<<<<<<<<<<<<<") newRpt := data.BaseReport{ DateCreated: data.NewCustomTime("2015-02-20T13:45:30"), DateUpdated: data.NewCustomTime("2015-02-25T09:00:01.000"), DeviceType: "IPHONE", DeviceModel: "5S", DeviceID: "1111", RequestType: "Graffiti Removal", RequestTypeID: "10", ImageUrl: "http://www.citysourced.com/image_200.png", ImageUrlXl: "http://www.citysourced.com/image_xl_200.png", ImageUrlLg: "http://www.citysourced.com/image_lg_200.png", ImageUrlMd: "http://www.citysourced.com/image_md_200.png", ImageUrlSm: "http://www.citysourced.com/image_sm_200.png", ImageUrlXs: "http://www.citysourced.com/image_xs_200.png", City: "San Jose", State: "CA", ZipCode: "95101", Latitude: "37.336240", Longitude: "-121.885862", Directionality: "25 N NW", Description: "New graffiti request - someone painted flames on Flames Restaurant", AuthorNameFirst: "Wiley", AuthorNameLast: "Coyote", AuthorEmail: "", AuthorTelephone: "", AuthorIsAnonymous: "true", UrlDetail: "http://www.citysourced.com/report/100/graffiti", UrlShortened: "", StatusType: "Open", } data.Append(newRpt) fmt.Printf("------ After add:\n%s\n", data.DisplayReports()) }
func TestReadData(t *testing.T) { fmt.Println("\n\n>>>>>>>>>>>>>>>>>>> TestReadData <<<<<<<<<<<<<<<<<<<<<<<<<<") // Load Data if err := data.Init("../data.json"); err != nil { t.Errorf("Error %q occurred when loading the data.", err) } fmt.Printf("%v", data.DisplayReports()) }