tests/testthat/test-chk-numeric.R

test_that("vld_numeric", {
  expect_true(vld_numeric(1))
  expect_true(vld_numeric(matrix(1:3)))
  expect_true(vld_numeric(integer(0)))
  expect_false(vld_numeric(NULL))
  expect_false(vld_numeric("1"))
  expect_false(vld_numeric(NA))
})

test_that("chk_numeric", {
  expect_identical(chk_numeric(1), 1)
  expect_invisible(chk_numeric(1))
  expect_chk_error(chk_numeric("1"), "`\"1\"` must be numeric[.]$")
  expect_chk_error(chk_numeric("1", x_name = 1), "^1 must be numeric[.]$")
})

Try the chk package in your browser

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

chk documentation built on Oct. 6, 2023, 9:06 a.m.