Skip to content

Commit 07cbf37

Browse files
committed
add test
1 parent b733fba commit 07cbf37

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/testthat/test-coord_sf.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,27 @@ test_that("coord_sf() throws error when limits are badly specified", {
371371
# throws error when limit's length is different than two
372372
expect_snapshot_error(ggplot() + coord_sf(ylim=1:3))
373373
})
374+
375+
test_that("coord_sf() can render with empty graticules", {
376+
377+
skip_if_not_installed("sf")
378+
# Skipping this test on CRAN as changes upstream in {sf} might affect
379+
# this test, i.e. when suddenly graticules *do* work
380+
skip_on_cran()
381+
382+
df <- sf::st_sf(
383+
g = sf::st_sfc(sf::st_point(
384+
# Out of bounds values for lon/lat
385+
c(-600, 1200)
386+
)),
387+
crs = 4326
388+
)
389+
390+
# Double-check graticule is empty, suppressing warnings about oob longlat values
391+
grat <- suppressWarnings(sf::st_graticule(df))
392+
expect_equal(nrow(grat), 0)
393+
394+
# Plot should render
395+
p <- suppressWarnings(layer_grob(ggplot(df) + geom_sf())[[1]])
396+
expect_length(p$x, 1)
397+
})

0 commit comments

Comments
 (0)