tests/testthat/test-erase_after.R

skip_on_os("mac")
# forward_list
testthat::test_that("forward_list erase_after integer", {
  v <- cpp_forward_list(4:9)
  testthat::expect_invisible(erase_after(v, from = 2, to = 4))
  testthat::expect_equal(to_r(v), c(4:5, 8:9))
})
testthat::test_that("forward_list erase_after double", {
  v <- cpp_forward_list(seq.int(1, 2, 0.5))
  testthat::expect_invisible(erase_after(v, from = 1, to = 3))
  testthat::expect_equal(to_r(v), 1)
})
testthat::test_that("forward_list erase_after string", {
  v <- cpp_forward_list(c("hello", "there", "world"))
  testthat::expect_invisible(erase_after(v, from = 1, to = 3))
  testthat::expect_equal(to_r(v), "hello")
})
testthat::test_that("forward_list erase_after boolean", {
  v <- cpp_forward_list(c(FALSE, TRUE))
  testthat::expect_invisible(erase_after(v, from = 1, to = 2))
  testthat::expect_equal(to_r(v), FALSE)
})

Try the cppcontainers package in your browser

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

cppcontainers documentation built on Sept. 9, 2025, 5:55 p.m.