tests/testthat/test-calc_p_value.R

test_that("calc_p_value() works", {
  expect_lt(visage::calc_p_value(1, c(1), method = "simulate"), 1)
})

test_that("calc_p_value() passes tol = 0.01 for n_detect = 1, n_eval = 1, n_sel = 1 (if not, increase n_sim)", {
  set.seed(10086)
  expect_lt(abs(visage::calc_p_value(1, c(1), method = "simulate") - 0.05), 0.01)
})

test_that("calc_p_value() supports cache", {
  e <- new.env()
  p_value <- visage::calc_p_value(1, c(1), cache_env = e, method = "simulate")
  p_value <- visage::calc_p_value(1, c(1), cache_env = e, method = "simulate")
  expect_equal(p_value, p_value)
})

test_that("calc_p_value() works for n_detect = 0", {
  expect_equal(visage::calc_p_value(0, c(1), method = "simulate"), 1)
})
TengMCing/visage documentation built on Aug. 28, 2024, 3:27 p.m.