tests/testthat/test-add_geometry.R

test_that("retrieves geometry column", {
  locations <- nc_type_example_2$county[1:30]
  geom <- get_geometry(locations, feature_type = "sf.nc")
  expect_length(geom, 30L)
  expect_s3_class(geom, "sfc")
})

test_that("add_geometry supports tidy evaluation", {
  x <- add_geometry(
    head(nc_type_example_2, n = 30),
    county,
    feature_type = "sf.nc"
  )
  expect_length(sf::st_geometry(x), 30L)
})

test_that("feature type can be guessed", {
  x <- add_geometry(nc_type_example_2, county)
  expect_length(sf::st_geometry(x), nrow(nc_type_example_2))
})

Try the cartographer package in your browser

Any scripts or data that you put into this service are public.

cartographer documentation built on March 19, 2026, 5:07 p.m.