Skip to content

Commit

Permalink
Adjusted unit tests (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
wleoncio committed Aug 31, 2023
1 parent 7bafda0 commit f0c3d93
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
33 changes: 22 additions & 11 deletions tests/testthat/test-chackoPapers.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
test_that("Examples from Chacko (1966) produce correct vectors", {
expect_equal(reduceVector(chacko66_sec3)[, "x"], c(10, 14, 18))
expect_equal(reduceVector(chacko66_sec3)[, "t"], c(1, 3, 1))
expect_equal(reduceVector(chacko66_sec5)[, 1], c(12, 14, 17, 20, 24, 26, 30))
expect_equal(reduceVector(chacko66_sec5)[, 2], c(1, 1, 2, 3, 1, 1, 1))
expect_equal(permChacko(chacko66_sec3)[["chisq_bar"]], 2.2857143)
expect_equal(permChacko(chacko66_sec5)[["chisq_bar"]], 13.5)
test_that("Vector reduction procedure works well", {
c66s3 <- reduceVector(chacko66_sec3)
c66s5 <- reduceVector(chacko66_sec5)
expect_equal(c66s3[, "x"], c(10, 14, 18))
expect_equal(c66s3[, "t"], c(1, 3, 1))
expect_equal(c66s5[, 1], c(12, 14, 17, 20, 24, 26, 30))
expect_equal(c66s5[, 2], c(1, 1, 2, 3, 1, 1, 1))
})

test_that("Examples from Chacko (1966) produce correct statistics", {
set.seed(3174)
c66s3 <- permChacko(chacko66_sec3)
c66s5 <- permChacko(chacko66_sec5)
expect_output(
print(c66s3),
"Chacko Test for Order-restriction with Permutation Test"
)
expect_equal(c66s3[["statistic"]], 2.2857143)
expect_equal(c66s5[["statistic"]], 13.5)
expect_equal(
permChacko(chacko66_sec3)[["numeric_p-value"]],
permChacko(chacko66_sec3)[["tabular_p-value"]],
c66s3[["p_values"]][["numeric"]],
c66s3[["p_values"]][["tabular"]],
tolerance = 1e-1
)
expect_equal(
permChacko(chacko66_sec5)[["numeric_p-value"]],
permChacko(chacko66_sec5)[["tabular_p-value"]],
c66s5[["p_values"]][["numeric"]],
c66s5[["p_values"]][["tabular"]],
tolerance = 1e-1
)
})
6 changes: 3 additions & 3 deletions tests/testthat/test-customExamples.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_that("Other from produce correct vectors", {
expect_equal(reduceVector(ruxton221207)[, "x"], c("x" = 5.6))
expect_equal(reduceVector(ruxton221207)[, "t"], c("t" = 5))
expect_equal(permChacko(ruxton221207)[["chisq_bar"]], 0)
expect_equal(permChacko(ruxton221207)[["statistic"]], 0)
set.seed(2715249)
expect_equal(
permChacko(ruxton221207)[["numeric_p-value"]],
Expand All @@ -23,7 +23,7 @@ test_that("Expected output is produced", {
x <- rpois(n, lambda = mu)
reps <- sample(c(0L, 10L, 100L, 1000L, 2000L), size = 1L)
y <- permChacko(x, n_perm = reps)
expect_length(y, 4L)
expect_type(y, "double")
expect_length(y, 5L)
expect_type(y, "list")
}
})

0 comments on commit f0c3d93

Please sign in to comment.