tests/testthat/test-chkor-vld.R

test_that("chkor_vld", {
  expect_null(chkor_vld())
  expect_invisible(chkor_vld())
  expect_null(chkor_vld(vld_flag(TRUE)))
  expect_null(chkor_vld(vld_flag(TRUE), vld_number(1)))
  expect_null(chkor_vld(vld_flag(1), vld_flag(TRUE)))
  expect_chk_error(chkor_vld(vld_flag(1)), "^`1` must be a flag [(]TRUE or FALSE[)][.]$")
  expect_chk_error(chkor_vld(vld_flag(1), vld_flag(1)), "^`1` must be a flag [(]TRUE or FALSE[)][.]$")
  expect_chk_error(chkor_vld(vld_flag(1), vld_flag(2)), "^At least one of the following conditions must be met:\n[*] `1` must be a flag [(]TRUE or FALSE[)][.]\n[*] `2` must be a flag [(]TRUE or FALSE[)][.]$")
  expect_chk_error(chkor_vld(vld_flag(1), vld_flag(2), vld_flag(0)), "^At least one of the following conditions must be met:\n[*] `1` must be a flag [(]TRUE or FALSE[)].\n[*] `2` must be a flag [(]TRUE or FALSE[)].\n[*] `0` must be a flag [(]TRUE or FALSE[)].$")
})

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.