tests/testthat/test-castingErrorsAndWarnings.R

context("finishArgCheck Errors and Warnings")

test_that("Cast Appropriate Error",
{
  Check <- newArgCheck()
  addError("New Error",
           Check)
  expect_error(finishArgCheck(Check),
               "1: New Error")

})

test_that("Cast Appropriate Warning",
{
  Check <- newArgCheck()
  addWarning("New Warning",
             Check)
  expect_warning(finishArgCheck(Check),
                 "1: New Warning")
})

test_that("Cast Simultaneous Error and Warning",
{
  Check <- newArgCheck()
  addError("New Error",
           Check)
  addWarning("New Warning",
             Check)
  expect_warning(expect_error(finishArgCheck(Check),
                              "1: New Error"),
                 "1: New Warning")
})

Try the ArgumentCheck package in your browser

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

ArgumentCheck documentation built on May 2, 2019, 9:15 a.m.