tests/testthat/test-c.R

test_that("uses tidy_dots", {
  fs <- list(factor("a"), factor("b"))
  fab <- factor(c("a", "b"))

  expect_equal(fct_c(!!!fs), fab)
  expect_equal(fct_c(fs[[1]], fs[[2]]), fab)
})

test_that("all inputs must be factors", {
  expect_error(fct_c("a"), "must be factors")
})

test_that("empty input yields empty factor", {
  expect_equal(fct_c(), factor())
})

test_that("validates inputs", {
  expect_snapshot(error = TRUE, {
    fct_c(1)

    fct_unify(list(1))
    fct_unify(list(factor()), levels = 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.