tests/testthat/test-chk-chr.R

test_that("vld_chr", {
  rlang::local_options(lifecycle_verbosity = "quiet")

  lifecycle::expect_deprecated(chk_chr(""))

  expect_false(vld_chr(character(0)))
  expect_true(vld_chr(NA_character_))
  expect_true(vld_chr(""))
  expect_true(vld_chr("a"))
  expect_false(vld_chr(c("a", "b")))
})

test_that("chk_chr", {
  rlang::local_options(lifecycle_verbosity = "quiet")

  lifecycle::expect_deprecated(chk_chr(""))

  expect_identical(chk_chr(""), "")
  expect_invisible(chk_chr(""))
  expect_chk_error(chk_chr(1), "^`1` must be a character scalar[.]$")
  expect_chk_error(chk_chr(1, x_name = "''"), "^'' must be a character scalar[.]$")
})

Try the chk package in your browser

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

chk documentation built on Sept. 11, 2024, 7:34 p.m.