tests/testthat/test-commify.R

context("Test the commify() function")
test_that("List of strings is correct", {
  expect_error(commify())
  expect_error(commify(1))
  expect_error(commify(c(1, 2)))
  expect_error(commify(c("a", "b"), 1))
  expect_equal(commify(c("a", "b", "c"), use_and = TRUE), "a, b, and c")
  expect_equal(commify(c("a", "b", "c"), use_and = FALSE), "a, b, c")
  expect_equal(commify(c("a", "b")), "a and b")
  expect_equal(commify(c("a", "b"), use_and = FALSE), "a and b")
})
pbs-assess/gfutilities documentation built on Sept. 18, 2023, 7:57 a.m.