tests/testthat/test-helpers-misc.R

test_that("last_col() selects last argument with offset", {
  vars <- letters[1:3]
  expect_identical(last_col(0, vars), 3L)
  expect_identical(last_col(2, vars), 1L)
})

test_that("last_col() checks its inputs", {
  expect_snapshot(error = TRUE, {
    last_col(Inf, letters[1:3])
    last_col(3, letters[1:3])
    last_col(0, character())
    last_col(1:2, letters[1:3])
  })
})

Try the tidyselect package in your browser

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

tidyselect documentation built on May 29, 2024, 6:07 a.m.