Skip to content

Commit 4d273ef

Browse files
committed
Add tests for DATAPTR
1 parent bbadaa1 commit 4d273ef

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/testthat/test-s2-geography.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,18 @@ test_that("wk crs and geodesic methods are defined", {
275275

276276
expect_error(wk::wk_set_geodesic(geog, FALSE), "Can't set geodesic")
277277
})
278+
279+
test_that("s2_geography vectors support elementwise assignment", {
280+
x <- as_s2_geography(c("POINT (0 0)", "POINT (90 0)"))
281+
x[2] <- as_s2_geography(c("POINT (45 45)"))
282+
283+
expect_wkt_equal(x, c("POINT (0 0)", "POINT (45 45)"))
284+
})
285+
286+
test_that("DATAPTR can be obtained for s2_geography", {
287+
Rcpp::cppFunction("double get_dataptr(SEXP obj) {
288+
return (double) ((uintptr_t) DATAPTR_RO(obj));
289+
}")
290+
291+
expect_no_error(get_dataptr(as_s2_geography("POINT (0 0)")))
292+
})

0 commit comments

Comments
 (0)