tests/testthat/helper_test_nonfinite.R

test.nonfinite.in.data <- function(data, name.col, fct, call.args, regexp="The above errors were encountered!"){
  data[5, name.col] <- NA_real_
  call.args <- modifyList(call.args, list(data= data))
  expect_error(do.call(what = fct, args=call.args), regexp = regexp)

  data[5, name.col] <- Inf
  call.args <- modifyList(call.args, list(data= data))
  expect_error(do.call(what = fct, args=call.args), regexp = regexp)

  data[5, name.col] <- -Inf
  call.args <- modifyList(call.args, list(data= data))
  expect_error(do.call(what = fct, args=call.args), regexp = regexp)

  data[5, name.col] <- NaN
  call.args <- modifyList(call.args, list(data= data))
  expect_error(do.call(what = fct, args=call.args), regexp = regexp)
}

Try the REndo package in your browser

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

REndo documentation built on Sept. 8, 2023, 5:53 p.m.