[dfe06d]: / tests / testthat / test_sim_ctd.R

Download this file

29 lines (22 with data), 789 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
context("Test sim_ctd")
## test output format ##
test_that("sim_ctd working as expected", {
## skip on CRAN
skip_on_cran()
## get data
data(fake_outbreak)
x <- fake_outbreak
N <- length(x$ances)
tTree <- data.frame(i = x$ances, j = 1:N)
## error check
expect_error(sim_ctd(tTree = tTree, eps = 1.1, lambda = 0),
"eps and lambda must be probabilities")
## for eps = 1 / lambda = 0, there should be one
## contact per transmission pair
ctd <- sim_ctd(tTree = tTree, eps = 1, lambda = 0)
expect_equal(nrow(ctd), sum(!is.na(x$ances)))
## for eps = 1 / lambda = 1, ensure all possible
## contacts are reported
ctd <- sim_ctd(tTree = tTree, eps = 1, lambda = 1)
expect_equal(nrow(ctd), N*(N-1)/2)
})