tests/testthat/test-get_fisher.R

test_that("get_fisher computes p-value correctly", {
  # Mocked contingency table
  contin_table <- matrix(c(10, 5, 3, 7), nrow = 2)

  # Test Fisher's exact test with specific indices
  p_value1 <- get_fisher(contin_table, 1, 1, FALSE)
  p_value2 <- get_fisher(contin_table, 1, 1, TRUE)

  # Test that p-value is numeric
  expect_type(p_value1, "double")
  expect_type(p_value2, "double")
  expect_length(p_value1, 1)
  expect_length(p_value2, 1)
  expect_true(p_value1 >= 0 && p_value1 <= 1)
  expect_true(p_value2 >= 0 && p_value2 <= 1)
})

Try the MDDC package in your browser

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

MDDC documentation built on April 11, 2025, 5:45 p.m.