tests/testthat/test-utils.R

test_that("check_factor() fails when needed", {
  expect_equal(check_factor("x"), factor("x"))
  expect_equal(check_factor(factor("x")), factor("x"))

  expect_snapshot(error = TRUE, {
    check_factor(NA)
  })
})

test_that("check_factor_list() checks its inputs", {
  expect_snapshot(error = TRUE, {
    check_factor_list(1)
    check_factor_list(list(1))
  })
})

Try the forcats package in your browser

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

forcats documentation built on Feb. 16, 2023, 8:57 p.m.