From a8f0dbe23959cfd7cecaf38c9d0478b56807bf3f Mon Sep 17 00:00:00 2001 From: Dax Kellie Date: Wed, 3 Apr 2024 13:08:50 +1100 Subject: [PATCH] Add tests for type `radius` in `galah_geolocate()` #216 --- tests/testthat/test-galah_geolocate.R | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-galah_geolocate.R b/tests/testthat/test-galah_geolocate.R index e1381a94..e9917ced 100644 --- a/tests/testthat/test-galah_geolocate.R +++ b/tests/testthat/test-galah_geolocate.R @@ -8,9 +8,23 @@ test_that("galah_geolocate works when type is set to polygon", { expect_match(galah_geolocate(wkt, type = "polygon"), "MULTIPOLYGON") }) -test_that("galah_geolocate switches to use galah_bbox when type is set to bbox", { +test_that("galah_geolocate switches to use galah_bbox when `type = bbox`", { wkt <- "POLYGON((142.36228 -29.00703,142.74131 -29.00703,142.74131 -29.39064,142.36228 -29.39064,142.36228 -29.00703))" obj_sf <- wkt |> sf::st_as_sfc() expect_error(galah_geolocate(wkt, type = "bbox")) expect_match(galah_geolocate(obj_sf, type = "bbox"), "MULTIPOLYGON") }) + +test_that("galah_geolocate switches to use galah_radius when `type = radius`", { + wkt <- "POLYGON((142.36228 -29.00703,142.74131 -29.00703,142.74131 -29.39064,142.36228 -29.39064,142.36228 -29.00703))" + obj_sf <- wkt |> sf::st_as_sfc() + expect_error(galah_geolocate(wkt, type = "radius"), "Missing") + expect_error(galah_geolocate(obj_sf, type = "radius"), "Invalid spatial object") + expect_equal(galah_geolocate(lat = -33.66741, + lon = 151.3174, + radius = 2, + type = "radius"), + list(lat = -33.66741, + lon = 151.3174, + radius = 2)) +})