Skip to content

Commit

Permalink
extendrtests: added null externalptr test
Browse files Browse the repository at this point in the history
  • Loading branch information
CGMossa committed Mar 2, 2024
1 parent eac2dea commit 5bcdb37
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/extendrtests/tests/testthat/test-classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ test_that("Issue 431: Restore struct as ExternalPtr", {
y <- MyClass$restore_from_robj(x)
expect_equal(x$a(), y$a())
})

test_that("Error nicely with null externalptr", {
x <- MyClass$new()
x$set_a(42L)
null_x <- new("externalptr") # no attributes, null-ptr
attributes(null_x) <- attributes(x)
expect_error(
null_x$set_a(44L)
)
})

0 comments on commit 5bcdb37

Please sign in to comment.