tests/testthat/test_bad_input.R

test_that("catch bad inputs", {
  cat("\n\n", as.character(Sys.time()), "--------------- test_bad_input.R ---------------\n\n")
  mpm <- money_priming_sub()

  # passing only affirmatives should result in an informative error
  mpm <- mpm |> mutate(affirm = yi / sqrt(vi) > qnorm(.975))
  aff <- mpm |> filter(affirm)
  expect_error(phacking_meta(aff$yi, aff$vi, parallelize = FALSE))

  # passing sei or vi vector whose length doesn't match yi should throw error
  expect_error(phacking_meta(mpm$yi, 2, parallelize = FALSE))

  # passing negative sei should result in error
  expect_error(phacking_meta(mpm$yi, sei = -sqrt(mpm$vi), parallelize = FALSE))
})

Try the phacking package in your browser

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

phacking documentation built on July 26, 2023, 5:22 p.m.