tests/testthat/test-vctrs.R

test_that("s2_geography is a vctr", {
  x <- new_s2_geography(list(NULL))
  expect_true(vctrs::vec_is(x))
  expect_identical(vctrs::vec_data(x), list(NULL))
  expect_identical(vctrs::vec_restore(list(NULL), x), x)
  expect_identical(vctrs::vec_ptype_abbr(x), class(x)[1])
})

test_that("s2_cell is a vctr", {
  x <- new_s2_cell(NA_real_)
  expect_true(vctrs::vec_is(x))
  expect_identical(vctrs::vec_data(x), NA_real_)
  expect_identical(vctrs::vec_restore(NA_real_, x), x)
  expect_identical(vctrs::vec_ptype_abbr(x), "s2cell")
})

test_that("s2_cell_union is a vctr", {
  x <- new_s2_cell_union(list(NULL))
  expect_true(vctrs::vec_is(x))
  expect_identical(vctrs::vec_data(x), list(NULL))
  expect_identical(vctrs::vec_restore(list(NULL), x), x)
  expect_identical(vctrs::vec_ptype_abbr(x), "s2cellunion")
})

Try the s2 package in your browser

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

s2 documentation built on May 31, 2023, 9:33 p.m.