tests/testthat/test-not-available.R

test_that("not_available() works", {
  expect_error(get_not_available(), NA)
  expect_error(get_not_available("foo"), class = "getNotAvailableError")

  val <- struct(NA, "foo")
  set_not_available("foo", val)

  expect_identical(get_not_available("foo"), val)
  expect_identical(not_available("foo", 2), c(NA, NA))
  expect_identical(not_available(val, 2), c(NA, NA))

  expect_true(is.na(not_available("Date", 1)))

  set_not_available("foo", NULL)
  set_not_available("foo_fun", function() NULL)
  expect_error(get_not_available("foo_fun"), class = "getNotAvailableTypeError")

  # reset list
  options(mark.na_list = NULL)
  expect_identical(get_na_list(), na_list)
})

Try the mark package in your browser

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

mark documentation built on May 29, 2024, 5:13 a.m.