Skip to content

Commit

Permalink
Fix vctrs optional tests (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot authored Jan 21, 2025
1 parent d23497a commit 0f39cf6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/testthat/test-plot.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

test_that("s2_plot works", {
skip_if_not_installed("vctrs")

x <- s2_data_countries()
expect_identical(s2_plot(x), x)
s2_plot(s2_data_cities(), add = TRUE)
Expand All @@ -10,6 +12,8 @@ test_that("s2_plot works", {
})

test_that("s2_plot works for all examples", {
skip_if_not_installed("vctrs")

for (name in names(s2_data_example_wkt)) {
geog <- as_s2_geography(s2_data_example_wkt[[name]])

Expand All @@ -22,6 +26,8 @@ test_that("s2_plot works for all examples", {
})

test_that("plot() works for vector classes", {
skip_if_not_installed("vctrs")

x <- as_s2_geography("POINT (0 1)")
expect_identical(plot(x), x)

Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-vctrs.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

test_that("s2_geography is a vctr", {
skip_if_not_installed("vctrs")

x <- new_s2_geography(list(NULL))
expect_true(vctrs::vec_is(x))
expect_identical(vctrs::vec_data(x), list(NULL))
Expand All @@ -8,6 +10,8 @@ test_that("s2_geography is a vctr", {
})

test_that("s2_cell is a vctr", {
skip_if_not_installed("vctrs")

x <- new_s2_cell(NA_real_)
expect_true(vctrs::vec_is(x))
expect_identical(vctrs::vec_data(x), NA_real_)
Expand All @@ -16,6 +20,8 @@ test_that("s2_cell is a vctr", {
})

test_that("s2_cell_union is a vctr", {
skip_if_not_installed("vctrs")

x <- new_s2_cell_union(list(NULL))
expect_true(vctrs::vec_is(x))
expect_identical(vctrs::vec_data(x), list(NULL))
Expand Down

0 comments on commit 0f39cf6

Please sign in to comment.