diff --git a/R/geocode.R b/R/geocode.R index 27b7a01..3cee8bb 100644 --- a/R/geocode.R +++ b/R/geocode.R @@ -119,9 +119,37 @@ geocode <- function(location, output = c("latlon", "latlona", "more", "all"), # geocode ply and out if(output == "latlon" || output == "latlona" || output == "more"){ - return(ldply(as.list(location), geocode, output = output, source = source, messaging = messaging, inject = inject)) + return( + ldply( + as.list(location), + geocode, + output = output, + source = source, + messaging = messaging, + force = force, + urlonly = urlonly, + override_limit = override_limit, + nameType = nameType, + ext = ext, + inject = inject + ) + ) } else { # output = all - return(llply(as.list(location), geocode, output = output, source = source, messaging = messaging, inject = inject)) + return( + llply( + as.list(location), + geocode, + output = output, + source = source, + messaging = messaging, + force = force, + urlonly = urlonly, + override_limit = override_limit, + nameType = nameType, + ext = ext, + inject = inject + ) + ) } } diff --git a/tests/testthat/test-geocode.R b/tests/testthat/test-geocode.R new file mode 100644 index 0000000..cb05198 --- /dev/null +++ b/tests/testthat/test-geocode.R @@ -0,0 +1,24 @@ +context("geocode") + +register_google(key = Sys.getenv("GOOGLE_GEOCODE_KEY")) + +test_that("geocode(urlonly = TRUE) returns url.", { + res <- geocode("Houston, Texas", urlonly = TRUE) + expect_is(res, "character") + expect_match(res, "Houston%2C%20Texas", fixed = TRUE) + expect_message(res, regexp = NA) # No "Source : ..." message +}) + +test_that("geocode(urlonly = TRUE) works with multiple locations.", { + res <- geocode(c("Houston, Texas", "Washington, DC"), urlonly = TRUE) + expect_match(res[[1, 1]], "Houston%2C%20Texas", fixed = TRUE) + expect_match(res[[2, 1]], "Washington%2C%20DC", fixed = TRUE) + expect_message(res, regexp = NA) # No "Source : ..." message, see #207 +}) + +test_that("geocode(ext) works with multiple locations.", { + res <- geocode(c("Houston", "Washington"), urlonly = TRUE, ext = "ca") + expect_match(res[[1]], ".ca", fixed = TRUE) + expect_match(res[[2, 1]], ".ca", fixed = TRUE) + expect_message(res, regexp = NA) # No "Source : ..." message, see #207 +})