Skip to content

Commit

Permalink
tests for as..vector
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Aug 31, 2024
1 parent c6be337 commit 43d9e17
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/testthat/test-p_direction.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ test_that("p_direction", {
# converstion into frequentist p-value works
p <- p_direction(x, as_p = TRUE)
expect_equal(as.numeric(p), pd_to_p(pd$pd), tolerance = 0.1)
expect_equal(as.vector(p), pd_to_p(pd$pd), tolerance = 0.1)
# return NA
expect_true(is.na(as.numeric(p_direction(c(x, NA), remove_na = FALSE))))
# works
expect_equal(as.numeric(p_direction(c(x, NA))), 0.8413, tolerance = 0.1)
expect_equal(as.vector(p_direction(c(x, NA))), 0.8413, tolerance = 0.1)
# error if only NA
expect_error(p_direction(c(NA_real_, NA_real_)), regex = "No valid values found")
expect_equal(as.numeric(p_direction(x, method = "kernel")), 0.842, tolerance = 0.1)
Expand Down Expand Up @@ -56,6 +58,11 @@ test_that("p_direction", {
as.numeric(p_direction(m, effects = "all", as_p = TRUE)),
tolerance = 1e-3
)
expect_equal(
p_direction(m, effects = "all", as_p = TRUE)$p,
as.vector(p_direction(m, effects = "all", as_p = TRUE)),
tolerance = 1e-3
)
})


Expand Down

0 comments on commit 43d9e17

Please sign in to comment.