Skip to content

Commit

Permalink
Added unit tests for print and summary methods (#7, #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
wleoncio committed Sep 5, 2023
1 parent 2d96c11 commit 9ee0675
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/test-print-and-summary.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set.seed(778566)

test_that("print.reduced_vector() works as expected", {
expect_output(reduceVector(rpois(13, 8)), NA)
expect_output(
suppressMessages(reduceVector(rpois(11, 8), verbosity = 1)),
"8\\.00 1 2\\.0"
)
x <- reduceVector(rpois(6, 6))
expect_output(print(x), "Reduced vector : 4\\t4\\t4\\t5\\t8")
})
test_that("print.chacko_test() works as expected", {
expect_output(permChacko(rpois(8, 6), n_perm = 50L), NA)
y <- permChacko(rpois(3, 5), n_perm = 30L)
expect_output(print(y), "Test statistic \\(chisq_bar\\): 0\\.500000")
expect_output(print(y), "Analytic p-value\\s+: 0\\.778801")
expect_output(print(y), "Numeric p-value\\s+: 0\\.400000 \\(30 permutation")
expect_output(print(y), "Tabular p-value\\s+: 0\\.369550")
})
test_that("summary.reduced_vector() works as expected", {
expect_output(summary(reduceVector(rpois(7, 7))), "has been reduced 3 times")
})

0 comments on commit 9ee0675

Please sign in to comment.