tests/testthat/test-assertions.R

test_that("is_existing_file", {
  miss <- basename(tempfile())
  withr::with_dir(
    tempdir(),
    expect_snapshot(
      error = TRUE,
      desc::desc(miss)
    )
  )
})

test_that("is_named_character_or_null", {
  x <- c(2, 3)
  expect_false(is_named_character_or_null(x))

  x <- "comment"
  expect_true(is_named_character_or_null(x))

  x <- c("comment1", "comment")
  expect_false(is_named_character_or_null(x))

  x <- c(comment1 = "comment1", comment2 = "comment")
  expect_true(is_named_character_or_null(x))

  x <- c(comment1 = "comment1", comment2 = NA)
  expect_false(is_named_character_or_null(x))

  x <- NULL
  expect_true(is_named_character_or_null(x))
})
r-lib/desc documentation built on June 11, 2025, 2:32 p.m.