tests/testthat/test-function-lastElement.R

test_that("lastElement() works", {

  f <- kwb.utils:::lastElement

  expect_error(f())

  expect_identical(f(list(a = 1, b = 2)), 2)
  
  expect_identical(
    resetRowNames(f(data.frame(a = 1:2, b = 2:3))), 
    data.frame(a = 2L, b = 3L)
  )
  
  expect_identical(f(c("a", "b")), "b")
})
KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.